]> code.ossystems Code Review - openembedded-core.git/commitdiff
uboot: Fixes SPL verified boot on corner cases
authorKlaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
Wed, 31 Mar 2021 13:23:13 +0000 (10:23 -0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 6 Apr 2021 21:37:19 +0000 (22:37 +0100)
* The kernel-fitimage class adds a do_assemble_fitimage_initramfs task
  regardless of INITRAMFS_IMAGE_BUNDLE setting, which in some cases can
  result in that task running after do_uboot_assemble_fitimage and
  overwriting the u-boot-spl.dtb file with the pristine version (without
  public key). Fix this by making do_uboot_assemble_fitimage dependant
  on both do_assemble_fitimage_* tasks, regardless of the aforementioned
  setting.

* Adjust 'type' and 'os' on the U-boot fitimage its script so that
  mkimage/dumpimage can recognize them.

* Move the deployment of the u-boot-spl-nodtb files outside of
  concat_spl_dtb_helper(), so that we can better isolate the scenarios
  of creating an (unsigned) U-Boot fitimage versus also signing it. This
  prevents some stale files from being deployed in the images directory.

* Remove any u-boot-fitImage and u-boot-its files from build tree, in
  case the build tree is being reused across bitbake calls.

Signed-off-by: Klaus Heinrich Kiwi <klaus@linux.vnet.ibm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/uboot-sign.bbclass
meta/lib/oeqa/selftest/cases/fitimage.py

index 137ce29b438799f4359f4da4ab8e1e554eec1db9..d11882f90fd4d8338a4bbe2d6aca3b45483ce346 100644 (file)
@@ -142,19 +142,12 @@ concat_spl_dtb_helper() {
        # We only deploy symlinks to the u-boot-spl.dtb,as the KERNEL_PN will
        # be responsible for deploying the real file
        if [ -e "${SPL_DIR}/${SPL_DTB_BINARY}" ] ; then
-               deployed_spl_dtb_binary='${DEPLOY_DIR_IMAGE}/${SPL_DTB_IMAGE}'
                ln -sf ${SPL_DTB_IMAGE} ${DEPLOYDIR}/${SPL_DTB_SYMLINK}
                ln -sf ${SPL_DTB_IMAGE} ${DEPLOYDIR}/${SPL_DTB_BINARY}
        fi
 
-       if [ -f "${SPL_DIR}/${SPL_NODTB_BINARY}" ] ; then
-               echo "Copying u-boot-nodtb binary..."
-               install -m 0644 ${SPL_DIR}/${SPL_NODTB_BINARY} ${DEPLOYDIR}/${SPL_NODTB_IMAGE}
-               ln -sf ${SPL_NODTB_IMAGE} ${DEPLOYDIR}/${SPL_NODTB_SYMLINK}
-               ln -sf ${SPL_NODTB_IMAGE} ${DEPLOYDIR}/${SPL_NODTB_BINARY}
-       fi
-
        # Concatenate the SPL nodtb binary and u-boot.dtb
+       deployed_spl_dtb_binary='${DEPLOY_DIR_IMAGE}/${SPL_DTB_IMAGE}'
        if [ -e "${DEPLOYDIR}/${SPL_NODTB_IMAGE}" -a -e "$deployed_spl_dtb_binary" ] ; then
                cd ${DEPLOYDIR}
                cat ${SPL_NODTB_IMAGE} $deployed_spl_dtb_binary | tee ${B}/${CONFIG_B_PATH}/${SPL_BINARY} > ${SPL_IMAGE}
@@ -343,8 +336,8 @@ uboot_fitimage_assemble() {
         uboot {
             description = "U-Boot image";
             data = /incbin/("${uboot_nodtb_bin}");
-            type = "uboot";
-            os = "U-Boot";
+            type = "standalone";
+            os = "u-boot";
             arch = "${UBOOT_ARCH}";
             compression = "none";
             load = <${UBOOT_LOADADDRESS}>;
@@ -438,6 +431,7 @@ do_uboot_assemble_fitimage() {
                # do_assemble_fitimage task
                cp -P ${STAGING_DATADIR}/u-boot-spl*.dtb ${B}
                cp -P ${STAGING_DATADIR}/u-boot-nodtb*.bin ${B}
+               rm -rf ${B}/u-boot-fitImage-* ${B}/u-boot-its-*
                kernel_uboot_fitimage_name=`basename ${STAGING_DATADIR}/u-boot-fitImage-*`
                kernel_uboot_its_name=`basename ${STAGING_DATADIR}/u-boot-its-*`
                cd ${B}
@@ -453,19 +447,30 @@ do_deploy_prepend_pn-${UBOOT_PN}() {
        if [ "${UBOOT_SIGN_ENABLE}" = "1" -a -n "${UBOOT_DTB_BINARY}" ] ; then
                concat_dtb
        fi
-       if [ "${SPL_SIGN_ENABLE}" = "1" -a -n "${SPL_DTB_BINARY}" ] ; then
-               concat_spl_dtb
-       fi
 
-       # We only deploy the symlinks to the uboot-fitImage and uboot-its
-       # images, as the KERNEL_PN will take care of deploying the real file
        if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" ] ; then
+       # Deploy the u-boot-nodtb binary and symlinks...
+               if [ -f "${SPL_DIR}/${SPL_NODTB_BINARY}" ] ; then
+                       echo "Copying u-boot-nodtb binary..."
+                       install -m 0644 ${SPL_DIR}/${SPL_NODTB_BINARY} ${DEPLOYDIR}/${SPL_NODTB_IMAGE}
+                       ln -sf ${SPL_NODTB_IMAGE} ${DEPLOYDIR}/${SPL_NODTB_SYMLINK}
+                       ln -sf ${SPL_NODTB_IMAGE} ${DEPLOYDIR}/${SPL_NODTB_BINARY}
+               fi
+
+
+               # We only deploy the symlinks to the uboot-fitImage and uboot-its
+               # images, as the KERNEL_PN will take care of deploying the real file
                ln -sf ${UBOOT_FITIMAGE_IMAGE} ${DEPLOYDIR}/${UBOOT_FITIMAGE_BINARY}
                ln -sf ${UBOOT_FITIMAGE_IMAGE} ${DEPLOYDIR}/${UBOOT_FITIMAGE_SYMLINK}
                ln -sf ${UBOOT_ITS_IMAGE} ${DEPLOYDIR}/${UBOOT_ITS}
                ln -sf ${UBOOT_ITS_IMAGE} ${DEPLOYDIR}/${UBOOT_ITS_SYMLINK}
        fi
 
+       if [ "${SPL_SIGN_ENABLE}" = "1" -a -n "${SPL_DTB_BINARY}" ] ; then
+               concat_spl_dtb
+       fi
+
+
 }
 
 do_deploy_append_pn-${UBOOT_PN}() {
@@ -496,9 +501,7 @@ python () {
         # If the Kernel fitImage is being signed, we need to
         # create the U-Boot fitImage after it
         if d.getVar('UBOOT_SIGN_ENABLE') == '1':
-            if d.getVar('INITRAMFS_IMAGE_BUNDLE') == "1":
-                d.appendVarFlag('do_uboot_assemble_fitimage', 'depends', ' %s:do_assemble_fitimage_initramfs' % d.getVar('KERNEL_PN'))
-            else:
-                d.appendVarFlag('do_uboot_assemble_fitimage', 'depends', ' %s:do_assemble_fitimage' % d.getVar('KERNEL_PN'))
+            d.appendVarFlag('do_uboot_assemble_fitimage', 'depends', ' %s:do_assemble_fitimage' % d.getVar('KERNEL_PN'))
+            d.appendVarFlag('do_uboot_assemble_fitimage', 'depends', ' %s:do_assemble_fitimage_initramfs' % d.getVar('KERNEL_PN'))
 
 }
index b911fded74d08b25ff6c1a4ffcf2f0585a9f01cd..815ee48c054133092b6f37447ed9a3b85a7f5b35 100644 (file)
@@ -293,7 +293,7 @@ FIT_SIGN_INDIVIDUAL = "1"
         # different architectures.
         its_field_check = [
             'description = "A model description";',
-            'type = "uboot";',
+            'type = "standalone";',
             'load = <0x80080000>;',
             'entry = <0x80080000>;',
             'default = "conf";',
@@ -376,7 +376,7 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c 'a smart U-Boot comment'"
         # different architectures.
         its_field_check = [
             'description = "A model description";',
-            'type = "uboot";',
+            'type = "standalone";',
             'load = <0x80080000>;',
             'entry = <0x80080000>;',
             'default = "conf";',