See comments in patch for U-Boot console commands to convert existing
U-Boot environment to "NOR partition first" scheme.

I will be away for a couple of days but will react to any comments as
soon as possible.
generate-mtdpartsraw.patch

From: warmcat <[EMAIL PROTECTED]>

This patch makes U-boot autogenerate a new env var when the env block is
loaded from NAND.

When the GTA device is brought up from manufacture, a bad block test on the NAND
is executed in U-Boot, which generates a possibly device-specific "mtdparts"
environment variable that is stored in the U-Boot environment partition.  The
"mtdparts" var is defined as something like this (the "mtdparts=" at the
beginning is part of the value of the env var)

mtdparts=neo1973-nand:0x00040000(u-boot),0x00040000(u-boot_env),0x00200000(kernel),0x000a0000(splash),0x0fce0000(rootfs)

We need to pass this information on the kernel commandline so the kernel understands
the layout on that specific device, but unfortunately we need to add the NOR
partition information between the "mtdparts=" part and the "neo1973-nand..." part.

This patch autogenerates a new env var if mtdparts is defined, called "mtdpartsraw".
Its value is the same as "mtdparts" but with the "mtdparts=" at the start snipped.
If there is an mtdpartsraw in the environment already, it is deleted first.

This means we can now make an existing U-Boot env compatible by the following U-Boot
commands

setenv bootcmd setenv bootargs \${bootargs_base} mtdparts=physmap-flash:-(nor)\\;\${mtdpartsraw}\; nand read.e 0x32000000 kernel\; bootm 0x32000000
setenv bootargs_base rootfstype=jffs2 root=/dev/mtdblock5 console=ttySAC2,115200 console=tty0 loglevel=8
saveenv

which uses the nand device-specific information from mtdparts but with out NOR information
prepended: the second one converts it to boot from /dev/mtdblock5 instead of 4 since
our NOR device is now occupying /dev/mtdblock0 and moved the NAND partitions down by one.

Signed-off-by: Andy Green <[EMAIL PROTECTED]>
---

 common/env_common.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)


diff --git a/common/env_common.c b/common/env_common.c
index 1734fbf..d7af31f 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -216,6 +216,8 @@ void default_env(void)
 
 void env_relocate (void)
 {
+	char * mtdparts;
+
 	DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,
 		gd->reloc_off);
 
@@ -267,6 +269,22 @@ void env_relocate (void)
 #ifdef CONFIG_AMIGAONEG3SE
 	disable_nvram();
 #endif
+
+	/* clear down any mtdpartsraw that found its way into the env */
+	setenv("mtdpartsraw", NULL);
+	/* get ahold of mtdparts if it exists */
+	mtdparts = getenv("mtdparts");
+	if (mtdparts == NULL)
+		goto bail;
+	if (strlen(mtdparts) < 9) /* "mtdparts=" is 9 chars */
+		goto bail;
+	/*
+	 * create an env var that is the same as mtdparts but without the
+	 * mtdparts= preamble, so we can prepend our own stuff
+	 */
+	setenv("mtdpartsraw", mtdparts + 9); /* snip mtdparts= */
+bail:
+	return;
 }
 
 #ifdef CONFIG_AUTO_COMPLETE

Reply via email to