summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2023-03-15 19:33:38 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2023-03-16 10:00:34 +0100
commit3cf4bcd86419a9be1506efb5239bbaa21c3a8fa9 (patch)
tree4d58229effa6f5dd545f0f3ad66ae5d1cfbed6ac
parent7830dc62c88e890ae8e5324793bbec407334626f (diff)
downloadbarebox-3cf4bcd86419a9be1506efb5239bbaa21c3a8fa9.tar.gz
barebox-3cf4bcd86419a9be1506efb5239bbaa21c3a8fa9.tar.xz
imx-usb-loader: Don't try to transfer more data than contained in the image
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> Link: https://lore.barebox.org/20230315183338.78433-1-u.kleine-koenig@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--scripts/imx/imx-usb-loader.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c
index a98ab0e33f..4bcb4cbab6 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;