From f83a3e39f5dadd8ed6f115e3105377ee8dc7ce7c Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 17 Sep 2014 12:25:09 +0200 Subject: imx-usb-loader: Skip unknown tags Instead of bailing out skip unknown tags. These tags are usually doing operations to poll for a certain register state. The correct solution is to implement this register polling, but for now delay execution for a while and assume the register has the correct state afterwards. Signed-off-by: Sascha Hauer --- scripts/imx/imx-usb-loader.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index 475917bc6c..c86260cdea 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -615,8 +615,10 @@ static int write_dcd_table_ivt(struct libusb_device_handle *h, struct usb_id *p_ printf("sub dcd length %x\n", s_length); if ((dcd[0] != 0xcc) || (dcd[3] != 0x04)) { - printf("Unknown sub tag\n"); - return -1; + printf("Skipping unknown sub tag 0x%02x with len %04x\n", dcd[0], s_length); + usleep(50000); + dcd += s_length; + continue; } dcd += 4; -- cgit v1.2.3 From 072a7964a37038e13b75f1f9309c37f2362beacc Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Wed, 17 Sep 2014 12:25:10 +0200 Subject: imx-image: Handle check commands correctly The length of two subsequent check commands was incorrectly calculated. The check commands have a fixed length anyway, so program a fixed length in the check command and skip the code from check_last_dcd. Signed-off-by: Sascha Hauer --- scripts/imx/imx-image.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'scripts') diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c index 3a25c09298..d1db51780f 100644 --- a/scripts/imx/imx-image.c +++ b/scripts/imx/imx-image.c @@ -259,34 +259,29 @@ struct command { int (*parse)(int argc, char *argv[]); }; -static uint32_t last_cmd; +static uint32_t last_write_cmd; static int last_cmd_len; static uint32_t *last_dcd; static void check_last_dcd(uint32_t cmd) { - if (last_dcd) { - if (last_cmd == cmd) { - return; - } else { - uint32_t l = be32toh(*last_dcd); + cmd &= 0xff0000ff; - l |= last_cmd_len << 8; - - *last_dcd = htobe32(l); - - last_dcd = NULL; - } + if (cmd == last_write_cmd) { + last_cmd_len += sizeof(uint32_t) * 2; + return; } - if (!cmd) - return; + /* write length ... */ + if (last_write_cmd) + *last_dcd = htobe32(last_write_cmd | (last_cmd_len << 8)); - if (!last_dcd) { + if ((cmd >> 24) == TAG_WRITE) { + last_write_cmd = cmd; last_dcd = &dcdtable[curdcd++]; - *last_dcd = htobe32(cmd); - last_cmd_len = sizeof(uint32_t); - last_cmd = cmd; + last_cmd_len = sizeof(uint32_t) * 3; + } else { + last_write_cmd = 0; } } @@ -303,7 +298,6 @@ static int write_mem_v2(uint32_t addr, uint32_t val, int width) check_last_dcd(cmd); - last_cmd_len += sizeof(uint32_t) * 2; dcdtable[curdcd++] = htobe32(addr); dcdtable[curdcd++] = htobe32(val); @@ -370,11 +364,11 @@ static int do_cmd_check(int argc, char *argv[]) return -EINVAL; } - cmd = (TAG_CHECK << 24) | (i << 3) | width; + cmd = (TAG_CHECK << 24) | (i << 3) | width | ((sizeof(uint32_t) * 3) << 8); check_last_dcd(cmd); - last_cmd_len += sizeof(uint32_t) * 2; + dcdtable[curdcd++] = htobe32(cmd); dcdtable[curdcd++] = htobe32(addr); dcdtable[curdcd++] = htobe32(mask); -- cgit v1.2.3 From 690e3920274769cb4f00154c8f7cbac555994905 Mon Sep 17 00:00:00 2001 From: Eric Bénard Date: Wed, 24 Sep 2014 16:42:59 +0200 Subject: imx-image: handle i.MX35 special case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From the i.MX35 user manual : Since MLC NAND Flash devices do not guarantee error-free boot blocks, the i.MX35 boot code requires that the first 4 Kbytes of boot code be duplicated in a subsequent block to serve as a second copy option. Actually imx-image puts the image at 4k but it seems that the i.MX35 bootrom copies only from 8k as it expects that there is a copy of the first 0-4k in 4k-8k (and is supposed to use this copy if there is an ECC error in the first 4k) as we can see in the following lines : barebox@Eukrea CPUIMX35:/ md -s /dev/nand0 0x0 00000000: ea0003fe eafffffe eafffffe eafffffe ................ 00000010: eafffffe eafffffe eafffffe eafffffe ................ 00000020: 65726162 00786f62 00000000 00000000 barebox......... =-> header is @ 0 in flash barebox@Eukrea CPUIMX35:/ md -s /dev/nand0 0x1000 00001000: 56341200 00000000 0001eda1 00000000 ..4V............ 00001010: 00000000 00000000 00000000 00000000 ................ =-> so we have data @ 0x1000 in flash barebox@Eukrea CPUIMX35:/ md 0x87f00000 87f00000: 00000000 00000000 00000000 00000000 ................ 87f00010: 00000000 00000000 00000000 00000000 ................ =-> but we don't find this data in RAM barebox@Eukrea CPUIMX35:/ md -s /dev/nand0 0x2000 00002000: ea000012 eafffffe eafffffe eafffffe ................ 00002010: eafffffe eafffffe eafffffe eafffffe ................ 00002020: 65726162 00786f62 00000000 00034272 barebox.....rB.. =-> so we have the image @ 0x2000 in flash barebox@Eukrea CPUIMX35:/ md 0x87f01000 87f01000: ea000871 eafffffe eafffffe eafffffe q............... 87f01010: eafffffe eafffffe eafffffe eafffffe ................ 87f01020: 65726162 00786f62 87f02000 0003b520 barebox.. .. ... =-> and we find it in RAM Signed-off-by: Eric Bénard Signed-off-by: Sascha Hauer --- scripts/imx/imx-image.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c index d1db51780f..1f37fe20bc 100644 --- a/scripts/imx/imx-image.c +++ b/scripts/imx/imx-image.c @@ -37,6 +37,7 @@ static uint32_t image_dcd_offset; static uint32_t dcdtable[MAX_DCD]; static int curdcd; static int header_version; +static int cpu_type; static int add_barebox_header; /* @@ -448,14 +449,15 @@ static int do_dcd_offset(int argc, char *argv[]) struct soc_type { char *name; int header_version; + int cpu_type; }; static struct soc_type socs[] = { - { .name = "imx25", .header_version = 1, }, - { .name = "imx35", .header_version = 1, }, - { .name = "imx51", .header_version = 1, }, - { .name = "imx53", .header_version = 2, }, - { .name = "imx6", .header_version = 2, }, + { .name = "imx25", .header_version = 1, .cpu_type = 25}, + { .name = "imx35", .header_version = 1, .cpu_type = 35 }, + { .name = "imx51", .header_version = 1, .cpu_type = 51 }, + { .name = "imx53", .header_version = 2, .cpu_type = 53 }, + { .name = "imx6", .header_version = 2, .cpu_type = 6 }, }; static int do_soc(int argc, char *argv[]) @@ -471,6 +473,7 @@ static int do_soc(int argc, char *argv[]) for (i = 0; i < ARRAY_SIZE(socs); i++) { if (!strcmp(socs[i].name, soc)) { header_version = socs[i].header_version; + cpu_type = socs[i].cpu_type; return 0; } } @@ -761,6 +764,14 @@ int main(int argc, char *argv[]) exit(1); } + if (cpu_type == 35) { + ret = xwrite(outfd, buf, 4096); + if (ret < 0) { + perror("write"); + exit(1); + } + } + infd = open(imagename, O_RDONLY); if (infd < 0) { perror("open"); -- cgit v1.2.3