[PATCH u-boot-marvell 09/11] tools: kwbimage: Fill the real header size into the main header

Stefan Roese sr at denx.de
Wed Nov 10 09:29:19 CET 2021


On 08.11.21 18:12, Marek Behún wrote:
> From: Pali Rohár <pali at kernel.org>
> 
> Fill the real header size without padding into the main header
> 
> This allows to reduce final image when converting image to another format
> which does not need additional padding.
> 
> Signed-off-by: Pali Rohár <pali at kernel.org>
> Signed-off-by: Marek Behún <marek.behun at nic.cz>

Reviewed-by: Stefan Roese <sr at denx.de>

Thanks,
Stefan

> ---
>   tools/kwbimage.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index 8dcfebcb57..114b313b4d 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -1220,6 +1220,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
>   {
>   	struct image_cfg_element *e;
>   	struct main_hdr_v1 *main_hdr;
> +	struct opt_hdr_v1 *ohdr;
>   	struct register_set_hdr_v1 *register_set_hdr;
>   	struct secure_hdr_v1 *secure_hdr = NULL;
>   	size_t headersz;
> @@ -1370,6 +1371,14 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
>   	main_hdr->checksum = image_checksum8(main_hdr, headersz);
>   
>   	*imagesz = headersz;
> +
> +	/* Fill the real header size without padding into the main header */
> +	headersz = sizeof(*main_hdr);
> +	for_each_opt_hdr_v1 (ohdr, main_hdr)
> +		headersz += opt_hdr_v1_size(ohdr);
> +	main_hdr->headersz_lsb = cpu_to_le16(headersz & 0xFFFF);
> +	main_hdr->headersz_msb = (headersz & 0xFFFF0000) >> 16;
> +
>   	return image;
>   }
>   
> 

Viele Grüße,
Stefan Roese

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


More information about the U-Boot mailing list