Skip to content

Commit

Permalink
tools: kwbimage: Fill the real header size into the main header
Browse files Browse the repository at this point in the history
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@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
  • Loading branch information
pali authored and Stefan Roese committed Nov 10, 2021
1 parent 5cad2e6 commit 2b0980c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/kwbimage.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2b0980c

Please sign in to comment.