Skip to contentSkip to conversation

Changes for single binary image for u-boot for NAND/OneNAND flash.

PATCH New Manikandan Pillai 4 participants 6 messages Mar 3, 2009 – Mar 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Changes for single binary image for u-boot for NAND/OneNAND flash.

Support for single binary image for NAND/OneNAND based OMAP3 EVM boards. The software has to set the flag CONFIG_ENV_IS_RUNTIME_SEL in include/configs/omap3_evm.h. The software is able to detect whether it is NAND or OneNAND flash at runtime. The flash detected is set as the environment store also.

As per the comments received, the change is done only for OMAP3 EVM.

---
 board/omap3/evm/evm.c             |    2 +
 common/Makefile                   |    1 +
 common/cmd_nvedit.c               |    5 ++
 common/env_common.c               |    8 +++-
 common/env_nand.c                 |   33 +++++++++++-
 common/env_onenand.c              |   26 +++++++++-
 cpu/arm_cortexa8/omap3/board.c    |   13 +++++
 cpu/arm_cortexa8/omap3/mem.c      |  100 ++++++++++++++++++++++++++++++++++++-
 cpu/arm_cortexa8/omap3/sys_info.c |   27 +++++++++-
 include/common.h                  |   10 +++-
 include/configs/omap3_evm.h       |    6 ++-
 lib_arm/board.c                   |   25 +++++++---
 12 files changed, 237 insertions(+), 19 deletions(-)
board/omap3/evm/evm.c +2 -0
index b406312..9924432 100644
@@ -44,7 +44,9 @@ int board_init(void)
 {
 	DECLARE_GLOBAL_DATA_PTR;
 
+#if !defined(CONFIG_ENV_IS_RUNTIME_SEL)
 	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+#endif
 	/* board id for Linux */
 	gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
 	/* boot param addr */
common/Makefile +1 -0
index f13cd11..a6c55d2 100644
@@ -58,6 +58,7 @@ COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o
 COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
 COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
 COBJS-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
+COBJS-$(CONFIG_ENV_IS_RUNTIME_SEL) += env_onenand.o env_nand.o
 
 # command
 COBJS-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o
common/cmd_nvedit.c +5 -0
index 68c673e..628bcf4 100644
@@ -59,6 +59,7 @@ DECLARE_GLOBAL_DATA_PTR;
     !defined(CONFIG_ENV_IS_IN_NAND)	&& \
     !defined(CONFIG_ENV_IS_IN_ONENAND)	&& \
     !defined(CONFIG_ENV_IS_IN_SPI_FLASH)	&& \
+    !defined(CONFIG_ENV_IS_RUNTIME_SEL)	&& \
     !defined(CONFIG_ENV_IS_NOWHERE)
 # error Define one of CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE}
 #endif
@@ -66,6 +67,10 @@ DECLARE_GLOBAL_DATA_PTR;
 #define XMK_STR(x)	#x
 #define MK_STR(x)	XMK_STR(x)
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern saveenv_p saveenv;
+#endif
+
 /************************************************************************
 ************************************************************************/
 
common/env_common.c +7 -1
index 6be3bb0..b692900 100644
@@ -46,8 +46,13 @@ DECLARE_GLOBAL_DATA_PTR;
 
 extern env_t *env_ptr;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern env_get_char_spec_p env_get_char_spec;
+extern env_relocate_spec_p env_relocate_spec;
+#else
 extern void env_relocate_spec (void);
 extern uchar env_get_char_spec(int);
+#endif
 
 static uchar env_get_char_init (int index);
 
@@ -140,7 +145,8 @@ uchar default_environment[] = {
 };
 
 #if defined(CONFIG_ENV_IS_IN_NAND)		/* Environment is in Nand Flash */ \
-	|| defined(CONFIG_ENV_IS_IN_SPI_FLASH)
+	|| defined(CONFIG_ENV_IS_IN_SPI_FLASH) \
+	|| (defined(CONFIG_CMD_NAND) && defined(CONFIG_ENV_IS_RUNTIME_SEL))
 int default_environment_size = sizeof(default_environment);
 #endif
 
common/env_nand.c +31 -2
index 76569da..add74c2 100644
@@ -65,17 +65,22 @@ int nand_legacy_rw (struct nand_chip* nand, int cmd,
 extern uchar default_environment[];
 extern int default_environment_size;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+char *nand_env_name_spec = "NAND";
+#else
 char * env_name_spec = "NAND";
-
+#endif
 
 #ifdef ENV_IS_EMBEDDED
 extern uchar environment[];
 env_t *env_ptr = (env_t *)(&environment[0]);
+#elif defined(CONFIG_ENV_IS_RUNTIME_SEL)
+env_t *nand_env_ptr;
+env_t *env_ptr;
 #else /* ! ENV_IS_EMBEDDED */
 env_t *env_ptr = 0;
 #endif /* ENV_IS_EMBEDDED */
 
-
 /* local functions */
 #if !defined(ENV_IS_EMBEDDED)
 static void use_default(void);
@@ -83,7 +88,11 @@ static void use_default(void);
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+uchar nand_env_get_char_spec(int index)
+#else
 uchar env_get_char_spec (int index)
+#endif
 {
 	return ( *((uchar *)(gd->env_addr + index)) );
 }
@@ -100,7 +109,11 @@ uchar env_get_char_spec (int index)
  * the SPL loads not only the U-Boot image from NAND but also the
  * environment.
  */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int nand_env_init(void)
+#else
 int env_init(void)
+#endif
 {
 #if defined(ENV_IS_EMBEDDED)
 	size_t total;
@@ -181,7 +194,11 @@ int writeenv(size_t offset, u_char *buf)
 	return 0;
 }
 #ifdef CONFIG_ENV_OFFSET_REDUND
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int nand_saveenv(void)
+#else
 int saveenv(void)
+#endif
 {
 	size_t total;
 	int ret = 0;
@@ -224,7 +241,11 @@ int saveenv(void)
 	return ret;
 }
 #else /* ! CONFIG_ENV_OFFSET_REDUND */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int nand_saveenv(void)
+#else
 int saveenv(void)
+#endif
 {
 	size_t total;
 	int ret = 0;
@@ -284,7 +305,11 @@ int readenv (size_t offset, u_char * buf)
 }
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+void nand_env_relocate_spec(void)
+#else
 void env_relocate_spec (void)
+#endif
 {
 #if !defined(ENV_IS_EMBEDDED)
 	size_t total;
@@ -343,7 +368,11 @@ void env_relocate_spec (void)
  * The legacy NAND code saved the environment in the first NAND device i.e.,
  * nand_dev_desc + 0. This is also the behaviour using the new NAND code.
  */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+void nand_env_relocate_spec(void)
+#else
 void env_relocate_spec (void)
+#endif
 {
 #if !defined(ENV_IS_EMBEDDED)
 	int ret;
common/env_onenand.c +24 -2
index dbccc79..7aaa83c 100644
@@ -39,11 +39,19 @@ extern uchar default_environment[];
 
 #define ONENAND_ENV_SIZE(mtd)	(mtd.writesize - ENV_HEADER_SIZE)
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+char *onenand_env_name_spec = "OneNAND";
+#else
 char *env_name_spec = "OneNAND";
+#endif
 
 #ifdef ENV_IS_EMBEDDED
 extern uchar environment[];
 env_t *env_ptr = (env_t *) (&environment[0]);
+#elif defined(CONFIG_ENV_IS_RUNTIME_SEL)
+static unsigned char onenand_env[MAX_ONENAND_PAGESIZE];
+env_t *onenand_env_ptr = (env_t *)&onenand_env[0];
+extern env_t *env_ptr;
 #else /* ! ENV_IS_EMBEDDED */
 static unsigned char onenand_env[MAX_ONENAND_PAGESIZE];
 env_t *env_ptr = (env_t *) onenand_env;
@@ -51,12 +59,20 @@ env_t *env_ptr = (env_t *) onenand_env;
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+uchar onenand_env_get_char_spec(int index)
+#else
 uchar env_get_char_spec(int index)
+#endif
 {
 	return (*((uchar *) (gd->env_addr + index)));
 }
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+void onenand_env_relocate_spec(void)
+#else
 void env_relocate_spec(void)
+#endif
 {
 	unsigned long env_addr;
 	int use_default = 0;
@@ -87,7 +103,11 @@ void env_relocate_spec(void)
 	gd->env_valid = 1;
 }
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int onenand_saveenv(void)
+#else
 int saveenv(void)
+#endif
 {
 	unsigned long env_addr = CONFIG_ENV_ADDR;
 	struct erase_info instr = {
@@ -102,7 +122,6 @@ int saveenv(void)
 		printf("OneNAND: erase failed at 0x%08lx\n", env_addr);
 		return 1;
 	}
-
 	/* update crc */
 	env_ptr->crc =
 	    crc32(0, env_ptr->data, ONENAND_ENV_SIZE(onenand_mtd));
@@ -112,11 +131,14 @@ int saveenv(void)
 		printf("OneNAND: write failed at 0x%08x\n", instr.addr);
 		return 2;
 	}
-
 	return 0;
 }
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int onenand_env_init(void)
+#else
 int env_init(void)
+#endif
 {
 	/* use default */
 	gd->env_addr = (ulong) & default_environment[0];
cpu/arm_cortexa8/omap3/board.c +13 -0
index 7bb3e28..ba0eec6 100644
@@ -313,6 +313,19 @@ void abort(void)
 {
 }
 
+/******************************************************************************
+ * Routine: print_board_info
+ * Description: Displays cpu and memory information for the board
+ *****************************************************************************/
+void print_board_info(void)
+{
+	u32 btype;
+
+	btype = get_board_type();
+
+	display_board_info(btype);
+}
+
 #ifdef CONFIG_NAND_OMAP_GPMC
 /******************************************************************************
  * OMAP3 specific command to switch between NAND HW and SW ecc
cpu/arm_cortexa8/omap3/mem.c +98 -2

151 lines not on this page · raw message

cpu/arm_cortexa8/omap3/sys_info.c +24 -3
index 28a1020..86cc95f 100644
@@ -36,6 +36,14 @@ static gpmc_csx_t *gpmc_cs_base = (gpmc_csx_t *)GPMC_CONFIG_CS0_BASE;
 static sdrc_t *sdrc_base = (sdrc_t *)OMAP34XX_SDRC_BASE;
 static ctrl_t *ctrl_base = (ctrl_t *)OMAP34XX_CTRL_BASE;
 
+#if defined(CONFIG_CMD_NAND)
+extern u8 is_nand;
+#endif
+
+#if defined(CONFIG_CMD_ONENAND)
+extern u8 is_onenand;
+#endif
+
 /******************************************
  * get_cpu_type(void) - extract cpu info
  ******************************************/
@@ -208,9 +216,22 @@ void display_board_info(u32 btype)
 
 
 	printf("OMAP%s-%s rev %d, CPU-OPP2 L3-165MHz\n", cpu_s,
-	       sec_s, get_cpu_rev());
-	printf("%s + %s/%s\n", sysinfo.board_string,
-	       mem_s, sysinfo.nand_string);
+		sec_s, get_cpu_rev());
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+		printf("%s + %s/", sysinfo.board_string,
+			mem_s);
+#if defined(CONFIG_CMD_NAND)
+	if (is_nand)
+		printf("%s\n", "NAND");
+#endif
+#if defined(CONFIG_CMD_ONENAND)
+	if (is_onenand)
+		printf("%s\n", "ONENAND");
+#endif
+#else
+		printf("%s + %s/%s\n", sysinfo.board_string,
+			mem_s, sysinfo.nand_string);
+#endif
 
 }
 
include/common.h +9 -1
index b75ea60..fd3da2c 100644
@@ -243,12 +243,20 @@ extern ulong load_addr;		/* Default Load Address */
 void	doc_probe(unsigned long physadr);
 
 /* common/cmd_nvedit.c */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+typedef uchar (*env_get_char_spec_p)(int index);
+typedef int (*env_init_p)(void);
+typedef int (*saveenv_p)(void);
+typedef void (*env_relocate_spec_p)(void);
+#else
 int	env_init     (void);
+int     saveenv(void);
+#endif
 void	env_relocate (void);
 int	envmatch     (uchar *, int);
 char	*getenv	     (char *);
 int	getenv_r     (char *name, char *buf, unsigned len);
-int	saveenv	     (void);
+
 #ifdef CONFIG_PPC		/* ARM version to be fixed! */
 int inline setenv   (char *, char *);
 #else
include/configs/omap3_evm.h +5 -1
index f4498a9..bf5614e 100644
@@ -107,6 +107,7 @@
 #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
 #define CONFIG_CMD_MMC		/* MMC support			*/
 #define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#define CONFIG_CMD_NAND		/* NAND support                 */
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING
 
@@ -125,12 +126,15 @@
 /*
  * Board NAND Info.
  */
+#define CONFIG_NAND_OMAP_GPMC
 #define CONFIG_SYS_NAND_ADDR		NAND_BASE	/* physical address */
 							/* to access nand */
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access */
 							/* nand at CS0 */
 
+#define GPMC_NAND_ECC_LP_x16_LAYOUT     1
+
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
 							/* NAND devices */
 #define SECTORSIZE			512
@@ -271,7 +275,7 @@
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
 
-#define CONFIG_ENV_IS_IN_ONENAND	1
+#define CONFIG_ENV_IS_RUNTIME_SEL	1
 #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
 #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
 
lib_arm/board.c +18 -7
index 09eaaf2..9a0c285 100644
@@ -60,6 +60,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern void gpmc_init(void);
+extern void print_board_info(void);
+#endif
+
 #ifdef CONFIG_HAS_DATAFLASH
 extern int  AT91F_DataflashInit(void);
 extern void dataflash_print_info(void);
@@ -259,12 +264,17 @@ static int arm_pci_init(void)
 typedef int (init_fnc_t) (void);
 
 int print_cpuinfo (void); /* test-only */
+extern env_init_p env_init;
 
 init_fnc_t *init_sequence[] = {
 	cpu_init,		/* basic cpu dependent setup */
 	board_init,		/* basic board dependent setup */
 	interrupt_init,		/* set up exceptions */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+	NULL,			/* initialize environment */
+#else
 	env_init,		/* initialize environment */
+#endif
 	init_baudrate,		/* initialze baudrate settings */
 	serial_init,		/* serial communications setup */
 	console_init_f,		/* stage 1 init of console */
@@ -350,13 +360,14 @@ void start_armboot (void)
 	/* armboot_start is defined in the board-specific linker script */
 	mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN);
 
-#if defined(CONFIG_CMD_NAND)
-	puts ("NAND:  ");
-	nand_init();		/* go init the NAND */
-#endif
-
-#if defined(CONFIG_CMD_ONENAND)
-	onenand_init();
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+	env_init();
+	init_baudrate();        /* initialze baudrate settings */
+	serial_init();          /* serial communications setup */
+	console_init_f();       /* stage 1 init of console */
+	display_banner();
+	print_board_info();
 #endif
 
 #ifdef CONFIG_HAS_DATAFLASH
Signature · 1 line
1.5.6
#1 lore raw

PATCH 1/1 Changes for single binary image for u-boot for NAND/OneNAND flash.

Manikandan Pillai said the following on 03/03/2009 05:41 AM:

Quoted 6 lines

Support for single binary image for NAND/OneNAND based OMAP3 EVM boards. The software has to set the flag CONFIG_ENV_IS_RUNTIME_SEL in include/configs/omap3_evm.h. The software is able to detect whether it is NAND or OneNAND flash at runtime. The flash detected is set as the environment store also.

makes sense for SDP also.. in SDP3430, we have NOR,OneNAND,NAND and MMC as possible boot devices. :(
Could you please split this patch into two:
a) changes to generic files
b) changes specific to omap.
it is easier to review that way..

Quoted 86 lines

As per the comments received, the change is done only for OMAP3 EVM.

---
 board/omap3/evm/evm.c             |    2 +
 common/Makefile                   |    1 +
 common/cmd_nvedit.c               |    5 ++
 common/env_common.c               |    8 +++-
 common/env_nand.c                 |   33 +++++++++++-
 common/env_onenand.c              |   26 +++++++++-
 cpu/arm_cortexa8/omap3/board.c    |   13 +++++
 cpu/arm_cortexa8/omap3/mem.c      |  100 ++++++++++++++++++++++++++++++++++++-
 cpu/arm_cortexa8/omap3/sys_info.c |   27 +++++++++-
 include/common.h                  |   10 +++-
 include/configs/omap3_evm.h       |    6 ++-
 lib_arm/board.c                   |   25 +++++++---
 12 files changed, 237 insertions(+), 19 deletions(-)
board/omap3/evm/evm.c +2 -0
index b406312..9924432 100644
@@ -44,7 +44,9 @@ int board_init(void)
 {
 	DECLARE_GLOBAL_DATA_PTR;
 
+#if !defined(CONFIG_ENV_IS_RUNTIME_SEL)
 	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+#endif
 	/* board id for Linux */
 	gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
 	/* boot param addr */
common/Makefile +1 -0
index f13cd11..a6c55d2 100644
@@ -58,6 +58,7 @@ COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o
 COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
 COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
 COBJS-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
+COBJS-$(CONFIG_ENV_IS_RUNTIME_SEL) += env_onenand.o env_nand.o
 
 # command
 COBJS-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o
common/cmd_nvedit.c +5 -0
index 68c673e..628bcf4 100644
@@ -59,6 +59,7 @@ DECLARE_GLOBAL_DATA_PTR;
     !defined(CONFIG_ENV_IS_IN_NAND)	&& \
     !defined(CONFIG_ENV_IS_IN_ONENAND)	&& \
     !defined(CONFIG_ENV_IS_IN_SPI_FLASH)	&& \
+    !defined(CONFIG_ENV_IS_RUNTIME_SEL)	&& \
     !defined(CONFIG_ENV_IS_NOWHERE)
 # error Define one of CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE}
 #endif
@@ -66,6 +67,10 @@ DECLARE_GLOBAL_DATA_PTR;
 #define XMK_STR(x)	#x
 #define MK_STR(x)	XMK_STR(x)
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern saveenv_p saveenv;
+#endif
+
 /************************************************************************
 ************************************************************************/
 
common/env_common.c +5 -0
index 6be3bb0..b692900 100644
@@ -46,8 +46,13 @@ DECLARE_GLOBAL_DATA_PTR;
 
 extern env_t *env_ptr;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern env_get_char_spec_p env_get_char_spec;
+extern env_relocate_spec_p env_relocate_spec;
+#else
 extern void env_relocate_spec (void);
 extern uchar env_get_char_spec(int);
+#endif
 
 static uchar env_get_char_init (int index);
 

common/env_common.c uchar default_environment[] = { · line 150

Quoted 7 lines
common/env_common.c +2 -1
@@ -140,7 +145,8 @@ uchar default_environment[] = {
 };
 
 #if defined(CONFIG_ENV_IS_IN_NAND)		/* Environment is in Nand Flash */ \
-	|| defined(CONFIG_ENV_IS_IN_SPI_FLASH)
+	|| defined(CONFIG_ENV_IS_IN_SPI_FLASH) \
+	|| (defined(CONFIG_CMD_NAND) && defined(CONFIG_ENV_IS_RUNTIME_SEL))
 

Errr.... ENV_IS_IN_NAND Vs ENV_IS_RUNTIME_SEL is not clear.

Quoted 8 lines
common/env_common.c +0 -0
 int default_environment_size = sizeof(default_environment);
 #endif
common/env_nand.c +0 -0
index 76569da..add74c2 100644

common/env_nand.c int nand_legacy_rw (struct nand_chip* nand, int cmd, · line 70

Quoted 6 lines
common/env_nand.c +2 -0
@@ -65,17 +65,22 @@ int nand_legacy_rw (struct nand_chip* nand, int cmd,
 extern uchar default_environment[];
 extern int default_environment_size;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+char *nand_env_name_spec = "NAND";
 

I suppose we might want a README.runtime_env to understand it's usage..

Quoted 104 lines
common/env_nand.c +5 -2
+#else
 char * env_name_spec = "NAND";
-
+#endif
 
 #ifdef ENV_IS_EMBEDDED
 extern uchar environment[];
 env_t *env_ptr = (env_t *)(&environment[0]);
+#elif defined(CONFIG_ENV_IS_RUNTIME_SEL)
+env_t *nand_env_ptr;
+env_t *env_ptr;
 #else /* ! ENV_IS_EMBEDDED */
 env_t *env_ptr = 0;
 #endif /* ENV_IS_EMBEDDED */
 
-
 /* local functions */
 #if !defined(ENV_IS_EMBEDDED)

static void use_default(void);

common/env_nand.c +24 -0
@@ -83,7 +88,11 @@ static void use_default(void);
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+uchar nand_env_get_char_spec(int index)
+#else
 uchar env_get_char_spec (int index)
+#endif
 {
 	return ( *((uchar *)(gd->env_addr + index)) );
 }
@@ -100,7 +109,11 @@ uchar env_get_char_spec (int index)
  * the SPL loads not only the U-Boot image from NAND but also the
  * environment.
  */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int nand_env_init(void)
+#else
 int env_init(void)
+#endif
 {
 #if defined(ENV_IS_EMBEDDED)
 	size_t total;
@@ -181,7 +194,11 @@ int writeenv(size_t offset, u_char *buf)
 	return 0;
 }
 #ifdef CONFIG_ENV_OFFSET_REDUND
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int nand_saveenv(void)
+#else
 int saveenv(void)
+#endif
 {
 	size_t total;
 	int ret = 0;
@@ -224,7 +241,11 @@ int saveenv(void)
 	return ret;
 }
 #else /* ! CONFIG_ENV_OFFSET_REDUND */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int nand_saveenv(void)
+#else
 int saveenv(void)
+#endif
 {
 	size_t total;
 	int ret = 0;
@@ -284,7 +305,11 @@ int readenv (size_t offset, u_char * buf)
 }
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+void nand_env_relocate_spec(void)
+#else
 void env_relocate_spec (void)
+#endif
 {
 #if !defined(ENV_IS_EMBEDDED)
 	size_t total;
@@ -343,7 +368,11 @@ void env_relocate_spec (void)
  * The legacy NAND code saved the environment in the first NAND device i.e.,
  * nand_dev_desc + 0. This is also the behaviour using the new NAND code.
  */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+void nand_env_relocate_spec(void)
+#else
 void env_relocate_spec (void)
+#endif
 {
 #if !defined(ENV_IS_EMBEDDED)
 	int ret;
common/env_onenand.c +4 -0
index dbccc79..7aaa83c 100644
@@ -39,11 +39,19 @@ extern uchar default_environment[];
 
 #define ONENAND_ENV_SIZE(mtd)	(mtd.writesize - ENV_HEADER_SIZE)
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+char *onenand_env_name_spec = "OneNAND";
+#else
 char *env_name_spec = "OneNAND";
+#endif

common/env_onenand.c extern uchar default_environment[]; · line 56

Quoted 10 lines
common/env_onenand.c +4 -0
 
 #ifdef ENV_IS_EMBEDDED
 extern uchar environment[];
 env_t *env_ptr = (env_t *) (&environment[0]);
+#elif defined(CONFIG_ENV_IS_RUNTIME_SEL)
+static unsigned char onenand_env[MAX_ONENAND_PAGESIZE];
+env_t *onenand_env_ptr = (env_t *)&onenand_env[0];
+extern env_t *env_ptr;
 #else /* ! ENV_IS_EMBEDDED */
 

and NOT CONFIG_ENV_IS_RUNTIME_SEL...

Quoted 7 lines
common/env_onenand.c +0 -0
 static unsigned char onenand_env[MAX_ONENAND_PAGESIZE];

env_t *env_ptr = (env_t *) onenand_env;

common/env_onenand.c +1 -0
@@ -51,12 +59,20 @@ env_t *env_ptr = (env_t *) onenand_env;
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)

common/env_onenand.c env_t *env_ptr = (env_t *) onenand_env; · line 72

Quoted 10 lines
common/env_onenand.c +4 -0
+uchar onenand_env_get_char_spec(int index)
+#else
 uchar env_get_char_spec(int index)
+#endif
 {
 	return (*((uchar *) (gd->env_addr + index)));
 }
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
 

how about #ifdef :).... many places we do have #if defined... ;).. saves a few bytes here and there.. :D

Quoted 20 lines
common/env_onenand.c +3 -0
+void onenand_env_relocate_spec(void)
+#else
 void env_relocate_spec(void)
+#endif
 {
 	unsigned long env_addr;
common/env_onenand.c +4 -0
 	int use_default = 0;
@@ -87,7 +103,11 @@ void env_relocate_spec(void)
 	gd->env_valid = 1;
 }
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int onenand_saveenv(void)
+#else
 int saveenv(void)
+#endif
 {
 	unsigned long env_addr = CONFIG_ENV_ADDR;
 	struct erase_info instr = {

common/env_onenand.c int saveenv(void) · line 125

Quoted 5 lines
common/env_onenand.c +0 -1
@@ -102,7 +122,6 @@ int saveenv(void)
 		printf("OneNAND: erase failed at 0x%08lx\n", env_addr);
 		return 1;
 	}
-
 

some one did not like empty lines? ;)

common/env_onenand.c int saveenv(void) · line 134

Quoted 9 lines
common/env_onenand.c +0 -0
 	/* update crc */
 	env_ptr->crc =
common/env_onenand.c +0 -1
 	    crc32(0, env_ptr->data, ONENAND_ENV_SIZE(onenand_mtd));
@@ -112,11 +131,14 @@ int saveenv(void)
 		printf("OneNAND: write failed at 0x%08x\n", instr.addr);
 		return 2;
 	}
-
 

some one did not like empty lines? ;)

Quoted 23 lines
common/env_onenand.c +4 -0
 	return 0;
 }
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int onenand_env_init(void)
+#else
 int env_init(void)
+#endif
 {
 	/* use default */
common/env_onenand.c +0 -0
 	gd->env_addr = (ulong) & default_environment[0];
cpu/arm_cortexa8/omap3/board.c +4 -0
index 7bb3e28..ba0eec6 100644
@@ -313,6 +313,19 @@ void abort(void)
 {
 }
 
+/******************************************************************************
+ * Routine: print_board_info
+ * Description: Displays cpu and memory information for the board
+ *****************************************************************************/

cpu/arm_cortexa8/omap3/board.c void abort(void) · line 329

Quoted 10 lines
cpu/arm_cortexa8/omap3/board.c +9 -0
+void print_board_info(void)
+{
+	u32 btype;
+
+	btype = get_board_type();
+
+	display_board_info(btype);
+}
+
 

I dont think this is related to this...

Quoted 117 lines
cpu/arm_cortexa8/omap3/board.c +0 -0
 #ifdef CONFIG_NAND_OMAP_GPMC
 /******************************************************************************

* OMAP3 specific command to switch between NAND HW and SW ecc

cpu/arm_cortexa8/omap3/mem.c +57 -2
index 3cc22c4..159ed87 100644
@@ -26,10 +26,12 @@
  */
 
 #include <common.h>
+#include <environment.h>
 #include <asm/io.h>
 #include <asm/arch/mem.h>
 #include <asm/arch/sys_proto.h>
 #include <command.h>
+#include <nand.h>
 
 /*
  * Only One NAND allowed on board at a time.
@@ -41,7 +43,21 @@ unsigned int boot_flash_sec;
 unsigned int boot_flash_type;
 volatile unsigned int boot_flash_env_addr;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern env_t *env_ptr;
+extern char *nand_env_name_spec;
+extern char *onenand_env_name_spec;
+extern env_t *nand_env_ptr;
+extern env_t *onenand_env_ptr;
+
+extern void onenand_init(void);
+extern int nand_scan_ident(struct mtd_info *mtd, int maxchips);
+#endif
+
 #if defined(CONFIG_CMD_NAND)
+u8 is_nand;
+extern nand_info_t nand_info[2];
+
 static u32 gpmc_m_nand[GPMC_MAX_REG] = {
 	M_NAND_GPMC_CONFIG1,
 	M_NAND_GPMC_CONFIG2,
@@ -63,6 +79,8 @@ gpmc_t *gpmc_cfg_base;
 #endif
 
 #if defined(CONFIG_CMD_ONENAND)
+u8 is_onenand;
+extern struct mtd_info onenand_mtd;
 static u32 gpmc_onenand[GPMC_MAX_REG] = {
 	ONENAND_GPMC_CONFIG1,
 	ONENAND_GPMC_CONFIG2,
@@ -84,6 +102,24 @@ gpmc_csx_t *onenand_cs_base;
 
 static sdrc_t *sdrc_base = (sdrc_t *)OMAP34XX_SDRC_BASE;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+char *env_name_spec;
+env_get_char_spec_p env_get_char_spec;
+env_init_p env_init;
+saveenv_p saveenv;
+env_relocate_spec_p env_relocate_spec;
+
+extern uchar nand_env_get_char_spec(int index);
+extern int nand_env_init(void);
+extern int nand_saveenv(void);
+extern void nand_env_relocate_spec(void);
+
+extern uchar onenand_env_get_char_spec(int index);
+extern int onenand_env_init(void);
+extern int onenand_saveenv(void);
+extern void onenand_env_relocate_spec(void);
+#endif /* CONFIG_ENV_IS_RUNTIME_SEL */
+
 /**************************************************************************
  * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
  *  command line mem=xyz use all memory with out discontinuous support
@@ -229,6 +265,7 @@ void gpmc_init(void)
 	u32 f_off = CONFIG_SYS_MONITOR_LEN;
 	u32 f_sec = 0;
 	u32 config = 0;
+	u32 gpmc_index = 0;
 
 	/* global settings */
 	writel(0, &gpmc_base->irqenable); /* isr's sources masked */
@@ -245,7 +282,7 @@ void gpmc_init(void)
 	writel(0, &gpmc_cs_base->config7);
 	sdelay(1000);
 
-#if defined(CONFIG_CMD_NAND)	/* CS 0 */
+#if defined(CONFIG_CMD_NAND) && !defined(CONFIG_ENV_IS_RUNTIME_SEL)
 	gpmc_config = gpmc_m_nand;
 	gpmc_cfg_base = gpmc_base;
 	nand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
@@ -264,7 +301,37 @@ void gpmc_init(void)
 #endif
 #endif
 
-#if defined(CONFIG_CMD_ONENAND)
+#if defined(CONFIG_CMD_NAND) && defined(CONFIG_ENV_IS_RUNTIME_SEL)
+	gpmc_config = gpmc_m_nand;
+	nand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
+			(gpmc_index * GPMC_CONFIG_WIDTH));
+	base = PISMO1_NAND_BASE;
+	size = PISMO1_NAND_SIZE;
+	enable_gpmc_config(gpmc_config, nand_cs_base, base, size);
+	/* NAND and/or ONENAND is to be scanned */
+	is_nand = 0;
+	nand_init();
+	if (nand_info[0].size) {
+		is_nand = 1;
+		f_off = SMNAND_ENV_OFFSET;
+		f_sec = SZ_128K;
+		/* env setup */
+		boot_flash_base = base;
+		boot_flash_off = f_off;
+		boot_flash_sec = f_sec;
+		boot_flash_env_addr = f_off;

cpu/arm_cortexa8/omap3/mem.c void gpmc_init(void) · line 332

Quoted 10 lines
cpu/arm_cortexa8/omap3/mem.c +9 -0
+
+		env_name_spec = nand_env_name_spec;
+		env_ptr = nand_env_ptr;
+		env_get_char_spec = nand_env_get_char_spec;
+		env_init = nand_env_init;
+		saveenv = nand_saveenv;
+		env_relocate_spec = nand_env_relocate_spec;
+		gpmc_index++;
+	}
 

with a change like above in a common omap3 file, you are essentially bottlenecking scalability to other OMAP3 platforms which use different NAND. Eg. we assume SZ_128K ;) kinda wrong rt? sector size is dependent on the nand device we plug in..

Quoted 8 lines
cpu/arm_cortexa8/omap3/mem.c +3 -0
+#endif
+
+#if defined(CONFIG_CMD_ONENAND) && !defined(CONFIG_ENV_IS_RUNTIME_SEL)
 	gpmc_config = gpmc_onenand;
 	onenand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
cpu/arm_cortexa8/omap3/mem.c +0 -0
 					(GPMC_CS * GPMC_CONFIG_WIDTH));
@@ -281,4 +348,33 @@ void gpmc_init(void)
 	boot_flash_env_addr = f_off;

cpu/arm_cortexa8/omap3/mem.c void gpmc_init(void) · line 358

Quoted 10 lines
cpu/arm_cortexa8/omap3/mem.c +7 -0
 #endif
 #endif
+
+#if defined(CONFIG_CMD_ONENAND) && defined(CONFIG_ENV_IS_RUNTIME_SEL)
+	gpmc_config = gpmc_onenand;
+	onenand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
+			(gpmc_index * GPMC_CONFIG_WIDTH));
+	base = PISMO1_ONEN_BASE;
+	size = PISMO1_ONEN_SIZE;
 

here.. PISMO? PISMO is a plugin Board on SDP and possibly EVM, but not true for other platforms.. :(

Quoted 56 lines
cpu/arm_cortexa8/omap3/mem.c +22 -0
+	enable_gpmc_config(gpmc_config, onenand_cs_base, base, size);
+	/* NAND and/or ONENAND is to be scanned */
+	is_onenand = 0;
+	onenand_init();
+	if (onenand_mtd.size) {
+		is_onenand = 1;
+		f_off = ONENAND_ENV_OFFSET;
+		f_sec = SZ_128K;
+		/* env setup */
+		boot_flash_base = base;
+		boot_flash_off = f_off;
+		boot_flash_sec = f_sec;
+		boot_flash_env_addr = f_off;
+		env_name_spec = onenand_env_name_spec;
+		env_ptr = onenand_env_ptr;
+		env_get_char_spec = onenand_env_get_char_spec;
+		env_init = onenand_env_init;
+		saveenv = onenand_saveenv;
+		env_relocate_spec = onenand_env_relocate_spec;
+		gpmc_index++;
+	}
+#endif

}

cpu/arm_cortexa8/omap3/sys_info.c +15 -3
index 28a1020..86cc95f 100644
@@ -36,6 +36,14 @@ static gpmc_csx_t *gpmc_cs_base = (gpmc_csx_t *)GPMC_CONFIG_CS0_BASE;
 static sdrc_t *sdrc_base = (sdrc_t *)OMAP34XX_SDRC_BASE;
 static ctrl_t *ctrl_base = (ctrl_t *)OMAP34XX_CTRL_BASE;
 
+#if defined(CONFIG_CMD_NAND)
+extern u8 is_nand;
+#endif
+
+#if defined(CONFIG_CMD_ONENAND)
+extern u8 is_onenand;
+#endif
+
 /******************************************
  * get_cpu_type(void) - extract cpu info
  ******************************************/
@@ -208,9 +216,22 @@ void display_board_info(u32 btype)
 
 
 	printf("OMAP%s-%s rev %d, CPU-OPP2 L3-165MHz\n", cpu_s,
-	       sec_s, get_cpu_rev());
-	printf("%s + %s/%s\n", sysinfo.board_string,
-	       mem_s, sysinfo.nand_string);
+		sec_s, get_cpu_rev());
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+		printf("%s + %s/", sysinfo.board_string,
+			mem_s);
+#if defined(CONFIG_CMD_NAND)
+	if (is_nand)
+		printf("%s\n", "NAND");

cpu/arm_cortexa8/omap3/sys_info.c void display_board_info(u32 btype) · line 235

Quoted 10 lines
cpu/arm_cortexa8/omap3/sys_info.c +9 -0
+#endif
+#if defined(CONFIG_CMD_ONENAND)
+	if (is_onenand)
+		printf("%s\n", "ONENAND");
+#endif
+#else
+		printf("%s + %s/%s\n", sysinfo.board_string,
+			mem_s, sysinfo.nand_string);
+#endif
 

I have this feel that we could improve this #ifdef mess.. using variables maybe?

Quoted 34 lines
cpu/arm_cortexa8/omap3/sys_info.c +0 -0
 }
 
include/common.h +9 -1
index b75ea60..fd3da2c 100644
@@ -243,12 +243,20 @@ extern ulong load_addr;		/* Default Load Address */
 void	doc_probe(unsigned long physadr);
 
 /* common/cmd_nvedit.c */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+typedef uchar (*env_get_char_spec_p)(int index);
+typedef int (*env_init_p)(void);
+typedef int (*saveenv_p)(void);
+typedef void (*env_relocate_spec_p)(void);
+#else
 int	env_init     (void);
+int     saveenv(void);
+#endif
 void	env_relocate (void);
 int	envmatch     (uchar *, int);
 char	*getenv	     (char *);
 int	getenv_r     (char *name, char *buf, unsigned len);
-int	saveenv	     (void);
+
 #ifdef CONFIG_PPC		/* ARM version to be fixed! */
 int inline setenv   (char *, char *);
 #else
include/configs/omap3_evm.h +0 -0
index f4498a9..bf5614e 100644

include/configs/omap3_evm.h line 111

Quoted 5 lines
include/configs/omap3_evm.h +1 -0
@@ -107,6 +107,7 @@
 #define CONFIG_CMD_I2C		/* I2C serial bus support	*/
 #define CONFIG_CMD_MMC		/* MMC support			*/
 #define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#define CONFIG_CMD_NAND		/* NAND support                 */
 

please move this to some other patch.. not relevant here..

Quoted 64 lines
include/configs/omap3_evm.h +4 -1
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING
@@ -125,12 +126,15 @@
 /*
  * Board NAND Info.
  */
+#define CONFIG_NAND_OMAP_GPMC
 #define CONFIG_SYS_NAND_ADDR		NAND_BASE	/* physical address */
 							/* to access nand */
 #define CONFIG_SYS_NAND_BASE		NAND_BASE	/* physical address */
 							/* to access */
 							/* nand at CS0 */
 
+#define GPMC_NAND_ECC_LP_x16_LAYOUT     1
+
 #define CONFIG_SYS_MAX_NAND_DEVICE	1		/* Max number of */
 							/* NAND devices */
 #define SECTORSIZE			512
@@ -271,7 +275,7 @@
 #define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
 
-#define CONFIG_ENV_IS_IN_ONENAND	1
+#define CONFIG_ENV_IS_RUNTIME_SEL	1
 #define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
 #define SMNAND_ENV_OFFSET		0x260000 /* environment starts here */
 
lib_arm/board.c +10 -0
index 09eaaf2..9a0c285 100644
@@ -60,6 +60,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern void gpmc_init(void);
+extern void print_board_info(void);
+#endif
+
 #ifdef CONFIG_HAS_DATAFLASH
 extern int  AT91F_DataflashInit(void);
 extern void dataflash_print_info(void);
@@ -259,12 +264,17 @@ static int arm_pci_init(void)
 typedef int (init_fnc_t) (void);
 
 int print_cpuinfo (void); /* test-only */
+extern env_init_p env_init;
 
 init_fnc_t *init_sequence[] = {
 	cpu_init,		/* basic cpu dependent setup */
 	board_init,		/* basic board dependent setup */
 	interrupt_init,		/* set up exceptions */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+	NULL,			/* initialize environment */
+#else
 	env_init,		/* initialize environment */
+#endif
 	init_baudrate,		/* initialze baudrate settings */
 	serial_init,		/* serial communications setup */
 	console_init_f,		/* stage 1 init of console */
@@ -350,13 +360,14 @@ void start_armboot (void)
 	/* armboot_start is defined in the board-specific linker script */

lib_arm/board.c void start_armboot (void) · line 363

Quoted 10 lines
lib_arm/board.c +0 -7
 	mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN);
 
-#if defined(CONFIG_CMD_NAND)
-	puts ("NAND:  ");
-	nand_init();		/* go init the NAND */
-#endif
-
-#if defined(CONFIG_CMD_ONENAND)
-	onenand_init();
 

well.. my nand and onenand init dissapeared... :( not the way to di it I guess..

lib_arm/board.c void start_armboot (void) · line 372

Quoted 3 lines
lib_arm/board.c +2 -0
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+	gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
 

Wooooaaah.. gpmc is TI OMAP2 or OMAP3 only.... NOT in other ARM or PPC or other platforms.. NAK on this.

Quoted 10 lines
lib_arm/board.c +6 -0
+	env_init();
+	init_baudrate();        /* initialze baudrate settings */
+	serial_init();          /* serial communications setup */
+	console_init_f();       /* stage 1 init of console */
+	display_banner();
+	print_board_info();
 #endif

#ifdef CONFIG_HAS_DATAFLASH

Regards,
Nishanth Menon

#2 lore raw

PATCH 1/1 Changes for single binary image for u-boot for NAND/OneNAND flash.

Hi,

Pls find my comments below

Quoted 15 lines

-----Original Message-----
From: Nishanth Menon [mailto:menon.nishanth at gmail.com]
Sent: Tuesday, March 03, 2009 2:03 PM
To: Pillai, Manikandan
Cc: u-boot at lists.denx.de; dirk.behme at googlemail.com
Subject: Re: [U-Boot] [PATCH 1/1] Changes for single binary image for u-boot for NAND/OneNAND flash.

Manikandan Pillai said the following on 03/03/2009 05:41 AM:

Quoted 6 lines

Support for single binary image for NAND/OneNAND based OMAP3 EVM boards. The software has to set the flag CONFIG_ENV_IS_RUNTIME_SEL in include/configs/omap3_evm.h. The software is able to detect whether it is NAND or OneNAND flash at runtime. The flash detected is set as the environment store also.

Quoted 6 lines

makes sense for SDP also.. in SDP3430, we have NOR,OneNAND,NAND and MMC as possible boot devices. :(
Could you please split this patch into two:
a) changes to generic files
b) changes specific to omap.
it is easier to review that way..

[Pillai, Manikandan] OK

Quoted 90 lines
Quoted 12 lines

As per the comments received, the change is done only for OMAP3 EVM.

---
 board/omap3/evm/evm.c             |    2 +
 common/Makefile                   |    1 +
 common/cmd_nvedit.c               |    5 ++
 common/env_common.c               |    8 +++-
 common/env_nand.c                 |   33 +++++++++++-
 common/env_onenand.c              |   26 +++++++++-
 cpu/arm_cortexa8/omap3/board.c    |   13 +++++
 cpu/arm_cortexa8/omap3/mem.c      |  100

++++++++++++++++++++++++++++++++++++-

Quoted 37 lines
 cpu/arm_cortexa8/omap3/sys_info.c |   27 +++++++++-
 include/common.h                  |   10 +++-
 include/configs/omap3_evm.h       |    6 ++-
 lib_arm/board.c                   |   25 +++++++---
 12 files changed, 237 insertions(+), 19 deletions(-)
board/omap3/evm/evm.c +2 -0
index b406312..9924432 100644
@@ -44,7 +44,9 @@ int board_init(void)
 {
    DECLARE_GLOBAL_DATA_PTR;
 
+#if !defined(CONFIG_ENV_IS_RUNTIME_SEL)
    gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
+#endif
    /* board id for Linux */
    gd->bd->bi_arch_number = MACH_TYPE_OMAP3EVM;
    /* boot param addr */
common/Makefile +1 -0
index f13cd11..a6c55d2 100644
@@ -58,6 +58,7 @@ COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o
 COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
 COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
 COBJS-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
+COBJS-$(CONFIG_ENV_IS_RUNTIME_SEL) += env_onenand.o env_nand.o
 
 # command
 COBJS-$(CONFIG_CMD_AMBAPP) += cmd_ambapp.o
common/cmd_nvedit.c +0 -0
index 68c673e..628bcf4 100644

common/cmd_nvedit.c DECLARE_GLOBAL_DATA_PTR; · line 64

Quoted 6 lines
common/cmd_nvedit.c +1 -0
@@ -59,6 +59,7 @@ DECLARE_GLOBAL_DATA_PTR;
     !defined(CONFIG_ENV_IS_IN_NAND)        && \
     !defined(CONFIG_ENV_IS_IN_ONENAND)     && \
     !defined(CONFIG_ENV_IS_IN_SPI_FLASH)   && \
+    !defined(CONFIG_ENV_IS_RUNTIME_SEL)    && \
     !defined(CONFIG_ENV_IS_NOWHERE)
 # error Define one of

CONFIG_ENV_IS_IN_{NVRAM|EEPROM|FLASH|DATAFLASH|ONENAND|SPI_FLASH|NOWHERE}

Quoted 33 lines
common/cmd_nvedit.c +4 -0
 #endif
@@ -66,6 +67,10 @@ DECLARE_GLOBAL_DATA_PTR;
 #define XMK_STR(x) #x
 #define MK_STR(x)  XMK_STR(x)
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern saveenv_p saveenv;
+#endif
+
 /************************************************************************
 ************************************************************************/
 
common/env_common.c +5 -0
index 6be3bb0..b692900 100644
@@ -46,8 +46,13 @@ DECLARE_GLOBAL_DATA_PTR;
 
 extern env_t *env_ptr;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern env_get_char_spec_p env_get_char_spec;
+extern env_relocate_spec_p env_relocate_spec;
+#else
 extern void env_relocate_spec (void);
 extern uchar env_get_char_spec(int);
+#endif
 
 static uchar env_get_char_init (int index);
 
@@ -140,7 +145,8 @@ uchar default_environment[] = {
 };
 
Quoted 7 lines

common/env_common.c uchar default_environment[] = { · line 147

Quoted 1 line
common/env_common.c +0 -0
 #if defined(CONFIG_ENV_IS_IN_NAND)         /* Environment is in Nand

Flash */ \

common/env_common.c uchar default_environment[] = { · line 152

Quoted 4 lines
common/env_common.c +2 -1
-   || defined(CONFIG_ENV_IS_IN_SPI_FLASH)
+   || defined(CONFIG_ENV_IS_IN_SPI_FLASH) \
+   || (defined(CONFIG_CMD_NAND) && defined(CONFIG_ENV_IS_RUNTIME_SEL))
 

Errr.... ENV_IS_IN_NAND Vs ENV_IS_RUNTIME_SEL is not clear.

[Pillai, Manikandan] I am not clear with the query

Quoted 12 lines
Quoted 12 lines
common/env_common.c +0 -0
 int default_environment_size = sizeof(default_environment);
 #endif
common/env_nand.c +0 -0
index 76569da..add74c2 100644
@@ -65,17 +65,22 @@ int nand_legacy_rw (struct nand_chip* nand, int cmd,
 extern uchar default_environment[];
 extern int default_environment_size;
 
Quoted 4 lines

common/env_nand.c int nand_legacy_rw (struct nand_chip* nand, int cmd, · line 73

Quoted 3 lines
common/env_nand.c +2 -0
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+char *nand_env_name_spec = "NAND";
 

I suppose we might want a README.runtime_env to understand it's usage..

[Pillai, Manikandan] OK

Quoted 106 lines
Quoted 80 lines
common/env_nand.c +5 -2
+#else
 char * env_name_spec = "NAND";
-
+#endif
 
 #ifdef ENV_IS_EMBEDDED
 extern uchar environment[];
 env_t *env_ptr = (env_t *)(&environment[0]);
+#elif defined(CONFIG_ENV_IS_RUNTIME_SEL)
+env_t *nand_env_ptr;
+env_t *env_ptr;
 #else /* ! ENV_IS_EMBEDDED */
 env_t *env_ptr = 0;
 #endif /* ENV_IS_EMBEDDED */
 
-
 /* local functions */
 #if !defined(ENV_IS_EMBEDDED)

static void use_default(void);

common/env_nand.c +20 -0
@@ -83,7 +88,11 @@ static void use_default(void);
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+uchar nand_env_get_char_spec(int index)
+#else
 uchar env_get_char_spec (int index)
+#endif
 {
    return ( *((uchar *)(gd->env_addr + index)) );
 }
@@ -100,7 +109,11 @@ uchar env_get_char_spec (int index)
  * the SPL loads not only the U-Boot image from NAND but also the
  * environment.
  */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int nand_env_init(void)
+#else
 int env_init(void)
+#endif
 {
 #if defined(ENV_IS_EMBEDDED)
    size_t total;
@@ -181,7 +194,11 @@ int writeenv(size_t offset, u_char *buf)
    return 0;
 }
 #ifdef CONFIG_ENV_OFFSET_REDUND
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int nand_saveenv(void)
+#else
 int saveenv(void)
+#endif
 {
    size_t total;
    int ret = 0;
@@ -224,7 +241,11 @@ int saveenv(void)
    return ret;
 }
 #else /* ! CONFIG_ENV_OFFSET_REDUND */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int nand_saveenv(void)
+#else
 int saveenv(void)
+#endif
 {
    size_t total;
    int ret = 0;
@@ -284,7 +305,11 @@ int readenv (size_t offset, u_char * buf)
 }
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+void nand_env_relocate_spec(void)
+#else
 void env_relocate_spec (void)
+#endif
 {
 #if !defined(ENV_IS_EMBEDDED)
    size_t total;

common/env_nand.c void env_relocate_spec (void) · line 368

Quoted 1 line
common/env_nand.c +0 -0
@@ -343,7 +368,11 @@ void env_relocate_spec (void)
  * The legacy NAND code saved the environment in the first NAND device

i.e.,

Quoted 24 lines
common/env_nand.c +4 -0
  * nand_dev_desc + 0. This is also the behaviour using the new NAND code.
  */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+void nand_env_relocate_spec(void)
+#else
 void env_relocate_spec (void)
+#endif
 {
 #if !defined(ENV_IS_EMBEDDED)
    int ret;
common/env_onenand.c +4 -0
index dbccc79..7aaa83c 100644
@@ -39,11 +39,19 @@ extern uchar default_environment[];
 
 #define ONENAND_ENV_SIZE(mtd)      (mtd.writesize - ENV_HEADER_SIZE)
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+char *onenand_env_name_spec = "OneNAND";
+#else
 char *env_name_spec = "OneNAND";
+#endif
 
Quoted 10 lines

common/env_onenand.c extern uchar default_environment[];

Quoted 9 lines
common/env_onenand.c +4 -0
 #ifdef ENV_IS_EMBEDDED
 extern uchar environment[];
 env_t *env_ptr = (env_t *) (&environment[0]);
+#elif defined(CONFIG_ENV_IS_RUNTIME_SEL)
+static unsigned char onenand_env[MAX_ONENAND_PAGESIZE];
+env_t *onenand_env_ptr = (env_t *)&onenand_env[0];
+extern env_t *env_ptr;
 #else /* ! ENV_IS_EMBEDDED */
 

and NOT CONFIG_ENV_IS_RUNTIME_SEL...

[Pillai, Manikandan] OK

Quoted 15 lines
Quoted 15 lines
common/env_onenand.c +0 -0
 static unsigned char onenand_env[MAX_ONENAND_PAGESIZE];

env_t *env_ptr = (env_t *) onenand_env;

common/env_onenand.c +4 -0
@@ -51,12 +59,20 @@ env_t *env_ptr = (env_t *) onenand_env;
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+uchar onenand_env_get_char_spec(int index)
+#else
 uchar env_get_char_spec(int index)
+#endif
 {
    return (*((uchar *) (gd->env_addr + index)));
 }
 
Quoted 4 lines

common/env_onenand.c env_t *env_ptr = (env_t *) onenand_env; · line 72

Quoted 2 lines
common/env_onenand.c +1 -0
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
 

how about #ifdef :).... many places we do have #if defined... ;).. saves a few bytes here and there.. :D

[Pillai, Manikandan] OK

Quoted 62 lines
Quoted 20 lines
common/env_onenand.c +3 -0
+void onenand_env_relocate_spec(void)
+#else
 void env_relocate_spec(void)
+#endif
 {
    unsigned long env_addr;
    int use_default = 0;
common/env_onenand.c +4 -0
@@ -87,7 +103,11 @@ void env_relocate_spec(void)
    gd->env_valid = 1;
 }
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int onenand_saveenv(void)
+#else
 int saveenv(void)
+#endif
 {
    unsigned long env_addr = CONFIG_ENV_ADDR;
    struct erase_info instr = {

common/env_onenand.c int saveenv(void) · line 125

Quoted 5 lines
common/env_onenand.c +0 -1
@@ -102,7 +122,6 @@ int saveenv(void)
            printf("OneNAND: erase failed at 0x%08lx\n", env_addr);
            return 1;
    }
-
 

some one did not like empty lines? ;)

common/env_onenand.c int saveenv(void) · line 134

Quoted 9 lines
common/env_onenand.c +0 -0
    /* update crc */
    env_ptr->crc =
        crc32(0, env_ptr->data, ONENAND_ENV_SIZE(onenand_mtd));
common/env_onenand.c +0 -1
@@ -112,11 +131,14 @@ int saveenv(void)
            printf("OneNAND: write failed at 0x%08x\n", instr.addr);
            return 2;
    }
-
 

some one did not like empty lines? ;)

Quoted 16 lines
common/env_onenand.c +4 -0
    return 0;
 }
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+int onenand_env_init(void)
+#else
 int env_init(void)
+#endif
 {
    /* use default */
    gd->env_addr = (ulong) & default_environment[0];
cpu/arm_cortexa8/omap3/board.c +0 -0
index 7bb3e28..ba0eec6 100644

cpu/arm_cortexa8/omap3/board.c void abort(void) · line 316

Quoted 4 lines
cpu/arm_cortexa8/omap3/board.c +0 -0
@@ -313,6 +313,19 @@ void abort(void)
 {
 }
 
 

+/**************************************************************************** **

cpu/arm_cortexa8/omap3/board.c void abort(void) · line 323

Quoted 3 lines
cpu/arm_cortexa8/omap3/board.c +3 -0
+ * Routine: print_board_info
+ * Description: Displays cpu and memory information for the board
+

*****************************************************************************/

Quoted 11 lines

cpu/arm_cortexa8/omap3/board.c void abort(void)

Quoted 10 lines
cpu/arm_cortexa8/omap3/board.c +9 -0
+void print_board_info(void)
+{
+   u32 btype;
+
+   btype = get_board_type();
+
+   display_board_info(btype);
+}
+
 

I dont think this is related to this...

[Pillai, Manikandan] The default EVM support does not have NAND. To build only For NAND, you need to enable this. I can put this in a separate patch in a series.

Quoted 125 lines

cpu/arm_cortexa8/omap3/board.c void abort(void) · line 329

Quoted 2 lines
cpu/arm_cortexa8/omap3/board.c +0 -0
 #ifdef CONFIG_NAND_OMAP_GPMC

/***************************************************************************** *

Quoted 121 lines
cpu/arm_cortexa8/omap3/board.c +0 -0
  * OMAP3 specific command to switch between NAND HW and SW ecc
cpu/arm_cortexa8/omap3/mem.c +63 -2
index 3cc22c4..159ed87 100644
@@ -26,10 +26,12 @@
  */
 
 #include <common.h>
+#include <environment.h>
 #include <asm/io.h>
 #include <asm/arch/mem.h>
 #include <asm/arch/sys_proto.h>
 #include <command.h>
+#include <nand.h>
 
 /*
  * Only One NAND allowed on board at a time.
@@ -41,7 +43,21 @@ unsigned int boot_flash_sec;
 unsigned int boot_flash_type;
 volatile unsigned int boot_flash_env_addr;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern env_t *env_ptr;
+extern char *nand_env_name_spec;
+extern char *onenand_env_name_spec;
+extern env_t *nand_env_ptr;
+extern env_t *onenand_env_ptr;
+
+extern void onenand_init(void);
+extern int nand_scan_ident(struct mtd_info *mtd, int maxchips);
+#endif
+
 #if defined(CONFIG_CMD_NAND)
+u8 is_nand;
+extern nand_info_t nand_info[2];
+
 static u32 gpmc_m_nand[GPMC_MAX_REG] = {
    M_NAND_GPMC_CONFIG1,
    M_NAND_GPMC_CONFIG2,
@@ -63,6 +79,8 @@ gpmc_t *gpmc_cfg_base;
 #endif
 
 #if defined(CONFIG_CMD_ONENAND)
+u8 is_onenand;
+extern struct mtd_info onenand_mtd;
 static u32 gpmc_onenand[GPMC_MAX_REG] = {
    ONENAND_GPMC_CONFIG1,
    ONENAND_GPMC_CONFIG2,
@@ -84,6 +102,24 @@ gpmc_csx_t *onenand_cs_base;
 
 static sdrc_t *sdrc_base = (sdrc_t *)OMAP34XX_SDRC_BASE;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+char *env_name_spec;
+env_get_char_spec_p env_get_char_spec;
+env_init_p env_init;
+saveenv_p saveenv;
+env_relocate_spec_p env_relocate_spec;
+
+extern uchar nand_env_get_char_spec(int index);
+extern int nand_env_init(void);
+extern int nand_saveenv(void);
+extern void nand_env_relocate_spec(void);
+
+extern uchar onenand_env_get_char_spec(int index);
+extern int onenand_env_init(void);
+extern int onenand_saveenv(void);
+extern void onenand_env_relocate_spec(void);
+#endif /* CONFIG_ENV_IS_RUNTIME_SEL */
+
 /**************************************************************************
  * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
  *  command line mem=xyz use all memory with out discontinuous support
@@ -229,6 +265,7 @@ void gpmc_init(void)
    u32 f_off = CONFIG_SYS_MONITOR_LEN;
    u32 f_sec = 0;
    u32 config = 0;
+   u32 gpmc_index = 0;
 
    /* global settings */
    writel(0, &gpmc_base->irqenable); /* isr's sources masked */
@@ -245,7 +282,7 @@ void gpmc_init(void)
    writel(0, &gpmc_cs_base->config7);
    sdelay(1000);
 
-#if defined(CONFIG_CMD_NAND)       /* CS 0 */
+#if defined(CONFIG_CMD_NAND) && !defined(CONFIG_ENV_IS_RUNTIME_SEL)
    gpmc_config = gpmc_m_nand;
    gpmc_cfg_base = gpmc_base;
    nand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
@@ -264,7 +301,37 @@ void gpmc_init(void)
 #endif
 #endif
 
-#if defined(CONFIG_CMD_ONENAND)
+#if defined(CONFIG_CMD_NAND) && defined(CONFIG_ENV_IS_RUNTIME_SEL)
+   gpmc_config = gpmc_m_nand;
+   nand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
+                   (gpmc_index * GPMC_CONFIG_WIDTH));
+   base = PISMO1_NAND_BASE;
+   size = PISMO1_NAND_SIZE;
+   enable_gpmc_config(gpmc_config, nand_cs_base, base, size);
+   /* NAND and/or ONENAND is to be scanned */
+   is_nand = 0;
+   nand_init();
+   if (nand_info[0].size) {
+           is_nand = 1;
+           f_off = SMNAND_ENV_OFFSET;
+           f_sec = SZ_128K;
+           /* env setup */
+           boot_flash_base = base;
+           boot_flash_off = f_off;
+           boot_flash_sec = f_sec;
+           boot_flash_env_addr = f_off;
+
+           env_name_spec = nand_env_name_spec;
+           env_ptr = nand_env_ptr;
+           env_get_char_spec = nand_env_get_char_spec;
+           env_init = nand_env_init;
+           saveenv = nand_saveenv;
Quoted 8 lines

cpu/arm_cortexa8/omap3/mem.c void gpmc_init(void)

Quoted 4 lines
cpu/arm_cortexa8/omap3/mem.c +3 -0
+           env_relocate_spec = nand_env_relocate_spec;
+           gpmc_index++;
+   }
 

with a change like above in a common omap3 file, you are essentially bottlenecking scalability to other OMAP3 platforms which use different NAND. Eg. we assume SZ_128K ;) kinda wrong rt? sector size is dependent on the nand device we plug in..

[Pillai, Manikandan] I can plug out the initialization stuff and put it in a board dependent file and invoke the same from the common omap3 locations for the type of board.

Quoted 82 lines
Quoted 8 lines
cpu/arm_cortexa8/omap3/mem.c +3 -0
+#endif
+
+#if defined(CONFIG_CMD_ONENAND) && !defined(CONFIG_ENV_IS_RUNTIME_SEL)
    gpmc_config = gpmc_onenand;
    onenand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
                                    (GPMC_CS * GPMC_CONFIG_WIDTH));
cpu/arm_cortexa8/omap3/mem.c +0 -0
@@ -281,4 +348,33 @@ void gpmc_init(void)
    boot_flash_env_addr = f_off;

cpu/arm_cortexa8/omap3/mem.c void gpmc_init(void) · line 358

Quoted 10 lines
cpu/arm_cortexa8/omap3/mem.c +7 -0
 #endif
 #endif
+
+#if defined(CONFIG_CMD_ONENAND) && defined(CONFIG_ENV_IS_RUNTIME_SEL)
+   gpmc_config = gpmc_onenand;
+   onenand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
+                   (gpmc_index * GPMC_CONFIG_WIDTH));
+   base = PISMO1_ONEN_BASE;
+   size = PISMO1_ONEN_SIZE;
 

here.. PISMO? PISMO is a plugin Board on SDP and possibly EVM, but not true for other platforms.. :(

Quoted 23 lines
cpu/arm_cortexa8/omap3/mem.c +22 -0
+   enable_gpmc_config(gpmc_config, onenand_cs_base, base, size);
+   /* NAND and/or ONENAND is to be scanned */
+   is_onenand = 0;
+   onenand_init();
+   if (onenand_mtd.size) {
+           is_onenand = 1;
+           f_off = ONENAND_ENV_OFFSET;
+           f_sec = SZ_128K;
+           /* env setup */
+           boot_flash_base = base;
+           boot_flash_off = f_off;
+           boot_flash_sec = f_sec;
+           boot_flash_env_addr = f_off;
+           env_name_spec = onenand_env_name_spec;
+           env_ptr = onenand_env_ptr;
+           env_get_char_spec = onenand_env_get_char_spec;
+           env_init = onenand_env_init;
+           saveenv = onenand_saveenv;
+           env_relocate_spec = onenand_env_relocate_spec;
+           gpmc_index++;
+   }
+#endif

}

Review

Quoted 1 line
(quoted diff) +0 -0

b/cpu/arm_cortexa8/omap3/sys_info.c

cpu/arm_cortexa8/omap3/sys_info.c static gpmc_csx_t *gpmc_cs_base = (gpmc_csx_t

Quoted 4 lines

index 28a1020..86cc95f 100644

cpu/arm_cortexa8/omap3/sys_info.c +0 -0
@@ -36,6 +36,14 @@ static gpmc_csx_t *gpmc_cs_base = (gpmc_csx_t

*)GPMC_CONFIG_CS0_BASE;

Quoted 32 lines
cpu/arm_cortexa8/omap3/sys_info.c +19 -3
 static sdrc_t *sdrc_base = (sdrc_t *)OMAP34XX_SDRC_BASE;
 static ctrl_t *ctrl_base = (ctrl_t *)OMAP34XX_CTRL_BASE;
 
+#if defined(CONFIG_CMD_NAND)
+extern u8 is_nand;
+#endif
+
+#if defined(CONFIG_CMD_ONENAND)
+extern u8 is_onenand;
+#endif
+
 /******************************************
  * get_cpu_type(void) - extract cpu info
  ******************************************/
@@ -208,9 +216,22 @@ void display_board_info(u32 btype)
 
 
    printf("OMAP%s-%s rev %d, CPU-OPP2 L3-165MHz\n", cpu_s,
-          sec_s, get_cpu_rev());
-   printf("%s + %s/%s\n", sysinfo.board_string,
-          mem_s, sysinfo.nand_string);
+           sec_s, get_cpu_rev());
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+           printf("%s + %s/", sysinfo.board_string,
+                   mem_s);
+#if defined(CONFIG_CMD_NAND)
+   if (is_nand)
+           printf("%s\n", "NAND");
+#endif
+#if defined(CONFIG_CMD_ONENAND)
+   if (is_onenand)
+           printf("%s\n", "ONENAND");
Quoted 8 lines

cpu/arm_cortexa8/omap3/sys_info.c void display_board_info(u32 btype) · line 235

Quoted 6 lines
cpu/arm_cortexa8/omap3/sys_info.c +5 -0
+#endif
+#else
+           printf("%s + %s/%s\n", sysinfo.board_string,
+                   mem_s, sysinfo.nand_string);
+#endif
 

I have this feel that we could improve this #ifdef mess.. using variables maybe?

[Pillai, Manikandan] other suggestions welcome Personally, I felt here the #ifdef is not so dirty.

Quoted 107 lines

include/common.h extern ulong load_addr; /* Default Load Address

Quoted 8 lines
cpu/arm_cortexa8/omap3/sys_info.c +0 -0
 }
 
include/common.h +0 -0
index b75ea60..fd3da2c 100644
@@ -243,12 +243,20 @@ extern ulong load_addr;               /* Default Load Address

*/

Quoted 26 lines
include/common.h +9 -1
 void       doc_probe(unsigned long physadr);
 
 /* common/cmd_nvedit.c */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+typedef uchar (*env_get_char_spec_p)(int index);
+typedef int (*env_init_p)(void);
+typedef int (*saveenv_p)(void);
+typedef void (*env_relocate_spec_p)(void);
+#else
 int        env_init     (void);
+int     saveenv(void);
+#endif
 void       env_relocate (void);
 int        envmatch     (uchar *, int);
 char       *getenv      (char *);
 int        getenv_r     (char *name, char *buf, unsigned len);
-int        saveenv      (void);
+
 #ifdef CONFIG_PPC          /* ARM version to be fixed! */
 int inline setenv   (char *, char *);
 #else
include/configs/omap3_evm.h +0 -0
index f4498a9..bf5614e 100644

include/configs/omap3_evm.h line 111

Quoted 5 lines
include/configs/omap3_evm.h +1 -0
@@ -107,6 +107,7 @@
 #define CONFIG_CMD_I2C             /* I2C serial bus support       */
 #define CONFIG_CMD_MMC             /* MMC support                  */
 #define CONFIG_CMD_ONENAND /* ONENAND support              */
+#define CONFIG_CMD_NAND            /* NAND support                 */
 

please move this to some other patch.. not relevant here..

Quoted 66 lines
include/configs/omap3_evm.h +4 -1
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING
@@ -125,12 +126,15 @@
 /*
  * Board NAND Info.
  */
+#define CONFIG_NAND_OMAP_GPMC
 #define CONFIG_SYS_NAND_ADDR               NAND_BASE       /* physical address */
                                                    /* to access nand */
 #define CONFIG_SYS_NAND_BASE               NAND_BASE       /* physical address */
                                                    /* to access */
                                                    /* nand at CS0 */
 
+#define GPMC_NAND_ECC_LP_x16_LAYOUT     1
+
 #define CONFIG_SYS_MAX_NAND_DEVICE 1               /* Max number of */
                                                    /* NAND devices */
 #define SECTORSIZE                 512
@@ -271,7 +275,7 @@
 #define CONFIG_SYS_MONITOR_BASE            CONFIG_SYS_FLASH_BASE
 #define CONFIG_SYS_ONENAND_BASE            ONENAND_MAP
 
-#define CONFIG_ENV_IS_IN_ONENAND   1
+#define CONFIG_ENV_IS_RUNTIME_SEL  1
 #define ONENAND_ENV_OFFSET         0x260000 /* environment starts here */
 #define SMNAND_ENV_OFFSET          0x260000 /* environment starts here */
 
lib_arm/board.c +10 -0
index 09eaaf2..9a0c285 100644
@@ -60,6 +60,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
 
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+extern void gpmc_init(void);
+extern void print_board_info(void);
+#endif
+
 #ifdef CONFIG_HAS_DATAFLASH
 extern int  AT91F_DataflashInit(void);
 extern void dataflash_print_info(void);
@@ -259,12 +264,17 @@ static int arm_pci_init(void)
 typedef int (init_fnc_t) (void);
 
 int print_cpuinfo (void); /* test-only */
+extern env_init_p env_init;
 
 init_fnc_t *init_sequence[] = {
    cpu_init,               /* basic cpu dependent setup */
    board_init,             /* basic board dependent setup */
    interrupt_init,         /* set up exceptions */
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+   NULL,                   /* initialize environment */
+#else
    env_init,               /* initialize environment */
+#endif
    init_baudrate,          /* initialze baudrate settings */
    serial_init,            /* serial communications setup */
    console_init_f,         /* stage 1 init of console */
@@ -350,13 +360,14 @@ void start_armboot (void)
    /* armboot_start is defined in the board-specific linker script */
    mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN);
 
Quoted 10 lines

lib_arm/board.c void start_armboot (void) · line 372

Quoted 8 lines
lib_arm/board.c +0 -7
-#if defined(CONFIG_CMD_NAND)
-   puts ("NAND:  ");
-   nand_init();            /* go init the NAND */
-#endif
-
-#if defined(CONFIG_CMD_ONENAND)
-   onenand_init();
 

well.. my nand and onenand init dissapeared... :( not the way to di it I guess..

[Pillai, Manikandan] OK agreed. It was a miss.

Quoted 5 lines

lib_arm/board.c void start_armboot (void) · line 372

Quoted 3 lines
lib_arm/board.c +2 -0
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+   gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
 

Wooooaaah.. gpmc is TI OMAP2 or OMAP3 only.... NOT in other ARM or PPC or other platforms.. NAK on this.

[Pillai, Manikandan] Got your point. But I don't have a solution to this Since I EVM is doing a scan, it requires the gpmc_init to be called late. An option is to have another function board_init_late() which can be used to called gpmc_init_late().

Quoted 13 lines
Quoted 10 lines
lib_arm/board.c +6 -0
+   env_init();
+   init_baudrate();        /* initialze baudrate settings */
+   serial_init();          /* serial communications setup */
+   console_init_f();       /* stage 1 init of console */
+   display_banner();
+   print_board_info();
 #endif

#ifdef CONFIG_HAS_DATAFLASH

Regards,
Nishanth Menon

#3 lore raw

PATCH 1/1 Changes for single binary image for u-boot for NAND/OneNAND flash.

Pillai, Manikandan said the following on 03/04/2009 08:35 AM:

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

#if defined(CONFIG_ENV_IS_IN_NAND) /* Environment is in Nand

Flash */ \

Quoted 10 lines
Quoted 7 lines

common/env_common.c uchar default_environment[] = { · line 149

Quoted 5 lines
common/env_common.c +2 -1
-   || defined(CONFIG_ENV_IS_IN_SPI_FLASH)
+   || defined(CONFIG_ENV_IS_IN_SPI_FLASH) \
+   || (defined(CONFIG_CMD_NAND) && defined(CONFIG_ENV_IS_RUNTIME_SEL))

Errr.... ENV_IS_IN_NAND Vs ENV_IS_RUNTIME_SEL is not clear.

[Pillai, Manikandan] I am not clear with the query

CONFIG_ENV_IS_RUNTIME_SEL is dependent only on CMD_NAND? if I had onenand and NOR, then what?

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
cpu/arm_cortexa8/omap3/board.c +4 -0
+void print_board_info(void)
+{
+   u32 btype;
+
Quoted 9 lines

cpu/arm_cortexa8/omap3/board.c void abort(void) · line 328

Quoted 7 lines
cpu/arm_cortexa8/omap3/board.c +5 -0
+   btype = get_board_type();
+
+   display_board_info(btype);
+}
+

I dont think this is related to this...

Quoted 4 lines

[Pillai, Manikandan] The default EVM support does not have NAND. To build only For NAND, you need to enable this. I can put this in a separate patch in a series.

my comment -> move this as a seperate patch.. this patch seems to mix up things doing different things and confusing for a review.

Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
cpu/arm_cortexa8/omap3/mem.c +26 -1
-#if defined(CONFIG_CMD_ONENAND)
+#if defined(CONFIG_CMD_NAND) && defined(CONFIG_ENV_IS_RUNTIME_SEL)
+   gpmc_config = gpmc_m_nand;
+   nand_cs_base = (gpmc_csx_t *)(GPMC_CONFIG_CS0_BASE +
+                   (gpmc_index * GPMC_CONFIG_WIDTH));
+   base = PISMO1_NAND_BASE;
+   size = PISMO1_NAND_SIZE;
+   enable_gpmc_config(gpmc_config, nand_cs_base, base, size);
+   /* NAND and/or ONENAND is to be scanned */
+   is_nand = 0;
+   nand_init();
+   if (nand_info[0].size) {
+           is_nand = 1;
+           f_off = SMNAND_ENV_OFFSET;
+           f_sec = SZ_128K;
+           /* env setup */
+           boot_flash_base = base;
+           boot_flash_off = f_off;
+           boot_flash_sec = f_sec;
+           boot_flash_env_addr = f_off;
+
+           env_name_spec = nand_env_name_spec;
+           env_ptr = nand_env_ptr;
+           env_get_char_spec = nand_env_get_char_spec;
+           env_init = nand_env_init;
+           saveenv = nand_saveenv;
+           env_relocate_spec = nand_env_relocate_spec;
Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +2 -0
+           gpmc_index++;
+   }

with a change like above in a common omap3 file, you are essentially bottlenecking scalability to other OMAP3 platforms which use different NAND. Eg. we assume SZ_128K ;) kinda wrong rt? sector size is dependent on the nand device we plug in..

Quoted 5 lines

[Pillai, Manikandan] I can plug out the initialization stuff and put it in a board dependent file and invoke the same from the common omap3 locations for the type of board.

that might be a nice idea.. will look for your changes.. :)

Quoted 25 lines
Quoted 16 lines
Quoted 16 lines
    printf("OMAP%s-%s rev %d, CPU-OPP2 L3-165MHz\n", cpu_s,
cpu/arm_cortexa8/omap3/sys_info.c +12 -3
-          sec_s, get_cpu_rev());
-   printf("%s + %s/%s\n", sysinfo.board_string,
-          mem_s, sysinfo.nand_string);
+           sec_s, get_cpu_rev());
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+           printf("%s + %s/", sysinfo.board_string,
+                   mem_s);
+#if defined(CONFIG_CMD_NAND)
+   if (is_nand)
+           printf("%s\n", "NAND");
+#endif
+#if defined(CONFIG_CMD_ONENAND)
+   if (is_onenand)
+           printf("%s\n", "ONENAND");
+#endif
Quoted 9 lines

cpu/arm_cortexa8/omap3/sys_info.c void display_board_info(u32 btype) · line 234

Quoted 6 lines
cpu/arm_cortexa8/omap3/sys_info.c +4 -0
+#else
+           printf("%s + %s/%s\n", sysinfo.board_string,
+                   mem_s, sysinfo.nand_string);
+#endif

I have this feel that we could improve this #ifdef mess.. using variables maybe?

Quoted 3 lines

[Pillai, Manikandan] other suggestions welcome Personally, I felt here the #ifdef is not so dirty.

;) not after a time of adding multiple #ifdefs :D... as I said, how about using variables to do it?

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib_arm/board.c +2 -0
+#if defined(CONFIG_ENV_IS_RUNTIME_SEL)
+   gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
Quoted 8 lines
Quoted 3 lines

Wooooaaah.. gpmc is TI OMAP2 or OMAP3 only.... NOT in other ARM or PPC or other platforms.. NAK on this.

[Pillai, Manikandan] Got your point. But I don't have a solution to this Since I EVM is doing a scan, it requires the gpmc_init to be called late. An option is to have another function board_init_late() which can be used to called gpmc_init_late().

that could be an option.. but please keep other platforms in mind when we send this patch.
Regards,
Nishanth Menon

#4 lore raw

PATCH 1/1 Changes for single binary image for u-boot for NAND/OneNAND flash.

In reply to Manikandan Pillai

Dear Manikandan Pillai,

Quoted 1 line · In message <[email protected]> you wrote:

Support for single binary image for NAND/OneNAND based OMAP3 EVM

What is a "single binary image" ?

Quoted 1 line

boards. The software has to set the flag CONFIG_ENV_IS_RUNTIME_SEL

What is CONFIG_ENV_IS_RUNTIME_SEL supposed to mean?

Quoted 7 lines

in include/configs/omap3_evm.h. The software is able to detect whether it is NAND or OneNAND flash at runtime. The flash detected is set as the environment store also.

As per the comments received, the change is done only for OMAP3 EVM.

Quoted 14 lines
---
 board/omap3/evm/evm.c             |    2 +
 common/Makefile                   |    1 +
 common/cmd_nvedit.c               |    5 ++
 common/env_common.c               |    8 +++-
 common/env_nand.c                 |   33 +++++++++++-
 common/env_onenand.c              |   26 +++++++++-
 cpu/arm_cortexa8/omap3/board.c    |   13 +++++
 cpu/arm_cortexa8/omap3/mem.c      |  100 ++++++++++++++++++++++++++++++++++++-
 cpu/arm_cortexa8/omap3/sys_info.c |   27 +++++++++-
 include/common.h                  |   10 +++-
 include/configs/omap3_evm.h       |    6 ++-
 lib_arm/board.c                   |   25 +++++++---
 12 files changed, 237 insertions(+), 19 deletions(-)

Given all the other postings about this - just to be sure: NAK for now.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
An age is called Dark not because  the  light  fails  to  shine,  but
because people refuse to see it.           -- James Michener, "Space"
#5 lore raw

PATCH 1/1 Changes for single binary image for u-boot for NAND/OneNAND flash.

Hi,

Single binary image - The type of flash is not selected during compile time. The U-boot scans the flash available(as of now whether it is NAND or OneNAND) and starts using the first flash detected as the ENV storge. To select this option, I added a #define CONFIG_ENV_IS_RUNTIME_SEL(env storage selection during runtime).

Regards
Mani

Quoted 55 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Monday, March 09, 2009 4:05 AM
To: Pillai, Manikandan
Cc: u-boot at lists.denx.de; dirk.behme at googlemail.com
Subject: Re: [U-Boot] [PATCH 1/1] Changes for single binary image for u-boot for NAND/OneNAND flash.

Dear Manikandan Pillai,

Quoted 1 line · In message <[email protected]> you wrote:

Support for single binary image for NAND/OneNAND based OMAP3 EVM

What is a "single binary image" ?

Quoted 1 line

boards. The software has to set the flag CONFIG_ENV_IS_RUNTIME_SEL

What is CONFIG_ENV_IS_RUNTIME_SEL supposed to mean?

Quoted 7 lines

in include/configs/omap3_evm.h. The software is able to detect whether it is NAND or OneNAND flash at runtime. The flash detected is set as the environment store also.

As per the comments received, the change is done only for OMAP3 EVM.

Quoted 9 lines
---
 board/omap3/evm/evm.c             |    2 +
 common/Makefile                   |    1 +
 common/cmd_nvedit.c               |    5 ++
 common/env_common.c               |    8 +++-
 common/env_nand.c                 |   33 +++++++++++-
 common/env_onenand.c              |   26 +++++++++-
 cpu/arm_cortexa8/omap3/board.c    |   13 +++++
 cpu/arm_cortexa8/omap3/mem.c      |  100

++++++++++++++++++++++++++++++++++++-

Quoted 5 lines
 cpu/arm_cortexa8/omap3/sys_info.c |   27 +++++++++-
 include/common.h                  |   10 +++-
 include/configs/omap3_evm.h       |    6 ++-
 lib_arm/board.c                   |   25 +++++++---
 12 files changed, 237 insertions(+), 19 deletions(-)

Given all the other postings about this - just to be sure: NAK for now.

Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de An age is called Dark not because the light fails to shine, but
because people refuse to see it. -- James Michener, "Space"