summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamin Lin <jamin_lin@aspeedtech.com>2025-06-17 16:10:50 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-06-19 21:54:43 +0100
commitd8cd58cc7ad5d8b7c92ef6eb6f0b973f0276422d (patch)
tree5cf913eca69ac2bff80c8e6791bce29c5481cc55
parenteb9b83d6c9efec3b6aa70861fedb6ad531963945 (diff)
downloadpoky-d8cd58cc7ad5d8b7c92ef6eb6f0b973f0276422d.tar.gz
uboot-sign: Support signing U-Boot FIT image without SPL
Previously, the signing flow in "uboot-sign.bbclass" assumed that SPL was always present and that the FIT signing process must inject the public key into the SPL DTB. This made it inflexible for use cases where only the U-Boot proper FIT image is built and signed, with no SPL binary at all. This change introduces the following adjustments: - The `SPL_DTB_BINARY` variable can be explicitly set to an empty string to indicate that no SPL is present. - The signing logic checks `SPL_DTB_BINARY` and skips injecting the key or verifying the SPL DTB if it is empty. - The FIT image generation and deployment are always performed if `UBOOT_FITIMAGE_ENABLE` is enabled, regardless of the SPL settings. - The deploy helper now uses a single check on `SPL_DTB_BINARY` to decide whether to deploy the signed SPL DTB. Now the sign step checks if SPL_DTB_BINARY is empty: If present, it signs the FIT image and injects the public key into the SPL DTB, then verifies both. If empty, it only signs the FIT image and generates the ITS with the signature node, but does not attempt to verify or add the key to a non-existent SPL DTB. Key Behavior Explained If SPL_DTB_BINARY is empty, we assume there is no SPL. If UBOOT_FITIMAGE_ENABLE=1, we always create the FIT image and ITS. If SPL_SIGN_ENABLE=1, we always sign the FIT image, but only inject the key into the SPL DTB if it exists. Example usage: UBOOT_FITIMAGE_ENABLE = "1" SPL_SIGN_ENABLE = "1" SPL_DTB_BINARY = "" This means: - Generate and sign the FIT image. - Do not attempt to sign or deploy an SPL DTB. This aligns the implementation with real scenarios where some boards do not require an SPL. (From OE-Core rev: 7ad6acd8841752a5b75b8e2666bca5b609347cc1) Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-recipe/uboot-sign.bbclass50
1 files changed, 29 insertions, 21 deletions
diff --git a/meta/classes-recipe/uboot-sign.bbclass b/meta/classes-recipe/uboot-sign.bbclass
index 73e9ce3f11..01c53c7448 100644
--- a/meta/classes-recipe/uboot-sign.bbclass
+++ b/meta/classes-recipe/uboot-sign.bbclass
@@ -50,6 +50,8 @@ UBOOT_FITIMAGE_BINARY ?= "u-boot-fitImage"
50UBOOT_FITIMAGE_SYMLINK ?= "u-boot-fitImage-${MACHINE}" 50UBOOT_FITIMAGE_SYMLINK ?= "u-boot-fitImage-${MACHINE}"
51SPL_DIR ?= "spl" 51SPL_DIR ?= "spl"
52SPL_DTB_IMAGE ?= "u-boot-spl-${MACHINE}-${PV}-${PR}.dtb" 52SPL_DTB_IMAGE ?= "u-boot-spl-${MACHINE}-${PV}-${PR}.dtb"
53# When SPL is not used, set SPL_DTB_BINARY ?= "" to explicitly indicate
54# that no SPL DTB should be created or signed.
53SPL_DTB_BINARY ?= "u-boot-spl.dtb" 55SPL_DTB_BINARY ?= "u-boot-spl.dtb"
54SPL_DTB_SIGNED ?= "${SPL_DTB_BINARY}-signed" 56SPL_DTB_SIGNED ?= "${SPL_DTB_BINARY}-signed"
55SPL_DTB_SYMLINK ?= "u-boot-spl-${MACHINE}.dtb" 57SPL_DTB_SYMLINK ?= "u-boot-spl-${MACHINE}.dtb"
@@ -466,25 +468,31 @@ EOF
466 ${UBOOT_FITIMAGE_BINARY} 468 ${UBOOT_FITIMAGE_BINARY}
467 469
468 if [ "${SPL_SIGN_ENABLE}" = "1" ] ; then 470 if [ "${SPL_SIGN_ENABLE}" = "1" ] ; then
469 # 471 if [ -n "${SPL_DTB_BINARY}" ] ; then
470 # Sign the U-boot FIT image and add public key to SPL dtb 472 #
471 # 473 # Sign the U-boot FIT image and add public key to SPL dtb
472 ${UBOOT_MKIMAGE_SIGN} \ 474 #
473 ${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \ 475 ${UBOOT_MKIMAGE_SIGN} \
474 -F -k "${SPL_SIGN_KEYDIR}" \ 476 ${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \
475 -K "${SPL_DIR}/${SPL_DTB_BINARY}" \ 477 -F -k "${SPL_SIGN_KEYDIR}" \
476 -r ${UBOOT_FITIMAGE_BINARY} \ 478 -K "${SPL_DIR}/${SPL_DTB_BINARY}" \
477 ${SPL_MKIMAGE_SIGN_ARGS} 479 -r ${UBOOT_FITIMAGE_BINARY} \
478 # 480 ${SPL_MKIMAGE_SIGN_ARGS}
479 # Verify the U-boot FIT image and SPL dtb
480 #
481 ${UBOOT_FIT_CHECK_SIGN} \
482 -k "${SPL_DIR}/${SPL_DTB_BINARY}" \
483 -f ${UBOOT_FITIMAGE_BINARY}
484 fi
485 481
486 if [ -e "${SPL_DIR}/${SPL_DTB_BINARY}" ]; then 482 # Verify the U-boot FIT image and SPL dtb
487 cp ${SPL_DIR}/${SPL_DTB_BINARY} ${SPL_DIR}/${SPL_DTB_SIGNED} 483 ${UBOOT_FIT_CHECK_SIGN} \
484 -k "${SPL_DIR}/${SPL_DTB_BINARY}" \
485 -f ${UBOOT_FITIMAGE_BINARY}
486
487 cp ${SPL_DIR}/${SPL_DTB_BINARY} ${SPL_DIR}/${SPL_DTB_SIGNED}
488 else
489 # Sign the U-boot FIT image
490 ${UBOOT_MKIMAGE_SIGN} \
491 ${@'-D "${SPL_MKIMAGE_DTCOPTS}"' if len('${SPL_MKIMAGE_DTCOPTS}') else ''} \
492 -F -k "${SPL_SIGN_KEYDIR}" \
493 -r ${UBOOT_FITIMAGE_BINARY} \
494 ${SPL_MKIMAGE_SIGN_ARGS}
495 fi
488 fi 496 fi
489} 497}
490 498
@@ -496,7 +504,7 @@ uboot_assemble_fitimage_helper() {
496 concat_dtb "$type" "$binary" 504 concat_dtb "$type" "$binary"
497 fi 505 fi
498 506
499 if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" -a -n "${SPL_DTB_BINARY}" ]; then 507 if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" ]; then
500 uboot_fitimage_assemble 508 uboot_fitimage_assemble
501 fi 509 fi
502 510
@@ -543,7 +551,7 @@ deploy_helper() {
543 deploy_dtb $type 551 deploy_dtb $type
544 fi 552 fi
545 553
546 if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" -a -n "${SPL_DTB_BINARY}" ]; then 554 if [ "${UBOOT_FITIMAGE_ENABLE}" = "1" ]; then
547 if [ -n "${type}" ]; then 555 if [ -n "${type}" ]; then
548 uboot_its_image="u-boot-its-${type}-${PV}-${PR}" 556 uboot_its_image="u-boot-its-${type}-${PV}-${PR}"
549 uboot_fitimage_image="u-boot-fitImage-${type}-${PV}-${PR}" 557 uboot_fitimage_image="u-boot-fitImage-${type}-${PV}-${PR}"
@@ -561,7 +569,7 @@ deploy_helper() {
561 fi 569 fi
562 fi 570 fi
563 571
564 if [ "${SPL_SIGN_ENABLE}" = "1" -a -n "${SPL_DTB_SIGNED}" ] ; then 572 if [ "${SPL_SIGN_ENABLE}" = "1" -a -n "${SPL_DTB_BINARY}" ] ; then
565 deploy_spl_dtb $type 573 deploy_spl_dtb $type
566 fi 574 fi
567} 575}