<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15649</bug_id>
          
          <creation_ts>2024-11-15 22:21:38 +0000</creation_ts>
          <short_desc>uboot-sign does not produce U-Boot binary with public key</short_desc>
          <delta_ts>2026-01-10 14:57:03 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>configuration</component>
          <version>unspecified</version>
          <rep_platform>BeagleBone</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>IN PROGRESS REVIEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>NIR 01/10</status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Future</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Clayton Casciato">ccasciato</reporter>
          <assigned_to name="Unassigned">unassigned</assigned_to>
          <cc>denis</cc>
    
    <cc>kexin.hao</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>100191</commentid>
    <comment_count>0</comment_count>
    <who name="Clayton Casciato">ccasciato</who>
    <bug_when>2024-11-15 22:21:38 +0000</bug_when>
    <thetext>Reproducible in the master branch (and Scarthgap)

poky/build/conf$ diff local.conf{.sample,}
33c33
&lt; #MACHINE ?= &quot;beaglebone-yocto&quot;
---
&gt; MACHINE ?= &quot;beaglebone-yocto&quot;
39c39
&lt; MACHINE ??= &quot;qemux86-64&quot;
---
&gt; #MACHINE ??= &quot;qemux86-64&quot;
289a290,300
&gt; 
&gt; UBOOT_SIGN_ENABLE = &quot;1&quot;
&gt; UBOOT_MKIMAGE_DTCOPTS = &quot;-I dts -O dtb -p 2000&quot;
&gt; 
&gt; FIT_GENERATE_KEYS = &quot;1&quot;
&gt; UBOOT_SIGN_KEYDIR = &quot;${TOPDIR}&quot;
&gt; UBOOT_SIGN_KEYNAME = &quot;dev&quot;
&gt; 
&gt; KERNEL_IMAGETYPES += &quot; fitImage &quot;
&gt; 
&gt; KERNEL_CLASSES += &quot;kernel-fitimage&quot;

As expected, the public key is in a DTB:

poky/build/tmp/deploy/images/beaglebone-yocto$ hexdump -e &quot;16 \&quot;%_p\&quot; \&quot;\\n\&quot;&quot; u-boot-beaglebone-yocto.dtb | tr -d &apos;\n&apos; | grep -o &apos;key-dev&apos;
key-dev

Unexpectedly, the public key is not in the U-Boot binary:

poky/build/tmp/deploy/images/beaglebone-yocto$ hexdump -e &quot;16 \&quot;%_p\&quot; \&quot;\\n\&quot;&quot; u-boot.img | tr -d &apos;\n&apos; | grep -o &apos;key-dev&apos;

I have a local workaround by bypassing the first logic branch starting with:
if [ &quot;x${UBOOT_SUFFIX}&quot; = &quot;ximg&quot; -o &quot;x${UBOOT_SUFFIX}&quot; = &quot;xrom&quot; ]

In other words, the simple concatenation binary + signed DTB concatenation in this logic branch works as expected:
elif [ -e &quot;${UBOOT_NODTB_BINARY}&quot; -a -e &quot;${UBOOT_DTB_BINARY}&quot; ]; then

Post-patch results:

poky/build/tmp/deploy/images/beaglebone-yocto$ hexdump -e &quot;16 \&quot;%_p\&quot; \&quot;\\n\&quot;&quot; u-boot-beaglebone-yocto.dtb | tr -d &apos;\n&apos; | grep -o &apos;key-dev&apos;
key-dev

poky/build/tmp/deploy/images/beaglebone-yocto$ hexdump -e &quot;16 \&quot;%_p\&quot; \&quot;\\n\&quot;&quot; u-boot.img | tr -d &apos;\n&apos; | grep -o &apos;key-dev&apos;
key-dev</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100244</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-11-21 16:44:30 +0000</bug_when>
    <thetext>Clayton, Can you send a patch to openembedded-core@lists.openembedded.org ?

See: 
   https://docs.yoctoproject.org/dev/contributor-guide/submit-changes.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100252</commentid>
    <comment_count>2</comment_count>
    <who name="Clayton Casciato">ccasciato</who>
    <bug_when>2024-11-22 15:07:48 +0000</bug_when>
    <thetext>Hi, Randy!

I&apos;ve submitted a patch and CC&apos;d a few folks.

https://lists.openembedded.org/g/openembedded-core/message/207623</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100274</commentid>
    <comment_count>3</comment_count>
    <who name="Clayton Casciato">ccasciato</who>
    <bug_when>2024-11-26 15:24:26 +0000</bug_when>
    <thetext>Patch has been accepted to master:
https://git.openembedded.org/openembedded-core/commit/meta/classes-recipe/uboot-sign.bbclass?id=0d14e99aa18ee38293df63d585fafc270a4538be</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100381</commentid>
    <comment_count>4</comment_count>
    <who name="Denys Dmytriyenko">denis</who>
    <bug_when>2024-12-06 22:28:14 +0000</bug_when>
    <thetext>This may fix beaglebone-yocto case, but the change now breaks most of TI platforms in meta-ti that use uboot-sign, rendering them unbootable. Still investigating the actual root-cause...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100390</commentid>
    <comment_count>5</comment_count>
    <who name="Clayton Casciato">ccasciato</who>
    <bug_when>2024-12-09 13:04:57 +0000</bug_when>
    <thetext>Revert is in master-next:
https://git.openembedded.org/openembedded-core/commit/?h=master-next&amp;id=5e82d33451b5662df1e7fe2518a50644d18aa70d</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100432</commentid>
    <comment_count>6</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-12-12 16:14:20 +0000</bug_when>
    <thetext>Clayton, 

Will you be able to work with people to revise your patch to avoid the problmes identified?

Thanks,
-- Randy / YP Bug review</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100701</commentid>
    <comment_count>7</comment_count>
    <who name="Clayton Casciato">ccasciato</who>
    <bug_when>2025-01-20 18:47:09 +0000</bug_when>
    <thetext>There have been some significant updates such as the U-Boot upgrade to 2025.01
https://git.openembedded.org/openembedded-core/commit/meta/recipes-bsp/u-boot/u-boot_2025.01.bb?id=e16a24f04b56ca3fec6509a3286e2e3bb5c21c1e

This includes a potentially-relevant change: &quot;Makefile: pass external DTB provided by make variable EXT_DTB to binman&quot;
https://github.com/u-boot/u-boot/commit/f27e83062956c3b09d2ee3ea3b3c815f9d57e42d

Here is U-Boot&apos;s &quot;Verified Boot on the Beaglebone Black&quot;: https://github.com/u-boot/u-boot/blob/v2025.01/doc/usage/fit/beaglebone_vboot.rst

I&apos;m still seeing the same results:

poky$ git log -1 --oneline
15d005ccbf (HEAD -&gt; master, origin/master, origin/HEAD) test-manual/reproducible-builds: fix reproducible links

poky/build/tmp/deploy/images/beaglebone-yocto$ hexdump -e &quot;16 \&quot;%_p\&quot; \&quot;\\n\&quot;&quot; u-boot-beaglebone-yocto.dtb | tr -d &apos;\n&apos; | grep -o &apos;key-dev&apos;

poky/build/tmp/deploy/images/beaglebone-yocto$ hexdump -e &quot;16 \&quot;%_p\&quot; \&quot;\\n\&quot;&quot; u-boot.img | tr -d &apos;\n&apos; | grep -o &apos;key-dev&apos;

--

Debugging:

poky$ git diff
diff --git a/meta/classes-recipe/uboot-sign.bbclass b/meta/classes-recipe/uboot-sign.bbclass
index a17be745ce..7feefe52c3 100644
--- a/meta/classes-recipe/uboot-sign.bbclass
+++ b/meta/classes-recipe/uboot-sign.bbclass
@@ -101,6 +101,7 @@ python() {
 }
 
 concat_dtb() {
+       set -x
        type=&quot;$1&quot;
        binary=&quot;$2&quot;
 
@@ -139,6 +140,7 @@ concat_dtb() {
                        bbwarn &quot;Failure while adding public key to u-boot binary. Verified boot won&apos;t be available.&quot;
                fi
        fi
+       set +x
 }
 
 deploy_dtb() {

--

Select snippets from work/beaglebone_yocto-poky-linux-gnueabi/u-boot/2025.01/temp/log.do_uboot_assemble_fitimage:

DEBUG: Executing shell function do_uboot_assemble_fitimage
+ type=
+ binary=u-boot.img
+ [ -e u-boot.dtb ]
+ uboot-mkimage -D -I dts -O dtb -p 2000 -F -k [SNIP]/poky/build -K u-boot.dtb -r [SNIP]/poky/build/tmp/work/beaglebone_yocto-poky-linux-gnueabi/u-boot/2025.01/build/fitImage-linux
Failed to add verification data for &apos;signature-1&apos; signature node in &apos;conf-am335x-bone.dtb&apos; configuration node
[...]
Signature written to &apos;[SNIP]/poky/build/tmp/work/beaglebone_yocto-poky-linux-gnueabi/u-boot/2025.01/build/fitImage-linux&apos;, node &apos;/configurations/conf-am335x-bonegreen.dtb/signature-1&apos;
Public key written to &apos;u-boot.dtb&apos;, node &apos;/signature/key-dev&apos;
+ uboot-fit_check_sign -k u-boot.dtb -f [SNIP]/poky/build/tmp/work/beaglebone_yocto-poky-linux-gnueabi/u-boot/2025.01/build/fitImage-linux
Signature check OK
Verifying Hash Integrity for node &apos;conf-am335x-bone.dtb&apos;... sha256,rsa2048:dev+
[...]
Could not find subimage node type &apos;ramdisk&apos;
+ cp u-boot.dtb u-boot.dtb-signed
[...]
+ [ 0 != 1 ]
+ [ ximg = ximg -o ximg = xrom ]
+ [ -e u-boot.dtb ]
+ oe_runmake EXT_DTB=u-boot.dtb-signed all
+ oe_runmake_call EXT_DTB=u-boot.dtb-signed all
[...]
  cat u-boot.dtb-signed &gt; dts/dt.dtb
  ./tools/mkimage -f auto -A arm -T firmware -C none -O u-boot -a 0x80800000 -e 0x80800000 -p 0x0 -n &quot;U-Boot 2025.01 for am335x board&quot; -E  -b arch/arm/dts/am335x-evm.dtb -b arch/arm/dts/am335x-bone.dtb -b arch/arm/dts/am335x-sancloud-bbe.dtb -b arch/arm/dts/am335x-sancloud-bbe-lite.dtb -b arch/arm/dts/am335x-sancloud-bbe-extended-wifi.dtb -b arch/arm/dts/am335x-boneblack.dtb -b arch/arm/dts/am335x-evmsk.dtb -b arch/arm/dts/am335x-bonegreen.dtb -b arch/arm/dts/am335x-icev2.dtb -b arch/arm/dts/am335x-pocketbeagle.dtb  -d u-boot-nodtb.bin u-boot.img &gt;/dev/null  &amp;&amp; cat /dev/null
  cat u-boot-nodtb.bin dts/dt.dtb &gt; u-boot-dtb.bin
  cp u-boot-dtb.bin u-boot.bin
[...]
  cp dts/dt.dtb u-boot.dtb
  ./tools/mkimage -f auto -A arm -T firmware -C none -O u-boot -a 0x80800000 -e 0x80800000 -p 0x0 -n &quot;U-Boot 2025.01 for am335x board&quot; -E  -b arch/arm/dts/am335x-evm.dtb -b arch/arm/dts/am335x-bone.dtb -b arch/arm/dts/am335x-sancloud-bbe.dtb -b arch/arm/dts/am335x-sancloud-bbe-lite.dtb -b arch/arm/dts/am335x-sancloud-bbe-extended-wifi.dtb -b arch/arm/dts/am335x-boneblack.dtb -b arch/arm/dts/am335x-evmsk.dtb -b arch/arm/dts/am335x-bonegreen.dtb -b arch/arm/dts/am335x-icev2.dtb -b arch/arm/dts/am335x-pocketbeagle.dtb  -d u-boot-nodtb.bin u-boot-dtb.img &gt;/dev/null  &amp;&amp; cat /dev/null
  [SNIP]/poky/build/tmp/work/beaglebone_yocto-poky-linux-gnueabi/u-boot/2025.01/git/scripts/check-of.sh .config [SNIP]/poky/build/tmp/work/beaglebone_yocto-poky-linux-gnueabi/u-boot/2025.01/git/scripts/of_allowlist.txt
+ [ -n u-boot.img ]
+ cp u-boot.img u-boot-.img
+ set +x
DEBUG: Shell function do_uboot_assemble_fitimage finished

Interesting findings:
1. &quot;Failed to add verification data for &apos;signature-1&apos; signature node in &apos;conf-am335x-bone.dtb&apos; configuration node&quot;
2. The type is passed as &quot;&quot;, which causes this line: &quot;+ cp u-boot.img u-boot-.img&quot;
3. This looks promising:
cat u-boot.dtb-signed &gt; dts/dt.dtb
cat u-boot-nodtb.bin dts/dt.dtb &gt; u-boot-dtb.bin
cp dts/dt.dtb u-boot.dtb

From poky/build/tmp/work/beaglebone_yocto-poky-linux-gnueabi/u-boot/2025.01/build:
How many top-level results?
$ find . -maxdepth 1 -type f | xargs hexdump -e &quot;16 \&quot;%_p\&quot; \&quot;\\n\&quot;&quot; | tr -d &apos;\n&apos; | grep -o &apos;key-dev&apos; | uniq -c
      4 key-dev

Which ones?
$ hexdump -e &quot;16 \&quot;%_p\&quot; \&quot;\\n\&quot;&quot; {u-boot.dtb,u-boot.dtb-signed,u-boot-dtb.bin,u-boot.bin} | tr -d &apos;\n&apos; | grep -o &apos;key-dev&apos; | uniq -c
      4 key-dev</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>