diff mbox series

[master/scarthgap,v2] bsp: fitimage-legacyhs: add default dtb support

Message ID 20250415033510.3899512-1-anshuld@ti.com
State Accepted
Delegated to: Ryan Eatmon
Headers show
Series [master/scarthgap,v2] bsp: fitimage-legacyhs: add default dtb support | expand

Commit Message

Anshul Dalal April 15, 2025, 3:35 a.m. UTC
FIT_CONF_DEFAULT_DTB config specifies the default dtb file for the
FITimage when multiple ones are provided[1].

Legacyhs fitimage does not currently support this feature set which is
required for repurposing the same class for falcon boot.

This patch adds support for FIT_CONF_DEFAULT_DTB without affecting
existing platforms that rely on legacyhs fitImage.

[1]:
https://docs.yoctoproject.org/ref-manual/variables.html#term-FIT_CONF_DEFAULT_DTB

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
Changes in v2:
 * Added subject prefix to specify target branch for the patch
v1:
https://lore.kernel.org/yocto-meta-ti/20250411154418.2951391-1-anshuld@ti.com/
---
 .../classes/kernel-fitimage-legacyhs.bbclass  | 23 +++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/meta-ti-bsp/classes/kernel-fitimage-legacyhs.bbclass b/meta-ti-bsp/classes/kernel-fitimage-legacyhs.bbclass
index 5e1fa56a..61813555 100644
--- a/meta-ti-bsp/classes/kernel-fitimage-legacyhs.bbclass
+++ b/meta-ti-bsp/classes/kernel-fitimage-legacyhs.bbclass
@@ -316,6 +316,7 @@  EOF
 # $4 ... ramdisk ID
 # $5 ... config ID
 # $6 ... tee ID/name
+# $7 ... default DTB ID
 fitimage_emit_section_config() {
 
 	conf_csum=${FITIMAGE_HASH_ALGO}
@@ -370,6 +371,16 @@  fitimage_emit_section_config() {
 		final_conf_desc="${conf_desc}"
 	fi
 
+	default_dtb_count=${7}
+	if [ "x${FITIMAGE_CONF_BY_NAME}" = "x1" ] ; then
+		default_conf_name="${FIT_CONF_DEFAULT_DTB}"
+	else
+		default_conf_name="conf-${default_dtb_count}"
+	fi
+	cat << EOF >> ${1}
+        default = "${default_conf_name}";
+EOF
+
 	dtbcount=1
 	for DTB in ${KERNEL_DEVICETREE}; do
 		DTB=$(basename "${DTB}")
@@ -386,12 +397,6 @@  fitimage_emit_section_config() {
 			fdt_line="fdt = \"fdt-${dtbcount}\";"
 		fi
 
-		if [ "x${dtbcount}" = "x1" ]; then
-			cat << EOF >> ${1}
-                default = "${conf_name}";
-EOF
-		fi
-
 # Generate a single configuration section
 			cat << EOF >> ${1}
                 ${conf_name} {
@@ -524,6 +529,7 @@  fitimage_assemble() {
 	ramdiskcount=${3}
 	setupcount=""
 	teecount=1
+	default_dtb_count=1
 	rm -f ${1} arch/${ARCH}/boot/${2}
 
 	fitimage_emit_fit_header ${1}
@@ -544,6 +550,9 @@  fitimage_assemble() {
 		dtbcount=1
 		dtboaddress="${UBOOT_DTBO_LOADADDRESS}"
 		for DTB in ${KERNEL_DEVICETREE}; do
+			if [ "${DTB}" = "${FIT_CONF_DEFAULT_DTB}" ]; then
+				default_dtb_count=${dtbcount}
+			fi
 			if echo ${DTB} | grep -q '/dts/'; then
 				bbwarn "${DTB} contains the full path to the the dts file, but only the dtb name should be used."
 				DTB=`basename ${DTB} | sed 's,\.dts$,.dtb,g'`
@@ -660,7 +669,7 @@  fitimage_assemble() {
 	else
 		teeref="${teecount}"
 	fi
-	fitimage_emit_section_config ${1} "${kernelcount}" "${dtbref}" "${ramdiskcount}" "${setupcount}" "${teeref}"
+	fitimage_emit_section_config ${1} "${kernelcount}" "${dtbref}" "${ramdiskcount}" "${setupcount}" "${teeref}" "${default_dtb_count}"
 
 	fitimage_emit_section_maint ${1} sectend