@@ -75,6 +75,11 @@ SPL_WITH_DTB_BINARY ?= ""
# U-Boot fitImage description
UBOOT_FIT_DESC ?= "U-Boot fitImage for ${DISTRO_NAME}/${PV}/${MACHINE}"
+# Additional mkimage options for the U-Boot fitImage, passed both when
+# creating and when signing it, so that an option such as "-E", which places
+# the image data after the FIT structure, is kept by mkimage -F
+UBOOT_FIT_MKIMAGE_EXTRA_OPTS ?= ""
+
# U-Boot fitImage Hash Algo
UBOOT_FIT_HASH_ALG ?= "sha256"
@@ -560,6 +565,7 @@ EOF
#
${UBOOT_MKIMAGE} \
${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \
+ ${UBOOT_FIT_MKIMAGE_EXTRA_OPTS} \
-f ${UBOOT_ITS} \
${UBOOT_FITIMAGE_BINARY}
@@ -588,6 +594,7 @@ EOF
cp ${SPL_DIR}/${SPL_DTB_BINARY} ${SPL_DIR}/${SPL_DTB_SIGNED}
${UBOOT_MKIMAGE_SIGN} \
${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \
+ ${UBOOT_FIT_MKIMAGE_EXTRA_OPTS} \
-F -k "${SPL_SIGN_KEYDIR}" \
-K "${SPL_DIR}/${SPL_DTB_SIGNED}" \
-r ${UBOOT_FITIMAGE_BINARY} \
@@ -601,6 +608,7 @@ EOF
# Sign the U-boot FIT image
${UBOOT_MKIMAGE_SIGN} \
${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \
+ ${UBOOT_FIT_MKIMAGE_EXTRA_OPTS} \
-F -k "${SPL_SIGN_KEYDIR}" \
-r ${UBOOT_FITIMAGE_BINARY} \
${SPL_MKIMAGE_SIGN_ARGS}
@@ -2133,6 +2133,50 @@ UBOOT_FIT_HASH_ALG = "sha256"
self._test_fitimage(bb_vars)
+ def test_sign_uboot_fit_image_extra_opts(self):
+ """
+ Summary: Check if UBOOT_FIT_MKIMAGE_EXTRA_OPTS is passed to
+ mkimage both when creating and when signing the U-Boot
+ fitImage.
+ Expected: 1) U-Boot its and FIT image are built and signed
+ successfully
+ 2) UBOOT_FIT_MKIMAGE_EXTRA_OPTS = "-E" places the image
+ data after the FIT structure and signing keeps it
+ there: the image nodes have data-offset instead of
+ data
+ Product: oe-core
+ Author: Viswanath Kraleti <viswanath.kraleti@oss.qualcomm.com>
+ """
+ machine = self._get_machine_or_skip()
+ config = """
+# Enable creation and signing of the U-Boot fitImage, with external data
+UBOOT_FITIMAGE_ENABLE = "1"
+SPL_SIGN_ENABLE = "1"
+SPL_SIGN_KEYNAME = "spl-oe-selftest"
+SPL_SIGN_KEYDIR = "${TOPDIR}/signing-keys"
+UBOOT_ENTRYPOINT = "0x80000000"
+UBOOT_LOADADDRESS = "0x80000000"
+UBOOT_DTB_LOADADDRESS = "0x82000000"
+SPL_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000"
+UBOOT_EXTLINUX = "0"
+UBOOT_FIT_GENERATE_KEYS = "1"
+UBOOT_FIT_HASH_ALG = "sha256"
+UBOOT_FIT_MKIMAGE_EXTRA_OPTS = "-E"
+"""
+ config = FitImageTestCase._config_add_machine_settings(config, machine, keys=["UBOOT_MACHINE", "SPL_BINARY", "UBOOT_DTB_BINARY", "UBOOT_ARCH"])
+ config = self._require_machine_capability(config, machine, '_cap_spl_dtb')
+ self.write_config(config)
+ bb_vars = self._fit_get_bb_vars()
+ self._test_fitimage(bb_vars)
+
+ fitimage_path = os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], "u-boot-fitImage-%s" % bb_vars['MACHINE'])
+ dtc_bindir = FitImageTestCase._setup_native('dtc-native')
+ fdtget_path = os.path.join(dtc_bindir, 'fdtget')
+ for node in ('/images/uboot', '/images/fdt'):
+ self._verify_dtb_property(dtc_bindir, fitimage_path, node, 'data', None, absent=True)
+ result = runCmd('%s %s %s data-offset' % (fdtget_path, fitimage_path, node))
+ self.logger.debug("%s data-offset: %s" % (node, result.output))
+
def test_sign_cascaded_uboot_fit_image(self):
"""
Summary: Check if U-Boot FIT image and Image Tree Source (its) are
There is no way to pass options such as -E, which places the image data after the FIT structure, to the mkimage call creating the U-Boot fitImage. Such an option also has to be repeated when signing, since mkimage -F moves external data back into the FIT unless -E is given again. Add UBOOT_FIT_MKIMAGE_EXTRA_OPTS and pass it to the mkimage calls that create and sign the U-Boot fitImage, and extend the selftest to check that -E is kept through signing. It is separate from FIT_MKIMAGE_EXTRA_OPTS, so that options meant for the kernel FIT image do not change the U-Boot one. AI-Generated: Uses Claude Code Signed-off-by: Viswanath Kraleti <viswanath.kraleti@oss.qualcomm.com> --- meta/classes-recipe/uboot-sign.bbclass | 8 +++++ meta/lib/oeqa/selftest/cases/fitimage.py | 44 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+)