[U-Boot] [PATCH] tools/imximage: get HAB information from header

Stefano Babic sbabic at denx.de
Mon Jul 23 09:34:45 UTC 2018


On 06/07/2018 16:10, Holger Dengler wrote:
> Signing parts of a u-boot imximage for image verification in High
> Assurance Boot (HAB) in a post-build process, requires some
> information from the imximage header. Currently, this information is
> only provided during the image build, which makes the transfer of this
> information to the post-build process harder than necessary.
> 
> The i.MX HAB information (start and length) can be calculated either
> by using information from the image-configuration file, or from the
> information in the flash header of the imximage.
> The advantage of using information from flash header is, that they are
> not only available during image creation, but also available if
> existing images are processed.
> 
> Example:
> $ tools/mkimage -l u-boot.imx
> Image Type:   Freescale IMX Boot Image
> Image Ver:    2 (i.MX53/6/7 compatible)
> Mode:         DCD
> Data Size:    483328 Bytes = 472.00 KiB = 0.46 MiB
> Load Address: 877ff420
> Entry Point:  87800000
> HAB Blocks:   0x877ff400 0x00000000 0x00071c00
> DCD Blocks:   0x00910000 0x0000002c 0x00000208
> 
> Signed-off-by: Holger Dengler <dengler at linutronix.de>
> ---
> 
>  tools/imximage.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/imximage.c b/tools/imximage.c
> index 5f63bf8759..d7c0b6e883 100644
> --- a/tools/imximage.c
> +++ b/tools/imximage.c
> @@ -506,8 +506,7 @@ static void print_hdr_v2(struct imx_header *imx_hdr)
>  		genimg_print_size(hdr_v2->boot_data.size);
>  		printf("Load Address: %08x\n", (uint32_t)fhdr_v2->boot_data_ptr);
>  		printf("Entry Point:  %08x\n", (uint32_t)fhdr_v2->entry);
> -		if (fhdr_v2->csf && (imximage_ivt_offset != UNDEFINED) &&
> -		    (imximage_csf_size != UNDEFINED)) {
> +		if (fhdr_v2->csf) {
>  			uint16_t dcdlen;
>  			int offs;
>  
> @@ -515,10 +514,16 @@ static void print_hdr_v2(struct imx_header *imx_hdr)
>  			offs = (char *)&hdr_v2->data.dcd_table
>  				- (char *)hdr_v2;
>  
> +			/*
> +			 * The HAB block is the first part of the image, from
> +			 * start of IVT header (fhdr_v2->self) to the start of
> +			 * the CSF block (fhdr_v2->csf). So HAB size is
> +			 * calculated as:
> +			 * HAB_size = fhdr_v2->csf - fhdr_v2->self
> +			 */
>  			printf("HAB Blocks:   0x%08x 0x%08x 0x%08x\n",
>  			       (uint32_t)fhdr_v2->self, 0,
> -			       hdr_v2->boot_data.size - imximage_ivt_offset -
> -			       imximage_csf_size);
> +			       (uint32_t)(fhdr_v2->csf - fhdr_v2->self));
>  			printf("DCD Blocks:   0x00910000 0x%08x 0x%08x\n",
>  			       offs, be16_to_cpu(dcdlen));
>  		}
> 

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================


More information about the U-Boot mailing list