All of lore.kernel.org
 help / color / mirror / Atom feed
* [OE-core][PATCH] uboot-sign: fix the concatenation when multiple U-BOOT configurations are specified
@ 2021-10-27 14:04 Thomas Perrot
  2021-10-27 18:02 ` Richard Purdie
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Perrot @ 2021-10-27 14:04 UTC (permalink / raw)
  To: openembedded-core; +Cc: Thomas Perrot

Some BSPs, especially those of meta-freescale and meta-ti allow to build U-Boot
binaries using different configuration for a given target, for example:
- UBOOT_CONFIG ??= "tfa-secure-boot tfa"
- UBOOT_CONFIG ??= "nand sdcard spi nor"

When this is the case the public key wasn't concatenated to all U-Boot binaries
built.

Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
---
 meta/classes/uboot-sign.bbclass | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/meta/classes/uboot-sign.bbclass b/meta/classes/uboot-sign.bbclass
index bae8cada0ac3..8d136e940589 100644
--- a/meta/classes/uboot-sign.bbclass
+++ b/meta/classes/uboot-sign.bbclass
@@ -131,6 +131,20 @@ concat_dtb_helper() {
 		elif [ -e "${DEPLOYDIR}/${UBOOT_NODTB_IMAGE}" -a -e "$deployed_uboot_dtb_binary" ]; then
 			cd ${DEPLOYDIR}
 			cat ${UBOOT_NODTB_IMAGE} $deployed_uboot_dtb_binary | tee ${B}/${CONFIG_B_PATH}/${UBOOT_BINARY} > ${UBOOT_IMAGE}
+
+			if [ -n "${UBOOT_CONFIG}" ]
+			then
+				for config in ${UBOOT_MACHINE}; do
+					i=$(expr $i + 1);
+					for type in ${UBOOT_CONFIG}; do
+						j=$(expr $j + 1);
+						if [ $j -eq $i ]
+						then
+							cp ${UBOOT_IMAGE} ${B}/${CONFIG_B_PATH}/u-boot-$type.${UBOOT_SUFFIX}
+						fi
+					done
+				done
+			fi
 		else
 			bbwarn "Failure while adding public key to u-boot binary. Verified boot won't be available."
 		fi
@@ -205,7 +219,7 @@ install_helper() {
 	fi
 }
 
-# Install SPL dtb and u-boot nodtb to datadir, 
+# Install SPL dtb and u-boot nodtb to datadir,
 install_spl_helper() {
 	if [ -f "${SPL_DIR}/${SPL_DTB_BINARY}" ]; then
 		install -Dm 0644 ${SPL_DIR}/${SPL_DTB_BINARY} ${D}${datadir}/${SPL_DTB_IMAGE}
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [OE-core][PATCH] uboot-sign: fix the concatenation when multiple U-BOOT configurations are specified
  2021-10-27 14:04 [OE-core][PATCH] uboot-sign: fix the concatenation when multiple U-BOOT configurations are specified Thomas Perrot
@ 2021-10-27 18:02 ` Richard Purdie
  2021-10-29 22:17   ` Thomas Perrot
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Purdie @ 2021-10-27 18:02 UTC (permalink / raw)
  To: Thomas Perrot, openembedded-core

On Wed, 2021-10-27 at 16:04 +0200, Thomas Perrot wrote:
> Some BSPs, especially those of meta-freescale and meta-ti allow to build U-Boot
> binaries using different configuration for a given target, for example:
> - UBOOT_CONFIG ??= "tfa-secure-boot tfa"
> - UBOOT_CONFIG ??= "nand sdcard spi nor"
> 
> When this is the case the public key wasn't concatenated to all U-Boot binaries
> built.
> 
> Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
> ---
>  meta/classes/uboot-sign.bbclass | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/uboot-sign.bbclass b/meta/classes/uboot-sign.bbclass
> index bae8cada0ac3..8d136e940589 100644
> --- a/meta/classes/uboot-sign.bbclass
> +++ b/meta/classes/uboot-sign.bbclass
> @@ -131,6 +131,20 @@ concat_dtb_helper() {
>  		elif [ -e "${DEPLOYDIR}/${UBOOT_NODTB_IMAGE}" -a -e "$deployed_uboot_dtb_binary" ]; then
>  			cd ${DEPLOYDIR}
>  			cat ${UBOOT_NODTB_IMAGE} $deployed_uboot_dtb_binary | tee ${B}/${CONFIG_B_PATH}/${UBOOT_BINARY} > ${UBOOT_IMAGE}
> +
> +			if [ -n "${UBOOT_CONFIG}" ]
> +			then
> +				for config in ${UBOOT_MACHINE}; do
> +					i=$(expr $i + 1);
> +					for type in ${UBOOT_CONFIG}; do
> +						j=$(expr $j + 1);
> +						if [ $j -eq $i ]
> +						then
> +							cp ${UBOOT_IMAGE} ${B}/${CONFIG_B_PATH}/u-boot-$type.${UBOOT_SUFFIX}
> +						fi
> +					done
> +				done
> +			fi
>  		else
>  			bbwarn "Failure while adding public key to u-boot binary. Verified boot won't be available."
>  		fi
> @@ -205,7 +219,7 @@ install_helper() {
>  	fi
>  }
>  
> -# Install SPL dtb and u-boot nodtb to datadir, 
> +# Install SPL dtb and u-boot nodtb to datadir,
>  install_spl_helper() {
>  	if [ -f "${SPL_DIR}/${SPL_DTB_BINARY}" ]; then
>  		install -Dm 0644 ${SPL_DIR}/${SPL_DTB_BINARY} ${D}${datadir}/${SPL_DTB_IMAGE}


We seem to be just piling more and more conditional code into these classes for
different weird corner cases.

Are there some tests we should be adding to ensure people understand why this
code is here and if/as/when something else changes it and regresses it?

Cheers,

Richard




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [OE-core][PATCH] uboot-sign: fix the concatenation when multiple U-BOOT configurations are specified
  2021-10-27 18:02 ` Richard Purdie
@ 2021-10-29 22:17   ` Thomas Perrot
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Perrot @ 2021-10-29 22:17 UTC (permalink / raw)
  To: Richard Purdie, openembedded-core

[-- Attachment #1: Type: text/plain, Size: 4221 bytes --]

Hello Richard,

On Wed, 2021-10-27 at 19:02 +0100, Richard Purdie wrote:
> On Wed, 2021-10-27 at 16:04 +0200, Thomas Perrot wrote:
> > Some BSPs, especially those of meta-freescale and meta-ti allow to
> > build U-Boot
> > binaries using different configuration for a given target, for
> > example:
> > - UBOOT_CONFIG ??= "tfa-secure-boot tfa"
> > - UBOOT_CONFIG ??= "nand sdcard spi nor"
> > 
> > When this is the case the public key wasn't concatenated to all U-
> > Boot binaries
> > built.
> > 
> > Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
> > ---
> >  meta/classes/uboot-sign.bbclass | 16 +++++++++++++++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> > 
> > diff --git a/meta/classes/uboot-sign.bbclass b/meta/classes/uboot-
> > sign.bbclass
> > index bae8cada0ac3..8d136e940589 100644
> > --- a/meta/classes/uboot-sign.bbclass
> > +++ b/meta/classes/uboot-sign.bbclass
> > @@ -131,6 +131,20 @@ concat_dtb_helper() {
> >                 elif [ -e "${DEPLOYDIR}/${UBOOT_NODTB_IMAGE}" -a -e
> > "$deployed_uboot_dtb_binary" ]; then
> >                         cd ${DEPLOYDIR}
> >                         cat ${UBOOT_NODTB_IMAGE}
> > $deployed_uboot_dtb_binary | tee
> > ${B}/${CONFIG_B_PATH}/${UBOOT_BINARY} > ${UBOOT_IMAGE}
> > +
> > +                       if [ -n "${UBOOT_CONFIG}" ]
> > +                       then
> > +                               for config in ${UBOOT_MACHINE}; do
> > +                                       i=$(expr $i + 1);
> > +                                       for type in
> > ${UBOOT_CONFIG}; do
> > +                                               j=$(expr $j + 1);
> > +                                               if [ $j -eq $i ]
> > +                                               then
> > +                                                       cp
> > ${UBOOT_IMAGE} ${B}/${CONFIG_B_PATH}/u-boot-$type.${UBOOT_SUFFIX}
> > +                                               fi
> > +                                       done
> > +                               done
> > +                       fi
> >                 else
> >                         bbwarn "Failure while adding public key to
> > u-boot binary. Verified boot won't be available."
> >                 fi
> > @@ -205,7 +219,7 @@ install_helper() {
> >         fi
> >  }
> >  
> > -# Install SPL dtb and u-boot nodtb to datadir, 
> > +# Install SPL dtb and u-boot nodtb to datadir,
> >  install_spl_helper() {
> >         if [ -f "${SPL_DIR}/${SPL_DTB_BINARY}" ]; then
> >                 install -Dm 0644 ${SPL_DIR}/${SPL_DTB_BINARY}
> > ${D}${datadir}/${SPL_DTB_IMAGE}
> 
> 
> We seem to be just piling more and more conditional code into these
> classes for
> different weird corner cases.
> 
> Are there some tests we should be adding to ensure people understand
> why this
> code is here and if/as/when something else changes it and regresses
> it?
> 

I should be able to add a test in "oeqa/selftest/fitimage". I will
resubmit when it's done.

Best regards,
Thomas

> Cheers,
> 
> Richard
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#157562): 
> https://lists.openembedded.org/g/openembedded-core/message/157562
> Mute This Topic: https://lists.openembedded.org/mt/86628322/5443093
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/openembedded-core/unsub [thomas.perrot@bootlin.com
> ]
> -=-=-=-=-=-=-=-=-=-=-=-
> 

-- 
Thomas Perrot, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-29 22:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 14:04 [OE-core][PATCH] uboot-sign: fix the concatenation when multiple U-BOOT configurations are specified Thomas Perrot
2021-10-27 18:02 ` Richard Purdie
2021-10-29 22:17   ` Thomas Perrot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.