summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-02-13 09:19:11 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2020-02-13 11:43:25 +0100
commit02f37e1aef2de721cfd1a41ef2866e25e66e0035 (patch)
treee6594f22925b14db0a7ff5c6c790b33adac7e036 /scripts
parent315174e60e4be1463411e2e7ffe915ac649c60c8 (diff)
downloadbarebox-02f37e1aef2de721cfd1a41ef2866e25e66e0035.tar.gz
barebox-02f37e1aef2de721cfd1a41ef2866e25e66e0035.tar.xz
scripts: imx-usb-loader: download address is always the header address
We always have to upload the image beginning with the header, we have to skip everything that is before the header. In MODE_BULK this is explicit, but in HID mode this is obfuscated by doing several calculations with helper variables. Drop this and simplify code. Tested on i.MX51, i.MX53 and i.MX6 Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imx/imx-usb-loader.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c
index ebe0eea050..d6c62820c3 100644
--- a/scripts/imx/imx-usb-loader.c
+++ b/scripts/imx/imx-usb-loader.c
@@ -1359,7 +1359,6 @@ static int do_irom_download(struct usb_work *curr, int verify)
unsigned char type;
unsigned fsize = 0;
unsigned header_offset;
- unsigned file_base;
unsigned char *buf = NULL;
unsigned char *image;
unsigned char *verify_buffer = NULL;
@@ -1367,7 +1366,6 @@ static int do_irom_download(struct usb_work *curr, int verify)
unsigned max_length;
unsigned plugin = 0;
unsigned header_addr = 0;
- unsigned skip = 0;
ret = read_file(curr->filename, &buf, &fsize);
if (ret < 0)
@@ -1394,20 +1392,10 @@ static int do_irom_download(struct usb_work *curr, int verify)
goto cleanup;
}
- file_base = header_addr - header_offset;
+ dladdr = header_addr;
- if (usb_id->mach_id->mode == MODE_BULK) {
- /* No jump command, dladdr should point to header */
- dladdr = header_addr;
- }
-
- skip = dladdr - file_base;
-
- image = buf + skip;
- fsize -= skip;
-
- if (fsize > max_length)
- fsize = max_length;
+ image = buf + header_offset;
+ fsize -= header_offset;
type = FT_APP;
@@ -1428,8 +1416,8 @@ static int do_irom_download(struct usb_work *curr, int verify)
}
}
- printf("loading binary file(%s) to 0x%08x, skip=0x%x, fsize=%u type=%d...\n",
- curr->filename, dladdr, skip, fsize, type);
+ printf("loading binary file(%s) to 0x%08x, fsize=%u type=%d...\n",
+ curr->filename, dladdr, fsize, type);
ret = load_file(image, fsize, dladdr, type);
if (ret < 0)