aboutsummaryrefslogtreecommitdiff
path: root/tools/kwboot.c
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2023-03-23 20:57:52 +0100
committerStefan Roese <sr@denx.de>2023-03-24 13:13:35 +0100
commit848d9a5eaaf82d8394b6fab1bda6dd3eb7c5ce45 (patch)
treecf11eb62caac13127c41d12abf495e59a80fd3fe /tools/kwboot.c
parent12e79fbfffa2323679059898414e76caeffa3364 (diff)
downloadu-boot-848d9a5eaaf82d8394b6fab1bda6dd3eb7c5ce45.zip
u-boot-848d9a5eaaf82d8394b6fab1bda6dd3eb7c5ce45.tar.gz
u-boot-848d9a5eaaf82d8394b6fab1bda6dd3eb7c5ce45.tar.bz2
tools: kwboot: Fix invalid UART kwbimage v1 headersz
Ensure that UART aligned header size is always stored into kwbimage v1 header. It is needed for proper UART booting. Calculation of headersz field was broken in commit d656f5a0ee22 ("tools: kwboot: Calculate real used space in kwbimage header when calling kwboot_img_grow_hdr()") which introduced optimization of kwboot_img_grow_hdr() function. Fixes: d656f5a0ee22 ("tools: kwboot: Calculate real used space in kwbimage header when calling kwboot_img_grow_hdr()") Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'tools/kwboot.c')
-rw-r--r--tools/kwboot.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c
index 7c66648..ef108c8 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -2168,6 +2168,17 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
kwboot_printv("Aligning image header to Xmodem block size\n");
kwboot_img_grow_hdr(img, size, grow);
+ hdrsz += grow;
+
+ /*
+ * kwbimage v1 contains header size field and for UART type it
+ * must be set to the aligned xmodem header size because BootROM
+ * rounds header size down to xmodem block size.
+ */
+ if (kwbimage_version(img) == 1) {
+ hdr->headersz_msb = hdrsz >> 16;
+ hdr->headersz_lsb = cpu_to_le16(hdrsz & 0xffff);
+ }
}
hdr->checksum = kwboot_hdr_csum8(hdr) - csum;