mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] scripts imx-image: add DCD NOP command support
@ 2016-11-03 18:32 Alexander Kurz
  2016-11-07  7:56 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kurz @ 2016-11-03 18:32 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Kurz

The DCD NOP command is available for all flash header v2 devices (i.MX28,
50, 53, 6 and 7).

Signed-off-by: Alexander Kurz <akurz@blala.de>
---
 scripts/imx/README      |  1 +
 scripts/imx/imx-image.c | 28 ++++++++++++++++++++++++++++
 scripts/imx/imx.c       | 11 +++++++++++
 scripts/imx/imx.h       |  1 +
 4 files changed, 41 insertions(+)

diff --git a/scripts/imx/README b/scripts/imx/README
index 474b387..b5cdb48 100644
--- a/scripts/imx/README
+++ b/scripts/imx/README
@@ -32,6 +32,7 @@ check <width> <cond> <addr> <mask>    Poll until condition becomes true.
                                       while_any_bit_set
 set_bits <width> <addr> <bits>        set <bits> in register <addr>
 clear_bits <width> <addr> <bits>      clear <bits> in register <addr>
+nop                                   do nothing
 
 the i.MX SoCs support a wide range of fancy things doing with the flash header.
 We limit ourselves to a very simple case, that is the flash header has a fixed
diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 650a67f..dd5799c 100644
--- a/scripts/imx/imx-image.c
+++ b/scripts/imx/imx-image.c
@@ -482,6 +482,33 @@ static int write_mem(const struct config_data *data, uint32_t addr,
 	}
 }
 
+static int nop(const struct config_data *data)
+{
+	const struct imx_ivt_header nop_header = {
+		.tag = TAG_NOP,
+		.length = htobe16(4),
+		.version = 0,
+	};
+
+	switch (data->header_version) {
+	case 1:
+		fprintf(stderr, "DCD command NOP not implemented on DCD v1\n");
+		return -EINVAL;
+	case 2:
+		if (curdcd > MAX_DCD - 1) {
+			fprintf(stderr, "At maximum %d DCD entries allowed\n",
+				MAX_DCD);
+			return -ENOMEM;
+		}
+
+		check_last_dcd(*((uint32_t *) &nop_header));
+		dcdtable[curdcd++] = *((uint32_t *) &nop_header);
+		return 0;
+	default:
+		return -EINVAL;
+	}
+}
+
 /*
  * This uses the Freescale Code Signing Tool (CST) to sign the image.
  * The cst is expected to be executable as 'cst' or if exists, the content
@@ -653,6 +680,7 @@ int main(int argc, char *argv[])
 		.image_dcd_offset = 0xffffffff,
 		.write_mem = write_mem,
 		.check = check,
+		.nop = nop,
 	};
 
 	prgname = argv[0];
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index c8ee309..fba049e 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -131,6 +131,14 @@ static int do_cmd_check(struct config_data *data, int argc, char *argv[])
 	return data->check(data, cmd, addr, mask);
 }
 
+static int do_cmd_nop(struct config_data *data, int argc, char *argv[])
+{
+	if (!data->nop)
+		return -ENOSYS;
+
+	return data->nop(data);
+}
+
 static int write_mem(struct config_data *data, int argc, char *argv[],
 		     int set_bits, int clear_bits)
 {
@@ -365,6 +373,9 @@ struct command cmds[] = {
 		.name = "check",
 		.parse = do_cmd_check,
 	}, {
+		.name = "nop",
+		.parse = do_cmd_nop,
+	}, {
 		.name = "loadaddr",
 		.parse = do_loadaddr,
 	}, {
diff --git a/scripts/imx/imx.h b/scripts/imx/imx.h
index ae3702c..57c7525 100644
--- a/scripts/imx/imx.h
+++ b/scripts/imx/imx.h
@@ -77,6 +77,7 @@ struct config_data {
 		     uint32_t addr, uint32_t mask);
 	int (*write_mem)(const struct config_data *data, uint32_t addr,
 			 uint32_t val, int width, int set_bits, int clear_bits);
+	int (*nop)(const struct config_data *data);
 	int csf_space;
 	char *csf;
 };
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] scripts imx-image: add DCD NOP command support
  2016-11-03 18:32 [PATCH] scripts imx-image: add DCD NOP command support Alexander Kurz
@ 2016-11-07  7:56 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2016-11-07  7:56 UTC (permalink / raw)
  To: Alexander Kurz; +Cc: barebox

Hi Alexander,

On Thu, Nov 03, 2016 at 07:32:37PM +0100, Alexander Kurz wrote:
> The DCD NOP command is available for all flash header v2 devices (i.MX28,
> 50, 53, 6 and 7).
> 
> Signed-off-by: Alexander Kurz <akurz@blala.de>
> ---
>  scripts/imx/README      |  1 +
>  scripts/imx/imx-image.c | 28 ++++++++++++++++++++++++++++
>  scripts/imx/imx.c       | 11 +++++++++++
>  scripts/imx/imx.h       |  1 +
>  4 files changed, 41 insertions(+)

Applied, but ... out of curiosity, what do we need this for?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-07  7:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-03 18:32 [PATCH] scripts imx-image: add DCD NOP command support Alexander Kurz
2016-11-07  7:56 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox