Skip to contentSkip to conversation

uboot-sign: fix U-Boot binary with public key

PATCH In review Clayton Casciato 2 participants 2 messages Nov 22, 2024 – Dec 6, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uboot-sign: fix U-Boot binary with public key

Fixes [YOCTO #15649]

The U-Boot binary in the "deploy" directory is missing the public key when the removed logic branch is used.

The simple concatenation of the binary and DTB with public key works as expected on a BeagleBone Black.

Given:
MACHINE = beaglebone-yocto
UBOOT_SIGN_KEYNAME = "dev"

Post-patch (poky/build/tmp/deploy/images/beaglebone-yocto):

$ hexdump -e "16 \"%_p\" \"\\n\"" u-boot-beaglebone-yocto.dtb \
| tr -d '\n' | grep -o 'key-dev'
key-dev
$ hexdump -e "16 \"%_p\" \"\\n\"" u-boot.img \
| tr -d '\n' | grep -o 'key-dev'
key-dev

Non-Poky BeagleBone Black testing (Scarthgap):
U-Boot 2024.01 [...]
[...]
Using 'conf-ti_omap_am335x-boneblack.dtb' configuration Verifying Hash Integrity ... sha256,rsa4096:dev+ OK Trying 'kernel-1' kernel subimage
[...]

---
Sponsor: 21SoftWare LLC

 meta/classes-recipe/uboot-sign.bbclass | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
meta/classes-recipe/uboot-sign.bbclass +1 -7
index a17be745ce..7ee73b872a 100644
@@ -122,13 +122,7 @@ concat_dtb() {
 	# If we're not using a signed u-boot fit, concatenate SPL w/o DTB & U-Boot DTB
 	# with public key (otherwise U-Boot will be packaged by uboot_fitimage_assemble)
 	if [ "${SPL_SIGN_ENABLE}" != "1" ] ; then
-		if [ "x${UBOOT_SUFFIX}" = "ximg" -o "x${UBOOT_SUFFIX}" = "xrom" ] && \
-			[ -e "${UBOOT_DTB_BINARY}" ]; then
-			oe_runmake EXT_DTB="${UBOOT_DTB_SIGNED}" ${UBOOT_MAKE_TARGET}
-			if [ -n "${binary}" ]; then
-				cp ${binary} ${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX}
-			fi
-		elif [ -e "${UBOOT_NODTB_BINARY}" -a -e "${UBOOT_DTB_BINARY}" ]; then
+		if [ -e "${UBOOT_NODTB_BINARY}" -a -e "${UBOOT_DTB_BINARY}" ]; then
 			if [ -n "${binary}" ]; then
 				cat ${UBOOT_NODTB_BINARY} ${UBOOT_DTB_SIGNED} | tee ${binary} > \
 					${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX}
Signature · 1 line
2.34.1
#1 lore raw
Quoted 45 lines · Clayton Casciato via lists.openembedded.org

Fixes [YOCTO #15649]

The U-Boot binary in the "deploy" directory is missing the public key when the removed logic branch is used.

The simple concatenation of the binary and DTB with public key works as expected on a BeagleBone Black.

Given:
MACHINE = beaglebone-yocto
UBOOT_SIGN_KEYNAME = "dev"

Post-patch (poky/build/tmp/deploy/images/beaglebone-yocto):

$ hexdump -e "16 \"%_p\" \"\\n\"" u-boot-beaglebone-yocto.dtb \
| tr -d '\n' | grep -o 'key-dev'
key-dev
$ hexdump -e "16 \"%_p\" \"\\n\"" u-boot.img \
| tr -d '\n' | grep -o 'key-dev'
key-dev

Non-Poky BeagleBone Black testing (Scarthgap):
U-Boot 2024.01 [...]
[...]
Using 'conf-ti_omap_am335x-boneblack.dtb' configuration Verifying Hash Integrity ... sha256,rsa4096:dev+ OK Trying 'kernel-1' kernel subimage
[...]

---
Sponsor: 21SoftWare LLC

  meta/classes-recipe/uboot-sign.bbclass | 8 +-------
  1 file changed, 1 insertion(+), 7 deletions(-)
meta/classes-recipe/uboot-sign.bbclass +0 -1
index a17be745ce..7ee73b872a 100644
@@ -122,13 +122,7 @@ concat_dtb() {
  	# If we're not using a signed u-boot fit, concatenate SPL w/o DTB & U-Boot DTB
  	# with public key (otherwise U-Boot will be packaged by uboot_fitimage_assemble)
  	if [ "${SPL_SIGN_ENABLE}" != "1" ] ; then
-		if [ "x${UBOOT_SUFFIX}" = "ximg" -o "x${UBOOT_SUFFIX}" = "xrom" ] && \

meta/classes-recipe/uboot-sign.bbclass concat_dtb() { · line 128

Quoted 10 lines
meta/classes-recipe/uboot-sign.bbclass +1 -6
-			[ -e "${UBOOT_DTB_BINARY}" ]; then
-			oe_runmake EXT_DTB="${UBOOT_DTB_SIGNED}" ${UBOOT_MAKE_TARGET}
-			if [ -n "${binary}" ]; then
-				cp ${binary} ${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX}
-			fi
-		elif [ -e "${UBOOT_NODTB_BINARY}" -a -e "${UBOOT_DTB_BINARY}" ]; then
+		if [ -e "${UBOOT_NODTB_BINARY}" -a -e "${UBOOT_DTB_BINARY}" ]; then
  			if [ -n "${binary}" ]; then
  				cat ${UBOOT_NODTB_BINARY} ${UBOOT_DTB_SIGNED} | tee ${binary} > \
  					${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX}

I have been chasing down all week trying to figure out why our master builds all stopped booting properly. I would have responded to this patch sooner, but I also got bit by the BB_DANGLINGAPPENDS_WARNONLY that tanked our nightly builds around the same time this patch was accepted and the Thanskgiving holiday so that I wasn't even looking at the fact that our builds were tanked until Monday.

Removing the entire first if clause just to get to the second might fix the bug you were looking for, but our code was relying on that first if block to work correctly.

The issue is that UBOOT_SUFFIX is saying to create an .img file, but removing the first if clause just installs the .bin file under the suffix .img which is just wrong.

I think this patch needs to be reverted and a second attempt at fixing the bug needs to be made.

Quoted 10 lines

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

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