mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] imx-image: handle i.MX35 special case
@ 2014-09-24 14:42 Eric Bénard
  2014-09-25  6:14 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Bénard @ 2014-09-24 14:42 UTC (permalink / raw)
  To: barebox

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 <eric@eukrea.com>
---
 scripts/imx/imx-image.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c
index 3a25c09..80762e8 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;
 
 /*
@@ -454,14 +455,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[])
@@ -477,6 +479,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;
 		}
 	}
@@ -767,6 +770,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");
-- 
1.9.3


_______________________________________________
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] imx-image: handle i.MX35 special case
  2014-09-24 14:42 [PATCH] imx-image: handle i.MX35 special case Eric Bénard
@ 2014-09-25  6:14 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2014-09-25  6:14 UTC (permalink / raw)
  To: Eric Bénard; +Cc: barebox

On Wed, Sep 24, 2014 at 04:42:59PM +0200, Eric Bénard wrote:
> Signed-off-by: Eric Bénard <eric@eukrea.com>
> ---
>  scripts/imx/imx-image.c | 21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c

Applied, thanks

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:[~2014-09-25  6:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-24 14:42 [PATCH] imx-image: handle i.MX35 special case Eric Bénard
2014-09-25  6:14 ` Sascha Hauer

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