[U-Boot] [PATCH] tools/imximage: get HAB information from header
Bryan O'Donoghue
bryan.odonoghue at linaro.org
Mon Jul 9 11:44:06 UTC 2018
On 06/07/18 15: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));
> }
>
Good call.
Tested-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
More information about the U-Boot
mailing list