Skip to contentSkip to conversation

bsp: fitimage-legacyhs: add default dtb support

PATCH Superseded Anshul Dalal 2 participants 2 messages Apr 11, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bsp: fitimage-legacyhs: add default dtb support

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 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

---
 .../classes/kernel-fitimage-legacyhs.bbclass  | 23 +++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
meta-ti-bsp/classes/kernel-fitimage-legacyhs.bbclass +16 -7
index 5e1fa56a..61813555 100644
@@ -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
 
Signature · 1 line
2.49.0
#1 lore raw

You need to specify which branch this patch is intended to apply to:

[meta-ti][master/scarthgap][PATCH v1] bsp: fitimage-legacyhs: add default dtb support

         ^^^^^^^^^^^^^^^^^^
Quoted 97 lines · Anshul Dalal via lists.yoctoproject.org

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 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

---
  .../classes/kernel-fitimage-legacyhs.bbclass  | 23 +++++++++++++------
  1 file changed, 16 insertions(+), 7 deletions(-)
meta-ti-bsp/classes/kernel-fitimage-legacyhs.bbclass +16 -8
index 5e1fa56a..61813555 100644
@@ -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
 
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#18461): https://lists.yoctoproject.org/g/meta-ti/message/18461
Mute This Topic: https://lists.yoctoproject.org/mt/112212856/6551054
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-ti/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 3 lines
Ryan Eatmon                [email protected]
-----------------------------------------
Texas Instruments, Inc.  -  LCPD  -  MGTS