mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	barebox@lists.infradead.org
Subject: Re: [PATCH v2 09/16] images: always build sha256sum into pbl
Date: Mon, 05 Aug 2019 14:20:57 +0200	[thread overview]
Message-ID: <1565007657.2323.11.camel@pengutronix.de> (raw)
In-Reply-To: <f75dea541dc77d5f2416f85fd8619ee0cb67a084.1564997015.git-series.r.czerwinski@pengutronix.de>

Am Montag, den 05.08.2019, 11:23 +0200 schrieb Rouven Czerwinski:
> Create a sha256sum of the compressed barebox image and always add it to
> the PBL. We also add a custom linker section for ARM, to retrieve the
> sha256sum for piggydata verification.

Hm, this add an unconditional build dependency to the sha256sum host-
tool, which might be a bit unexpected. I'm not sot sure if we care
about this, so I'll defer the decision to Sascha. ;)

Regards,
Lucas

> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> ---
>  arch/arm/lib/pbl.lds.S |  7 +++++++
>  images/Makefile        | 22 +++++++++++++++++++---
>  images/sha_sum.S       |  7 +++++++
>  3 files changed, 33 insertions(+), 3 deletions(-)
>  create mode 100644 images/sha_sum.S
> 
> diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
> index d2f5ab2..01ed384 100644
> --- a/arch/arm/lib/pbl.lds.S
> +++ b/arch/arm/lib/pbl.lds.S
> @@ -68,6 +68,13 @@ SECTIONS
> >  	. = ALIGN(4);
> >  	.data : { *(.data*) }
>  
> > +	. = ALIGN(4);
> > +	__shasum_start = .;
> > +	.shasum : {
> > +		KEEP(*(.shasum))
> > +	}
> > +	__shasum_end = .;
> +
> >  	.rel_dyn_start : { *(.__rel_dyn_start) }
>  #ifdef CONFIG_CPU_32
> >  	.rel.dyn : { *(.rel*) }
> diff --git a/images/Makefile b/images/Makefile
> index 293e644..907986e 100644
> --- a/images/Makefile
> +++ b/images/Makefile
> @@ -57,11 +57,12 @@ quiet_cmd_elf__ ?= LD      $@
> >        cmd_elf__ ?= $(LD) $(LDFLAGS_barebox) --gc-sections		\
> > >  		-e $(2) -Map $@.map $(LDFLAGS_$(@F)) -o $@		\
> > >  		-T $(pbl-lds)						\
> > -		--start-group $(barebox-pbl-common) $(obj)/piggy.o --end-group
> > > +		--start-group $(barebox-pbl-common) $(obj)/piggy.o	\
> > +		$(obj)/sha_sum.o --end-group
>  
> >  PBL_CPPFLAGS	+= -fdata-sections -ffunction-sections
>  
> -$(obj)/%.pbl: $(pbl-lds) $(barebox-pbl-common) $(obj)/piggy.o FORCE
> +$(obj)/%.pbl: $(pbl-lds) $(barebox-pbl-common) $(obj)/piggy.o $(obj)/sha_sum.o FORCE
> >  	$(call if_changed,elf__,$(*F))
>  
>  $(obj)/%.pblb: $(obj)/%.pbl FORCE
> @@ -111,6 +112,21 @@ suffix_$(CONFIG_IMAGE_COMPRESSION_NONE) = comp_copy
>  
>  $(obj)/piggy.o: $(obj)/barebox.z FORCE
>  
> +$(obj)/sha_sum.o: $(obj)/barebox.sha.bin FORCE
> +
> +quiet_cmd_sha256bin ?= SHA-BIN $@
> +      cmd_sha256bin ?= printf "$(shell awk '{printf $$1}' < $(obj)/barebox.sum | sed -e 's/../\\x&/g' )" > $@
> +
> +quiet_cmd_sha256sum ?= SHA     $@
> +      cmd_sha256sum ?= sha256sum $(obj)/barebox.z > $@
> +
> +$(obj)/barebox.sha.bin: $(obj)/barebox.sum FORCE
> > +	$(call if_changed,sha256bin)
> +
> +$(obj)/barebox.sum: $(obj)/barebox.z FORCE
> > +	$(call if_changed,sha256sum)
> +
> +
>  # barebox.z - compressed barebox binary
>  # ----------------------------------------------------------------
>  $(obj)/barebox.z: $(obj)/../barebox.bin FORCE
> @@ -152,7 +168,7 @@ ifneq ($(pblx-y)$(pblx-),)
>    $(error pblx- has been removed. Please use pblb- instead.)
>  endif
>  
> -targets += $(image-y) pbl.lds barebox.x barebox.z piggy.o
> +targets += $(image-y) pbl.lds barebox.x barebox.z piggy.o sha_sum.o barebox.sha.bin barebox.sum
>  targets += $(patsubst %,%.pblb,$(pblb-y))
>  targets += $(patsubst %,%.pbl,$(pblb-y))
>  targets += $(patsubst %,%.s,$(pblb-y))
> diff --git a/images/sha_sum.S b/images/sha_sum.S
> new file mode 100644
> index 0000000..5928c20
> --- /dev/null
> +++ b/images/sha_sum.S
> @@ -0,0 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +        .section .shasum,"a"
> +        .globl  sha_sum
> +sha_sum:
> +        .incbin "images/barebox.sha.bin"
> +        .globl  sha_sum_end
> +sha_sum_end:

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-08-05 12:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05  9:23 [PATCH v2 00/16] HAB for i.MX8MQ Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 01/16] i.MX: HABv4: ignore return for i.MX28/6 initcalls Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 02/16] i.MX: HABv4: implement interface for i.MX8MQ Rouven Czerwinski
2019-08-05 12:12   ` Lucas Stach
2019-08-05  9:23 ` [PATCH v2 03/16] mach-imx: enable HAB on i.MX8MQ Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 04/16] arm: lib: add CSF section between PBL and piggy Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 05/16] esdhc-pbl: extract header parsing from image start Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 06/16] esdhc-pbl: add piggy load function Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 07/16] sections: fix macro for barebox_pbl_size Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 08/16] scripts: imx: support signing for i.MX8MQ Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 09/16] images: always build sha256sum into pbl Rouven Czerwinski
2019-08-05 12:20   ` Lucas Stach [this message]
2019-08-05 12:52     ` Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 10/16] pbl: add sha256 and piggy verification to PBL Rouven Czerwinski
2019-08-05 11:00   ` Lucas Stach
2019-08-05 12:57     ` Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 11/16] stdio: puts and putchar static inline wrappers Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 12/16] pbl: support panic with log output Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 13/16] arm: uncompress: verify sha256 if enabled Rouven Czerwinski
2019-08-05 10:42   ` Lucas Stach
2019-08-05  9:23 ` [PATCH v2 14/16] mach-imx: add gencsf header for i.MX8MQ Rouven Czerwinski
2019-08-05  9:23 ` [PATCH v2 15/16] mach-imx: hab: select piggy verification for i.MX8 Rouven Czerwinski
2019-08-05 10:39   ` Lucas Stach
2019-08-05  9:23 ` [PATCH v2 16/16] boards: nxp-mx8-evk: rework to different boot flow Rouven Czerwinski
2019-08-05 10:37   ` Lucas Stach
2019-08-05 12:59     ` Rouven Czerwinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1565007657.2323.11.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=r.czerwinski@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox