mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] imx-usb-loader: Don't try to transfer more data than contained in the image
@ 2023-03-15 18:33 Uwe Kleine-König
  2023-03-16  9:00 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2023-03-15 18:33 UTC (permalink / raw)
  To: barebox

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-16  9:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15 18:33 [PATCH] imx-usb-loader: Don't try to transfer more data than contained in the image Uwe Kleine-König
2023-03-16  9:00 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox