From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2 2/4] imx-image: Handle check commands correctly
Date: Wed, 17 Sep 2014 12:25:10 +0200 [thread overview]
Message-ID: <1410949512-16562-3-git-send-email-s.trumtrar@pengutronix.de> (raw)
In-Reply-To: <1410949512-16562-1-git-send-email-s.trumtrar@pengutronix.de>
From: Sascha Hauer <s.hauer@pengutronix.de>
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>
---
scripts/imx/imx-image.c | 36 +++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 3a25c0929883..d1db51780f64 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);
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-09-17 10:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-17 10:25 [PATCH v2 0/4] KaRo TX6u support Steffen Trumtrar
2014-09-17 10:25 ` [PATCH v2 1/4] imx-usb-loader: Skip unknown tags Steffen Trumtrar
2014-09-17 10:25 ` Steffen Trumtrar [this message]
2014-09-17 10:25 ` [PATCH v2 3/4] arm: mach-imx: add more ddr register defines Steffen Trumtrar
2014-09-17 10:25 ` [PATCH v2 4/4] ARM: i.MX6: add support for Karo TX6X family Steffen Trumtrar
2014-09-19 5:45 ` [PATCH v2 0/4] KaRo TX6u support Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410949512-16562-3-git-send-email-s.trumtrar@pengutronix.de \
--to=s.trumtrar@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox