tools: kwbimage: Fix checksum calculation for v1 images
PATCH 1/1 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.
--- tools/kwbimage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/kwbimage.c +3 -3
@@ -1398,9 +1398,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 */
@@ -1410,6 +1407,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; }
Signature · 1 line
2.34.0
Quoted 7 lines · On Saturday 25 December 2021 20:50:19 Pierre Bourdon wrote:
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 <[email protected]>
Thanks!
Stefan and Tom, could you please include this fixup patch into master branch for upcoming release? During development we broke kwbimage / mkimage generator and I think it is something which we should have fixed in upcoming release (if it is not too late now...).
Quoted 31 lines
--- tools/kwbimage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/kwbimage.c +3
-3@@ -1398,9 +1398,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 */ @@ -1410,6 +1407,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; }Signature · 1 line
2.34.0
Quoted 7 lines · Pierre Bourdon
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 <[email protected]>
Thanks,
Stefan
Quoted 20 lines
--- tools/kwbimage.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/kwbimage.c +0
-3@@ -1398,9 +1398,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 */
tools/kwbimage.c static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, · line 1415
Quoted 9 lines
tools/kwbimage.c +3
-0@@ -1410,6 +1407,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; }
Viele Grüße,
Stefan Roese
Signature · 3 lines
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: [email protected]
Quoted 10 lines · Stefan Roese
Quoted 7 lines · Pierre Bourdon
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 <[email protected]>Reviewed-by Stefan Roese <[email protected]>
Applied to u-boot-marvell/master
Thanks,
Stefan
Quoted 25 lines
Thanks,
StefanQuoted 22 lines
---
tools/kwbimage.c| 6 +++---1 file changed, 3 insertions(+), 3 deletions(-)tools/kwbimage.c +1
-3@@ -1398,9 +1398,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 */@@ -1410,6 +1407,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 */
Quoted 9 lines
tools/kwbimage.c static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, · line 1415
Quoted 5 lines
tools/kwbimage.c +2
-0+ main_hdr->checksum = image_checksum8(main_hdr, headersz); + return image; }Viele Grüße,
Stefan Roese
Viele Grüße,
Stefan Roese
Signature · 3 lines
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: [email protected]