From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] imx-usb-loader: Don't try to transfer more data than contained in the image
Date: Wed, 15 Mar 2023 19:33:38 +0100 [thread overview]
Message-ID: <20230315183338.78433-1-u.kleine-koenig@pengutronix.de> (raw)
On platforms that don't have a 2nd stage (in my case i.MX25) it usually
happens the transfer limit for the first (and only) upload is bigger than
the actual file length. Then it's the right thing to load the complete
image (minus its header), but not more.
This fixes a failure to boot via USB on i.MX25 that ends in
dl_command err=-1, last_trans=0
Fixes: 3367ebc55ebe ("scripts: imx-usb-loader: simplify code flow for file size calculations")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
scripts/imx/imx-usb-loader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c
index a98ab0e33f8a..4bcb4cbab6fe 100644
--- a/scripts/imx/imx-usb-loader.c
+++ b/scripts/imx/imx-usb-loader.c
@@ -1403,7 +1403,7 @@ static int do_irom_download(struct usb_work *curr, int verify)
printf("loading binary file(%s) to 0x%08x, firststage_len=%zu type=%d, hdroffset=%u...\n",
curr->filename, header_addr, firststage_len, type, header_offset);
- ret = load_file(image, firststage_len, header_addr, type, false);
+ ret = load_file(image, min(fsize, firststage_len), header_addr, type, false);
if (ret < 0)
goto cleanup;
base-commit: e3b5c9b60447eb266cb4895ee4662b1b613545b4
--
2.39.2
next reply other threads:[~2023-03-15 18:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 18:33 Uwe Kleine-König [this message]
2023-03-16 9:00 ` Sascha Hauer
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=20230315183338.78433-1-u.kleine-koenig@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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