summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-09-17 12:25:10 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-09-19 07:44:37 +0200
commit072a7964a37038e13b75f1f9309c37f2362beacc (patch)
tree4babd2a42e886f44ab5ebe2906f3aa44342035c7 /scripts
parentf83a3e39f5dadd8ed6f115e3105377ee8dc7ce7c (diff)
downloadbarebox-072a7964a37038e13b75f1f9309c37f2362beacc.tar.gz
barebox-072a7964a37038e13b75f1f9309c37f2362beacc.tar.xz
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 <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imx/imx-image.c36
1 files changed, 15 insertions, 21 deletions
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);