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