]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
kernel-fitimage: Allow user to select dtb when multiple dtb exists
authorSandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
Wed, 4 Jan 2023 22:09:02 +0000 (15:09 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 12 Jan 2023 23:07:39 +0000 (23:07 +0000)
Allow user to select the default DTB for FIT image when multiple
dtb's exists.

From machine.conf or local.conf user can specify the default dtb
for FIT image as shown below.

FIT_CONF_DEFAULT_DTB = "board-default.dtb"

Also fallback to avaialable dtb when FIT_CONF_DEFAULT_DTB doesn't
exits or empty.

Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/kernel-fitimage.bbclass

index 92e236a0a464f9ae028001a765084d5f8f7586e4..b77747404f5be797964dca3b20e1ac988ff6580b 100644 (file)
@@ -89,6 +89,9 @@ FIT_CONF_PREFIX[doc] = "Prefix to use for FIT configuration node name"
 
 FIT_SUPPORTED_INITRAMFS_FSTYPES ?= "cpio.lz4 cpio.lzo cpio.lzma cpio.xz cpio.zst cpio.gz ext2.gz cpio"
 
+# Allow user to select the default DTB for FIT image when multiple dtb's exists.
+FIT_CONF_DEFAULT_DTB ?= ""
+
 # Keys used to sign individually image nodes.
 # The keys to sign image nodes must be different from those used to sign
 # configuration nodes, otherwise the "required" property, from
@@ -412,6 +415,7 @@ fitimage_emit_section_config() {
        bootscr_line=""
        setup_line=""
        default_line=""
+       default_dtb_image="${FIT_CONF_DEFAULT_DTB}"
 
        dtb_image_sect=$(symlink_points_below $dtb_image "${EXTERNAL_KERNEL_DEVICETREE}")
        if [ -z "$dtb_image_sect" ]; then
@@ -462,7 +466,17 @@ fitimage_emit_section_config() {
                # default node is selected based on dtb ID if it is present,
                # otherwise its selected based on kernel ID
                if [ -n "$dtb_image" ]; then
-                       default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";"
+                       # Select default node as user specified dtb when
+                       # multiple dtb exists.
+                       if [ -n "$default_dtb_image" ]; then
+                               if [ -s "${EXTERNAL_KERNEL_DEVICETREE}/$default_dtb_image" ]; then
+                                       default_line="default = \"${FIT_CONF_PREFIX}$default_dtb_image\";"
+                               else
+                                       bbwarn "Couldn't find a valid user specified dtb in ${EXTERNAL_KERNEL_DEVICETREE}/$default_dtb_image"
+                               fi
+                       else
+                               default_line="default = \"${FIT_CONF_PREFIX}$dtb_image\";"
+                       fi
                else
                        default_line="default = \"${FIT_CONF_PREFIX}$kernel_id\";"
                fi