public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Stefan Roese <sr@denx.de>, Martin Rowe <martin.p.rowe@gmail.com>
Cc: u-boot@lists.denx.de
Subject: [PATCH u-boot-mvebu 2/5] tools: kwboot: Fix invalid UART kwbimage v1 headersz
Date: Thu, 23 Mar 2023 20:57:52 +0100	[thread overview]
Message-ID: <20230323195755.5131-3-pali@kernel.org> (raw)
In-Reply-To: <20230323195755.5131-1-pali@kernel.org>

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>
---
 tools/kwboot.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index c131711444ec..dd894e80db1c 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -2171,6 +2171,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;
-- 
2.20.1


  parent reply	other threads:[~2023-03-23 19:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 19:57 [PATCH u-boot-mvebu 0/5] mvebu: Fix UART booting Pali Rohár
2023-03-23 19:57 ` [PATCH u-boot-mvebu 1/5] tools: kwbimage: Fix invalid UART kwbimage v1 headersz Pali Rohár
2023-03-24  8:22   ` Stefan Roese
2023-03-23 19:57 ` Pali Rohár [this message]
2023-03-24  8:22   ` [PATCH u-boot-mvebu 2/5] tools: kwboot: " Stefan Roese
2023-03-23 19:57 ` [PATCH u-boot-mvebu 3/5] tools: kwboot: Fix inserting UART data checksum without -B option Pali Rohár
2023-03-24  8:23   ` Stefan Roese
2023-03-23 19:57 ` [PATCH u-boot-mvebu 4/5] tools: kwboot: Fix sending very small images Pali Rohár
2023-03-24  8:23   ` Stefan Roese
2023-03-23 19:57 ` [PATCH u-boot-mvebu 5/5] tools: kwboot: Workaround A38x BootROM bug for images with a gap Pali Rohár
2023-03-24  8:24   ` Stefan Roese
2023-03-24  3:31 ` [PATCH u-boot-mvebu 0/5] mvebu: Fix UART booting Martin Rowe
2023-03-24 14:44 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230323195755.5131-3-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=martin.p.rowe@gmail.com \
    --cc=sr@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox