Skip to content

Commit

Permalink
tools: kwboot: Recalculate 4-byte data checksum after injecting baudr…
Browse files Browse the repository at this point in the history
…ate code

If data part of image is modified, update 4-byte data checksum.

It looks like A385 BootROM does not verify this checksum for image
loaded via UART, but we do not know if other BootROMs are also ignoring
it. It is always better to provide correct checksum.

Signed-off-by: Pali Rohár <[email protected]>
[ refactored ]
Signed-off-by: Marek Behún <[email protected]>
Reviewed-by: Stefan Roese <[email protected]>
  • Loading branch information
pali authored and stroese committed Nov 3, 2021
1 parent 063cb35 commit 82c5a0a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/kwboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,9 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
kwboot_printv("Injecting code for changing baudrate back\n");
_inject_baudrate_change_code(img, size, 1, baudrate, 115200);

/* Update the 32-bit data checksum */
*kwboot_img_csum32_ptr(img) = kwboot_img_csum32(img);

/* recompute header size */
hdrsz = kwbheader_size(hdr);
}
Expand Down

0 comments on commit 82c5a0a

Please sign in to comment.