]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: kwboot: Recalculate 4-byte data checksum after injecting baudrate code
authorPali Rohár <pali@kernel.org>
Mon, 25 Oct 2021 13:12:57 +0000 (15:12 +0200)
committerStefan Roese <sr@denx.de>
Wed, 3 Nov 2021 05:45:27 +0000 (06:45 +0100)
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 <pali@kernel.org>
[ refactored ]
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
tools/kwboot.c

index bf26a667b735a0e7b19f1d5db98df08a5e615adc..1131c2eb1c46d37b28b7ce9f1c00556cc54e6a72 100644 (file)
@@ -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);
        }