From 9449f755a726c6e6c03adfeb6ef22576455a69b7 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Wed, 5 Aug 2026 15:41:53 +0200 Subject: [PATCH 1/5] linux-qcom-bootimg: make creation a function In preparation for external device tree support where device trees are not build from a kernel recipe, factor out the qcom boot image creation into a function and call that for every kernel devicetree. No functional changes. Signed-off-by: Rouven Czerwinski (cherry picked from commit 99475a55d030e271bc31b361c569678c1cbabff4) --- classes/linux-qcom-bootimg.bbclass | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classes/linux-qcom-bootimg.bbclass b/classes/linux-qcom-bootimg.bbclass index bc44f6ca9..85931b2ea 100644 --- a/classes/linux-qcom-bootimg.bbclass +++ b/classes/linux-qcom-bootimg.bbclass @@ -75,7 +75,7 @@ python do_qcom_img_deploy() { with open(definitrd, "w") as f: f.write("This is not an initrd\n") - for dtbf in d.getVar("KERNEL_DEVICETREE").split(): + def make_dtb_image(dtbf): dtb = os.path.basename(dtbf) dtb_name = dtb.rsplit('.', 1)[0] @@ -140,6 +140,9 @@ python do_qcom_img_deploy() { if initrd: make_initramfs_image("boot-sd-%s-%s-%s.img", rootfs, initrd, d.getVar("INITRAMFS_IMAGE")) + + for dtbf in d.getVar("KERNEL_DEVICETREE").split(): + make_dtb_image(dtbf) } do_qcom_img_deploy[depends] += "skales-native:do_populate_sysroot" From db2aa9e09631d4e6a5872f8d6a84f1b8011c7b67 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Wed, 5 Aug 2026 15:46:32 +0200 Subject: [PATCH 2/5] linux-qcom-bootimg: support external device trees Add support for device trees that are not build from the kernel repository. The implementation is similar to kernel-fit-image.bbclass, we detect whether the provider for virtual/dtb has been changed and retrieve the build devicetrees from the sysroot instead of using those build by the kernel. A new variable QCOM_BOOTIMG_DEVICETREE is introduced to specify the trees for which boot images should be build. In order to use this, set the provider for virtual/dtb to your device tree yocto recipe and then specify QCOM_BOOTIMG_DEVICETREE: PREFERRED_PROVIDER_virtual/dtb = "my-devicetree-recipe" QCOM_BOOTIMG_DEVICETREE ?= " \ my-devicetree-for-bootimg.dtb \ " in your machine configuration. Signed-off-by: Rouven Czerwinski (cherry picked from commit 2c16f585ffcf905b24ed0cfe3b495359b64a5a06) --- classes/linux-qcom-bootimg.bbclass | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/classes/linux-qcom-bootimg.bbclass b/classes/linux-qcom-bootimg.bbclass index 85931b2ea..f050eef98 100644 --- a/classes/linux-qcom-bootimg.bbclass +++ b/classes/linux-qcom-bootimg.bbclass @@ -20,6 +20,11 @@ QIMG_DEPLOYDIR = "${WORKDIR}/qcom_deploy-${PN}" python __anonymous () { if d.getVar('INITRAMFS_IMAGE') != '': d.appendVarFlag('do_qcom_img_deploy', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') + + providerdtb = d.getVar("PREFERRED_PROVIDER_virtual/dtb") + if providerdtb: + d.appendVarFlag('do_qcom_img_deploy', 'depends', ' virtual/dtb:do_populate_sysroot') + d.setVar('EXTERNAL_KERNEL_DEVICETREE', "${RECIPE_SYSROOT}/boot/devicetree") } python do_qcom_img_deploy() { @@ -48,6 +53,7 @@ python do_qcom_img_deploy() { workdir = d.getVar("WORKDIR") kernel = os.path.join(workdir, "kernel-dtb") definitrd = os.path.join(workdir, "initrd.img") + external_dtbdir = d.getVar("EXTERNAL_KERNEL_DEVICETREE") mkbootimg = os.path.join(d.getVar("STAGING_BINDIR_NATIVE"), "skales", "mkbootimg") kernel_image_name = d.getVar("KERNEL_IMAGE_NAME") kernel_link_name = d.getVar("KERNEL_IMAGE_LINK_NAME") @@ -75,7 +81,7 @@ python do_qcom_img_deploy() { with open(definitrd, "w") as f: f.write("This is not an initrd\n") - def make_dtb_image(dtbf): + def make_dtb_image(dtbf, external=False): dtb = os.path.basename(dtbf) dtb_name = dtb.rsplit('.', 1)[0] @@ -115,10 +121,11 @@ python do_qcom_img_deploy() { consoles = ' '.join(map(lambda c: "console=%(tty)s,%(rate)sn8" % dict(zip(("rate", "tty"), c.split(';'))), getVarDTB("SERIAL_CONSOLES").split())) # prepare kernel image with appended dtb + dtbdir = external_dtbdir if external else image_dir with open(kernel, 'wb') as wfd: with open(kernel_src, 'rb') as rfd: shutil.copyfileobj(rfd, wfd) - with open(os.path.join(image_dir, dtb), 'rb') as rfd: + with open(os.path.join(dtbdir, dtb), 'rb') as rfd: shutil.copyfileobj(rfd, wfd) rootfs = getVarDTB("QCOM_BOOTIMG_ROOTFS") @@ -141,8 +148,19 @@ python do_qcom_img_deploy() { if initrd: make_initramfs_image("boot-sd-%s-%s-%s.img", rootfs, initrd, d.getVar("INITRAMFS_IMAGE")) - for dtbf in d.getVar("KERNEL_DEVICETREE").split(): - make_dtb_image(dtbf) + if not d.getVar("QCOM_BOOTIMG_DEVICETREE") and not d.getVar("KERNEL_DEVICETREE"): + bb.fatal("Either QCOM_BOOTIMG_DEVICETREE or KERNEL_DEVICETREE needed for linux-qcom-bootimg.bbclass") + + if d.getVar("KERNEL_DEVICETREE"): + for dtbf in d.getVar("KERNEL_DEVICETREE").split(): + make_dtb_image(dtbf) + + if d.getVar("QCOM_BOOTIMG_DEVICETREE") and not external_dtbdir: + bb.fatal("QCOM_BOOTIMG_DEVICETREE requires PREFERRED_PROVIDER_virtual/dtb to be set") + + if d.getVar("QCOM_BOOTIMG_DEVICETREE"): + for dtbf in d.getVar("QCOM_BOOTIMG_DEVICETREE").split(): + make_dtb_image(dtbf, external=True) } do_qcom_img_deploy[depends] += "skales-native:do_populate_sysroot" From 1dddb2bce9ff19a2f24d9da3373f9ad042bb1561 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Tue, 8 Sep 2026 09:32:47 +0200 Subject: [PATCH 3/5] linux-qcom-bootimg: add suffix for external dtbs Name boot images generated from external dtbs with a -ext-dtb suffix to indicate that they were generated from an external device tree recipe and also to prevent overwriting similarly named boot images generated from a kernel device tree. Signed-off-by: Rouven Czerwinski (cherry picked from commit e4c5f6ca6aae544561332f2fbe43a85187e1b554) --- classes/linux-qcom-bootimg.bbclass | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/classes/linux-qcom-bootimg.bbclass b/classes/linux-qcom-bootimg.bbclass index f050eef98..e2ec7779d 100644 --- a/classes/linux-qcom-bootimg.bbclass +++ b/classes/linux-qcom-bootimg.bbclass @@ -132,21 +132,25 @@ python do_qcom_img_deploy() { if rootfs is None: bb.fatal("QCOM_BOOTIMG_ROOTFS is undefined") - output = make_image("boot-%s-%s.img", rootfs) + template = "boot-%s-%s-ext-dtb.img" if external else "boot-%s-%s.img" + output = make_image(template, rootfs) if not os.path.exists(output_img): os.symlink(os.path.basename(output), output_img) if initrd: - make_initramfs_image("boot-%s-%s-%s.img", rootfs, initrd, d.getVar("INITRAMFS_IMAGE")) + template = "boot-%s-%s-%s-ext-dtb.img" if external else "boot-%s-%s-%s.img" + make_initramfs_image(template, rootfs, initrd, d.getVar("INITRAMFS_IMAGE")) sd_rootfs = getVarDTB("SD_QCOM_BOOTIMG_ROOTFS") if sd_rootfs: - output = make_image("boot-sd-%s-%s.img", sd_rootfs) + template = "boot-sd-%s-%s-ext-dtb.img" if external else "boot-sd-%s-%s.img" + output = make_image(template, sd_rootfs) if not os.path.exists(output_sd_img): os.symlink(os.path.basename(output), output_sd_img) if initrd: - make_initramfs_image("boot-sd-%s-%s-%s.img", rootfs, initrd, d.getVar("INITRAMFS_IMAGE")) + template = "boot-sd-%s-%s-%s-ext-dtb.img" if external else "boot-sd-%s-%s-%s.img" + make_initramfs_image(template, rootfs, initrd, d.getVar("INITRAMFS_IMAGE")) if not d.getVar("QCOM_BOOTIMG_DEVICETREE") and not d.getVar("KERNEL_DEVICETREE"): bb.fatal("Either QCOM_BOOTIMG_DEVICETREE or KERNEL_DEVICETREE needed for linux-qcom-bootimg.bbclass") From 55fe5689532c53c2246660844767a0ee188de05e Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Tue, 8 Sep 2026 09:40:38 +0200 Subject: [PATCH 4/5] devicetree-dummy: recipe for bootimages with external dtbs Add a devicetree-dummy recipe that generates an empty but valid DTB for testing with the qcom-armv8 machine. Signed-off-by: Rouven Czerwinski (cherry picked from commit 7580c30483c4e1813cca19b3a45515d164e2d285) --- recipes-bsp/devicetree/devicetree-dummy.bb | 7 +++++++ recipes-bsp/devicetree/files/qcom-armv8-dummy.dts | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 recipes-bsp/devicetree/devicetree-dummy.bb create mode 100644 recipes-bsp/devicetree/files/qcom-armv8-dummy.dts diff --git a/recipes-bsp/devicetree/devicetree-dummy.bb b/recipes-bsp/devicetree/devicetree-dummy.bb new file mode 100644 index 000000000..23099b25d --- /dev/null +++ b/recipes-bsp/devicetree/devicetree-dummy.bb @@ -0,0 +1,7 @@ +inherit devicetree + +COMPATIBLE_MACHINE = "qcom-armv8" + +SRC_URI = "\ + file://qcom-armv8-dummy.dts \ +" diff --git a/recipes-bsp/devicetree/files/qcom-armv8-dummy.dts b/recipes-bsp/devicetree/files/qcom-armv8-dummy.dts new file mode 100644 index 000000000..863020407 --- /dev/null +++ b/recipes-bsp/devicetree/files/qcom-armv8-dummy.dts @@ -0,0 +1,3 @@ +/dts-v1/; +/{ +}; From 6bbf4839b7ea6f0dc7daae45be8faacdd6bd4001 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Tue, 8 Sep 2026 09:48:13 +0200 Subject: [PATCH 5/5] ci: test external devicetree boot image generation Modify the qcom-armv8 machine to use the dummy device tree recipe and generate a boot image from an external devicetree with it. Signed-off-by: Rouven Czerwinski (cherry picked from commit aa00cff93cad0b12fea6c5aa95c8b5725965d7b7) --- ci/qcom-armv8a.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ci/qcom-armv8a.yml b/ci/qcom-armv8a.yml index d5e3d3e4f..313d42e29 100644 --- a/ci/qcom-armv8a.yml +++ b/ci/qcom-armv8a.yml @@ -5,4 +5,9 @@ header: includes: - ci/base.yml +local_conf_header: + external_devicetree: | + PREFERRED_PROVIDER_virtual/dtb = "devicetree-dummy" + QCOM_BOOTIMG_DEVICETREE = "qcom-armv8-dummy.dtb" + machine: qcom-armv8a