Skip to contentSkip to conversation

Add support for setting firmware property in FIT configuration

PATCH Superseded Jamin Lin 1 participant 3 messages May 20, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jamin Lin

author
#0 lore raw

v2 cover Add support for setting firmware property in FIT configuration

v1:
1. Fix unintended "-e" written into ITS
2. Add support for setting firmware property in FIT configuration

v2:
Fix review issue

documentation:
https://patchwork.yoctoproject.org/project/docs/patch/[email protected]/

Jamin Lin (2):
uboot-sign: Fix unintended "-e" written into ITS
uboot-sign: Add support for setting firmware property in FIT
configuration

 meta/classes-recipe/uboot-sign.bbclass | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH v2 1/2 uboot-sign: Fix unintended "-e" written into ITS

An unintended "-e" string may be written into the generated ITS file when users set the UBOOT_FIT_USER_SETTINGS variable to include custom binaries in the U-Boot image.

This issue is caused by the use of 'echo -e', which behaves inconsistently across different shells. While bash interprets '-e' as enabling escape sequences (e.g., \n, \t), dash—the default /bin/sh on many systems—does not recognize '-e' and treats it as a literal string. As a result, "-e" can be mistakenly injected into the ITS file under certain build environments.

To ensure consistent and shell-agnostic behavior, replace 'echo -e' with 'printf', which is well-defined by POSIX and behaves reliably across all common shells.

This change improves portability and prevents malformed ITS files caused by unintended string injection.

Fixes c12e013 ("uboot-sign: support to add users specific image tree source")
---
 meta/classes-recipe/uboot-sign.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes-recipe/uboot-sign.bbclass +1 -1
index e0771b5429..dcf94b7179 100644
@@ -425,7 +425,7 @@ EOF
 	fi
 
 	if [ -n "${UBOOT_FIT_USER_SETTINGS}" ] ; then
-		echo -e "${UBOOT_FIT_USER_SETTINGS}" >> ${UBOOT_ITS}
+		printf "%b" "${UBOOT_FIT_USER_SETTINGS}" >> ${UBOOT_ITS}
 	fi
 
 	if [ -n "${UBOOT_FIT_CONF_USER_LOADABLES}" ] ; then
Signature · 1 line
2.43.0
author
#2 lore raw

PATCH v2 2/2 uboot-sign: Add support for setting firmware property in FIT configuration

In reply to Jamin Lin

Add the ability to set the "firmware" property in the FIT configuration node by introducing the UBOOT_FIT_CONF_FIRMWARE variable.

This property defines the primary image to be executed during boot. If it is set, its value will be written into the FIT configuration under the "firmware" field. If not set, the bootloader will fall back to using the first entry in the "loadables" list.

Using this property improves control over the boot sequence, especially in multi-binary boot scenarios.

---
 meta/classes-recipe/uboot-sign.bbclass | 10 ++++++++++
 1 file changed, 10 insertions(+)
meta/classes-recipe/uboot-sign.bbclass +10 -0
index dcf94b7179..283b68759d 100644
@@ -101,6 +101,10 @@ UBOOT_FIT_TEE_IMAGE ?= "tee-raw.bin"
 # User specific settings
 UBOOT_FIT_USER_SETTINGS ?= ""
 
+# Sets the firmware property to select the image to boot first.
+# If not set, the first entry in "loadables" is used instead.
+UBOOT_FIT_CONF_FIRMWARE ?= ""
+
 # Unit name containing a list of users additional binaries to be loaded.
 # It is a comma-separated list of strings.
 UBOOT_FIT_CONF_USER_LOADABLES ?= ''
@@ -361,6 +365,7 @@ EOF
 # we want to sign it so that the SPL can verify it
 uboot_fitimage_assemble() {
 	conf_loadables="\"uboot\""
+	conf_firmware=""
 	rm -f ${UBOOT_ITS} ${UBOOT_FITIMAGE_BINARY}
 
 	# First we create the ITS script
@@ -432,6 +437,10 @@ EOF
 		conf_loadables="${conf_loadables}${UBOOT_FIT_CONF_USER_LOADABLES}"
 	fi
 
+    if [ -n "${UBOOT_FIT_CONF_FIRMWARE}" ] ; then
+		conf_firmware="firmware = \"${UBOOT_FIT_CONF_FIRMWARE}\";"
+	fi
+
 	cat << EOF >> ${UBOOT_ITS}
     };
 
@@ -439,6 +448,7 @@ EOF
         default = "conf";
         conf {
             description = "Boot with signed U-Boot FIT";
+            ${conf_firmware}
             loadables = ${conf_loadables};
             fdt = "fdt";
         };
Signature · 1 line
2.43.0