diff options
author | Pierre Bourdon <delroth@gmail.com> | 2021-12-25 20:50:19 +0100 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2022-01-05 16:31:58 +0100 |
commit | 9203c73895ab410f7a57f56ec26201253a1f008b (patch) | |
tree | 126947ea7614970b1e7d8bb889a626a00222651b | |
parent | b3f84a939f514a266a5a3aa97cbe2787c2d73d89 (diff) | |
download | u-boot-9203c73895ab410f7a57f56ec26201253a1f008b.zip u-boot-9203c73895ab410f7a57f56ec26201253a1f008b.tar.gz u-boot-9203c73895ab410f7a57f56ec26201253a1f008b.tar.bz2 |
tools: kwbimage: Fix checksum calculation for v1 images
Recent changes caused fields in the image main header to be modified
after the header checksum had already been computed. Move the checksum
computation to once again be the last operation performed on the header.
Fixes: 2b0980c24027 ("tools: kwbimage: Fill the real header size into the main header")
Signed-off-by: Pierre Bourdon <delroth@gmail.com>
Reviewed-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
-rw-r--r-- | tools/kwbimage.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/kwbimage.c b/tools/kwbimage.c index da8bfe0..224d815 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1400,9 +1400,6 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, headersz, image, secure_hdr)) return NULL; - /* Calculate and set the header checksum */ - main_hdr->checksum = image_checksum8(main_hdr, headersz); - *imagesz = headersz; /* Fill the real header size without padding into the main header */ @@ -1412,6 +1409,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, main_hdr->headersz_lsb = cpu_to_le16(headersz & 0xFFFF); main_hdr->headersz_msb = (headersz & 0xFFFF0000) >> 16; + /* Calculate and set the header checksum */ + main_hdr->checksum = image_checksum8(main_hdr, headersz); + return image; } |