[PATCH u-boot-marvell 2/7] tools: kwbimage: Fix calculating size of kwbimage v0 header

Stefan Roese sr at denx.de
Wed Feb 16 10:47:51 CET 2022


On 2/15/22 19:59, Pali Rohár wrote:
> Extended and binary headers are optional and are part of the image header.
> 
> Fixes kwboot to determinate correct length of Dove images.
> 
> Signed-off-by: Pali Rohár <pali at kernel.org>

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

Thanks,
Stefan

> ---
>   tools/kwbimage.h | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/kwbimage.h b/tools/kwbimage.h
> index 706bebddf4fa..502b6d503305 100644
> --- a/tools/kwbimage.h
> +++ b/tools/kwbimage.h
> @@ -240,8 +240,20 @@ static inline size_t kwbheader_size(const void *header)
>   	if (kwbimage_version(header) == 0) {
>   		const struct main_hdr_v0 *hdr = header;
>   
> +		/*
> +		 * First extension header starts immediately after the main
> +		 * header without any padding. Between extension headers is
> +		 * 0x20 byte padding. There is no padding after the last
> +		 * extension header. First binary code header starts immediately
> +		 * after the last extension header (or immediately after the
> +		 * main header if there is no extension header) without any
> +		 * padding. There is no padding between binary code headers and
> +		 * neither after the last binary code header.
> +		 */
>   		return sizeof(*hdr) +
> -		       hdr->ext ? sizeof(struct ext_hdr_v0) : 0;
> +		       hdr->ext * sizeof(struct ext_hdr_v0) +
> +		       ((hdr->ext > 1) ? ((hdr->ext - 1) * 0x20) : 0) +
> +		       hdr->bin * sizeof(struct bin_hdr_v0);
>   	} else {
>   		const struct main_hdr_v1 *hdr = header;
>   

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