Browse Source

image: Add support for deploying multiple DTBs

This allows to support non-distro-boot images which select from multiple
DTBs during boot.

The isar-image-ubi recipe still only supports one DTB file, but that is
an exemplary recipe anyway.

Based on original patch by Chao Zeng.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Jan Kiszka 5 years ago
parent
commit
8df13076a8

+ 5 - 0
RECIPE-API-CHANGELOG.md

@@ -231,3 +231,8 @@ That task used to be at the end of a cache-warming build, a follow-up build
 with `ISAR_USE_CACHED_BASE_REPO` did use that. Now we cache all downloads
 anyway, if `ISAR_USE_CACHED_BASE_REPO` is set a build will use all the
 downloads from previous builds for the cache.
+
+### Renamed DTB_FILE to DTB_FILES, adding support for multiple entries
+
+DTB_FILES now allows to specify multiple DTBs that should be deployed for
+consumption by imaging classes.

+ 1 - 1
meta-isar/conf/machine/nand-ubi-demo.conf

@@ -10,4 +10,4 @@ MKUBIFS_ARGS := "-m 0x1000 -e 0x3e000 -c 1500"
 UBINIZE_ARGS = "-vv -m 0x1000 -p 0x40000"
 IMAGE_TYPE ?= "ubi-ubifs-img"
 
-DTB_FILE = "imx6q-sabrelite.dtb"
+DTB_FILES = "imx6q-sabrelite.dtb"

+ 2 - 1
meta-isar/recipes-core/images/isar-image-ubi.bb

@@ -20,7 +20,8 @@ TEMPLATE_FILES = "ubinize.cfg.tmpl fitimage.its.tmpl"
 
 KERNEL_IMG = "${PP_DEPLOY}/${KERNEL_IMAGE}"
 INITRD_IMG = "${PP_DEPLOY}/${INITRD_IMAGE}"
-DTB_IMG = "${PP_DEPLOY}/${DTB_FILE}"
+# only one dtb file supported, pick the first
+DTB_IMG = "${PP_DEPLOY}/${@(d.getVar('DTB_FILES').split() or [''])[0]}"
 
 UBIFS_IMG = "${PP_DEPLOY}/${UBIFS_IMAGE_FILE}"
 FIT_IMG = "${PP_DEPLOY}/${FIT_IMAGE_FILE}"

+ 8 - 6
meta/classes/image.bbclass

@@ -19,6 +19,9 @@ IMAGE_FULLNAME = "${PN}-${DISTRO}-${MACHINE}"
 KERNEL_IMAGE ?= "${IMAGE_FULLNAME}-${KERNEL_FILE}"
 INITRD_IMAGE ?= "${IMAGE_FULLNAME}-initrd.img"
 
+# This defines the deployed dtbs for reuse by imagers
+DTB_FILES ?= ""
+
 # Useful variables for imager implementations:
 PP = "/home/builder/${PN}"
 PP_DEPLOY = "${PP}/deploy"
@@ -139,17 +142,16 @@ do_copy_boot_files() {
         cp -f "$initrd" '${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}'
     fi
 
-    # Check DTB_FILE via inline python to handle unset case:
-    if [ -n "${@d.getVar('DTB_FILE', True) or ""}" ]; then
+    for file in ${DTB_FILES}; do
         dtb="$(find '${IMAGE_ROOTFS}/usr/lib' -type f \
-                    -iwholename '*linux-image-*/${DTB_FILE}' | head -1)"
+                    -iwholename '*linux-image-*/'${file} | head -1)"
 
         if [ -z "$dtb" -o ! -e "$dtb" ]; then
-            die "${DTB_FILE} not found"
+            die "${file} not found"
         fi
 
-        cp -f "$dtb" "${DEPLOY_DIR_IMAGE}/${DTB_FILE}"
-    fi
+        cp -f "$dtb" "${DEPLOY_DIR_IMAGE}/"
+    done
 }
 addtask copy_boot_files before do_rootfs_postprocess after do_rootfs_install