diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-02-18 08:36:43 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-02-18 08:36:43 +0100 |
commit | 36bd74ee6139f9807db6745e0f74adff3aff91f5 (patch) | |
tree | 69e03ac4316c3a11133a1974125b4dcbacf64503 /scripts | |
parent | 73e382e3e59cc15ab3e72b8f98254469d1b3187c (diff) | |
parent | b043601a35120c394d67fd47ebd37854b0472e60 (diff) | |
download | barebox-36bd74ee6139f9807db6745e0f74adff3aff91f5.tar.gz barebox-36bd74ee6139f9807db6745e0f74adff3aff91f5.tar.xz |
Merge branch 'for-next/imx'
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/imx/imx-usb-loader.c | 54 |
1 files changed, 12 insertions, 42 deletions
diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index 70883bf883..08affe72c7 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -1228,7 +1228,7 @@ static int is_header(const unsigned char *p) return 1; break; case HDR_MX53: - if (hdr->header.tag == TAG_IVT_HEADER && hdr->header.version == IVT_VERSION) + if (hdr->header.tag == TAG_IVT_HEADER && (hdr->header.version == IVT_VERSION || hdr->header.version == 0x41)) return 1; } @@ -1259,7 +1259,7 @@ static int perform_dcd(unsigned char *p, const unsigned char *file_start, } static int get_dl_start(const unsigned char *p, const unsigned char *file_start, - unsigned cnt, unsigned *dladdr, unsigned *max_length, unsigned *plugin, + unsigned cnt, unsigned *max_length, unsigned *plugin, unsigned *header_addr) { const unsigned char *file_end = file_start + cnt; @@ -1271,7 +1271,6 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start, unsigned char* dcd; int err = get_dcd_range_old(ohdr, file_start, cnt, &dcd, &dcd_end); - *dladdr = ohdr->app_dest; *header_addr = ohdr->dcd_ptr_ptr - offsetof(struct imx_flash_header, dcd); *plugin = 0; if (err >= 0) @@ -1284,7 +1283,6 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start, unsigned char *bd; struct imx_flash_header_v2 *hdr = (struct imx_flash_header_v2 *)p; - *dladdr = hdr->self; *header_addr = hdr->self; bd = hdr->boot_data_ptr + cvt_dest_to_src; if ((bd < file_start) || ((bd + 4) > file_end)) { @@ -1292,7 +1290,6 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start, return -1; } - *dladdr = ((struct imx_boot_data *)bd)->start; *max_length = ((struct imx_boot_data *)bd)->size; *plugin = ((struct imx_boot_data *)bd)->plugin; ((struct imx_boot_data *)bd)->plugin = 0; @@ -1304,7 +1301,7 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start, } static int process_header(struct usb_work *curr, unsigned char *buf, int cnt, - unsigned *p_dladdr, unsigned *p_max_length, unsigned *p_plugin, + unsigned *p_max_length, unsigned *p_plugin, unsigned *p_header_addr) { int ret; @@ -1319,7 +1316,7 @@ static int process_header(struct usb_work *curr, unsigned char *buf, int cnt, if (!is_header(p)) continue; - ret = get_dl_start(p, buf, cnt, p_dladdr, p_max_length, p_plugin, p_header_addr); + ret = get_dl_start(p, buf, cnt, p_max_length, p_plugin, p_header_addr); if (ret < 0) { printf("!!get_dl_start returned %i\n", ret); return ret; @@ -1359,15 +1356,12 @@ 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; - unsigned dladdr = 0; unsigned max_length; unsigned plugin = 0; unsigned header_addr = 0; - unsigned skip = 0; ret = read_file(curr->filename, &buf, &fsize); if (ret < 0) @@ -1375,8 +1369,7 @@ static int do_irom_download(struct usb_work *curr, int verify) max_length = fsize; - ret = process_header(curr, buf, fsize, - &dladdr, &max_length, &plugin, &header_addr); + ret = process_header(curr, buf, fsize, &max_length, &plugin, &header_addr); if (ret < 0) goto cleanup; @@ -1388,31 +1381,8 @@ static int do_irom_download(struct usb_work *curr, int verify) goto cleanup; } - if (!dladdr) { - printf("unknown load address\n"); - ret = -3; - goto cleanup; - } - - file_base = header_addr - header_offset; - - if (usb_id->mach_id->mode == MODE_BULK) { - /* No jump command, dladdr should point to header */ - dladdr = header_addr; - } - - if (file_base > dladdr) { - max_length -= (file_base - dladdr); - dladdr = file_base; - } - - 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; @@ -1433,10 +1403,10 @@ 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, header_addr, fsize, type); - ret = load_file(image, fsize, dladdr, type); + ret = load_file(image, fsize, header_addr, type); if (ret < 0) goto cleanup; @@ -1445,7 +1415,7 @@ static int do_irom_download(struct usb_work *curr, int verify) if (verify) { printf("verifying file...\n"); - ret = verify_memory(image, fsize, dladdr); + ret = verify_memory(image, fsize, header_addr); if (ret < 0) { printf("verifying failed\n"); goto cleanup; @@ -1459,7 +1429,7 @@ static int do_irom_download(struct usb_work *curr, int verify) * so we load part of the image again with type FT_APP * this time. */ - ret = load_file(verify_buffer, 64, dladdr, FT_APP); + ret = load_file(verify_buffer, 64, header_addr, FT_APP); if (ret < 0) goto cleanup; |