Skip to content

Commit

Permalink
meta-isar: Don't rely on hardcoded versioned kernel filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
flenorm committed Jun 2, 2017
1 parent 14dc601 commit 52b8d35
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
4 changes: 0 additions & 4 deletions doc/user_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,13 @@ Every machine is described in its configuration file. The file defines the follo
- Linux kernel.
- U-Boot or other boot loader.
- Machine-specific firmware.
- `KERNEL_IMAGE` - The name of kernel binary that it installed to `/boot` folder in target filesystem. This variable is used by Isar to extract the kernel binary and put it into the deploy folder. This makes sense for embedded devices, where kernel and root filesystem are written to different flash partitions. This variable is optional.
- `INITRD_IMAGE` - The name of `ramdisk` binary. The meaning of this variable is similar to `KERNEL_IMAGE`. This variable is optional.
- `MACHINE_SERIAL` - The name of serial device that will be used for console output.
- `IMAGE_TYPE` - The type of images to be generated for this machine.

Below is an example of machine configuration file for `Raspberry Pi` board:
```
IMAGE_PREINSTALL = "linux-image-rpi-rpfv \
raspberrypi-bootloader-nokernel"
KERNEL_IMAGE = "vmlinuz-4.4.0-1-rpi"
INITRD_IMAGE = "initrd.img-4.4.0-1-rpi"
MACHINE_SERIAL = "ttyAMA0"
IMAGE_TYPE = "rpi-sdimg"
```
Expand Down
2 changes: 0 additions & 2 deletions meta-isar/conf/machine/qemuamd64.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Copyright (C) 2015-2016 ilbers GmbH

IMAGE_PREINSTALL = "linux-image-amd64"
KERNEL_IMAGE = "vmlinuz-4.9.0-3-amd64"
INITRD_IMAGE = "initrd.img-4.9.0-3-amd64"

MACHINE_SERIAL = "ttyS0"
ROOTFS_DEV = "sda"
Expand Down
2 changes: 0 additions & 2 deletions meta-isar/conf/machine/qemuarm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Copyright (C) 2015-2016 ilbers GmbH

IMAGE_PREINSTALL = "linux-image-armmp"
KERNEL_IMAGE = "vmlinuz-4.9.0-3-armmp"
INITRD_IMAGE = "initrd.img-4.9.0-3-armmp"

MACHINE_SERIAL = "ttyAMA0"
ROOTFS_DEV = "mmcblk0"
Expand Down
4 changes: 0 additions & 4 deletions meta-isar/conf/machine/qemui386.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
# Copyright (C) 2015-2016 ilbers GmbH

IMAGE_PREINSTALL = "linux-image-686-pae"
KERNEL_IMAGE = "vmlinuz-4.9.0-3-686-pae"
INITRD_IMAGE = "initrd.img-4.9.0-3-686-pae"

IMAGE_BOOT_FILES = "${KERNEL_IMAGE}"

MACHINE_SERIAL = "ttyS0"
ROOTFS_DEV = "sda"
Expand Down
2 changes: 0 additions & 2 deletions meta-isar/conf/machine/rpi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ IMAGE_PREINSTALL = " \
vim \
"

KERNEL_IMAGE = "vmlinuz-4.4.0-1-rpi"
INITRD_IMAGE = "initrd.img-4.4.0-1-rpi"
IMAGE_BOOT_FILES = "boot_rpi/overlays/*;overlays/* boot_rpi/*.*"

MACHINE_SERIAL = "ttyAMA0"
Expand Down
24 changes: 22 additions & 2 deletions meta/classes/image.bbclass
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# This software is a part of ISAR.
# Copyright (C) 2015-2016 ilbers GmbH

KERNEL_IMAGE ?= ""
INITRD_IMAGE ?= ""
def get_image_name(d, name_link):
S = d.getVar("S", True)
path_link = os.path.join(S, name_link)
if os.path.exists(path_link):
return os.path.basename(os.path.realpath(path_link))

return ""

KERNEL_IMAGE = "${@get_image_name(d, 'vmlinuz')}"
INITRD_IMAGE = "${@get_image_name(d, 'initrd.img')}"

IMAGE_INSTALL ?= ""
IMAGE_TYPE ?= "ext4-img"
Expand Down Expand Up @@ -43,3 +51,15 @@ do_populate() {

addtask populate before do_build
do_populate[deptask] = "do_install"

python do_update_boot_options() {
KERNEL_IMAGE = d.getVar("KERNEL_IMAGE", True)
if not KERNEL_IMAGE:
d.setVar("KERNEL_IMAGE", get_image_name(d, "vmlinuz"))

INITRD_IMAGE = d.getVar("INITRD_IMAGE", True)
if not INITRD_IMAGE:
d.setVar("INITRD_IMAGE", get_image_name(d, "initrd.img"))
}

addtask do_update_boot_options after do_populate
2 changes: 1 addition & 1 deletion scripts/start_amd64_vm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright (C) 2017 Siemens AG

start_qemu_amd64() {
eval "$(grep '^\(KERNEL_IMAGE\|INITRD_IMAGE\)' "$(dirname "$0")/../meta-isar/conf/machine/qemuamd64.conf" | sed 's/[[:space:]]*=[[:space:]]/=/')"
eval "$(bitbake -e multiconfig:qemuamd64:isar-image-base | grep '^\(KERNEL\|INITRD\)_IMAGE')"

readonly PATH_KERNEL="${1}/tmp/deploy/images/${KERNEL_IMAGE}"
readonly PATH_INITRD="${1}/tmp/deploy/images/${INITRD_IMAGE}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/start_armhf_vm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright (C) 2015-2016 ilbers GmbH

start_qemuarm() {
eval "$(grep '^\(KERNEL_IMAGE\|INITRD_IMAGE\)' "$(dirname "$0")/../meta-isar/conf/machine/qemuarm.conf" | sed 's/[[:space:]]*=[[:space:]]/=/')"
eval "$(bitbake -e multiconfig:qemuarm:isar-image-base | grep '^\(KERNEL\|INITRD\)_IMAGE')"

readonly PATH_KERNEL="${1}/tmp/deploy/images/${KERNEL_IMAGE}"
readonly PATH_INITRD="${1}/tmp/deploy/images/${INITRD_IMAGE}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/start_i386_vm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright (C) 2015-2016 ilbers GmbH

start_qemu_i386() {
eval "$(grep '^\(KERNEL_IMAGE\|INITRD_IMAGE\)' "$(dirname "$0")/../meta-isar/conf/machine/qemui386.conf" | sed 's/[[:space:]]*=[[:space:]]/=/')"
eval "$(bitbake -e multiconfig:qemui386:isar-image-base | grep '^\(KERNEL\|INITRD\)_IMAGE')"

readonly PATH_KERNEL="${1}/tmp/deploy/images/${KERNEL_IMAGE}"
readonly PATH_INITRD="${1}/tmp/deploy/images/${INITRD_IMAGE}"
Expand Down

0 comments on commit 52b8d35

Please sign in to comment.