summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Denk <wd@pollux.denx.de>2006-09-13 10:25:40 +0200
committerWolfgang Denk <wd@pollux.denx.de>2006-09-13 10:25:40 +0200
commit5d5269f87fc00a3fe1960cacd92e3d04864dff7d (patch)
tree208a387f1e0f0399696132e556e58b36e6072efd
parenta87d46f7327eedead89284a0d0c5e5a769b984b9 (diff)
parentd12ae80889568365ecb9e6698322f9771ae76dde (diff)
downloadu-boot-imx-5d5269f87fc00a3fe1960cacd92e3d04864dff7d.zip
u-boot-imx-5d5269f87fc00a3fe1960cacd92e3d04864dff7d.tar.gz
u-boot-imx-5d5269f87fc00a3fe1960cacd92e3d04864dff7d.tar.bz2
Merge with /home/sr/git/u-boot/denx
-rw-r--r--CHANGELOG8
-rw-r--r--Makefile4
-rw-r--r--board/amcc/sequoia/u-boot-nand.lds8
-rw-r--r--common/env_nand.c50
-rw-r--r--common/environment.c3
-rw-r--r--doc/README.nand-boot-ppc44024
-rw-r--r--include/configs/sequoia.h27
-rw-r--r--include/environment.h4
-rw-r--r--nand_spl/board/amcc/sequoia/Makefile4
-rw-r--r--nand_spl/nand_boot.c3
10 files changed, 105 insertions, 30 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 4e9cf16..786f01b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,9 +2,15 @@
Changes since U-Boot 1.1.4:
======================================================================
+* Add NAND environment support for PPC440EPx Sequoia NAND boot config
+ Patch by Stefan Roese, 12 Sep 2006
+
+* Update NAND boot documentation
+ Patch by Stefan Roese, 12 Sep 2006
+
* Fix alignment problem in "mtdparts" command
-* Add documentation on the latest build environment extensions to
+* Add documentation on the latest build environment extensions to
the README file.
* Remove dead code (i2o and dma) from cpu/mpc824x/drivers/ directory.
diff --git a/Makefile b/Makefile
index 291dc61..84d9367 100644
--- a/Makefile
+++ b/Makefile
@@ -78,7 +78,7 @@ saved-output := $(BUILD_DIR)
# Attempt to create a output directory.
$(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR})
-# Verify if it was successful.
+# Verify if it was successful.
BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd)
$(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist))
endif # ifneq ($(BUILD_DIR),)
@@ -272,7 +272,7 @@ $(NAND_SPL): version
$(MAKE) -C nand_spl all
$(U_BOOT_NAND): $(NAND_SPL) $(obj)u-boot.bin
- cat nand_spl/u-boot-spl-4k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
+ cat nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin
version:
@echo -n "#define U_BOOT_VERSION \"U-Boot " > $(VERSION_FILE); \
diff --git a/board/amcc/sequoia/u-boot-nand.lds b/board/amcc/sequoia/u-boot-nand.lds
index c3d3d96..cf2e2b5 100644
--- a/board/amcc/sequoia/u-boot-nand.lds
+++ b/board/amcc/sequoia/u-boot-nand.lds
@@ -1,5 +1,5 @@
/*
- * (C) Copyright 2002
+ * (C) Copyright 2006
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
@@ -56,6 +56,12 @@ SECTIONS
cpu/ppc4xx/start.o (.text)
+ /* Align to next NAND block */
+ . = ALIGN(0x4000);
+ common/environment.o (.ppcenv)
+ /* Keep some space here for redundant env and potential bad env blocks */
+ . = ALIGN(0x10000);
+
*(.text)
*(.fixup)
*(.got1)
diff --git a/common/env_nand.c b/common/env_nand.c
index 0a05b09..67c4a4e 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -2,7 +2,7 @@
* (C) Copyright 2004
* Jian Zhang, Texas Instruments, jzhang@ti.com.
- * (C) Copyright 2000-2004
+ * (C) Copyright 2000-2006
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
@@ -76,7 +76,9 @@ env_t *env_ptr = 0;
/* local functions */
+#if !defined(ENV_IS_EMBEDDED)
static void use_default(void);
+#endif
DECLARE_GLOBAL_DATA_PTR;
@@ -91,11 +93,55 @@ uchar env_get_char_spec (int index)
* Mark it OK for now. env_relocate() in env_common.c
* will call our relocate function which will does
* the real validation.
+ *
+ * When using a NAND boot image (like sequoia_nand), the environment
+ * can be embedded or attached to the U-Boot image in NAND flash. This way
+ * the SPL loads not only the U-Boot image from NAND but also the
+ * environment.
*/
int env_init(void)
{
+#if defined(ENV_IS_EMBEDDED)
+ ulong total;
+ int crc1_ok = 0, crc2_ok = 0;
+ env_t *tmp_env1, *tmp_env2;
+
+ total = CFG_ENV_SIZE;
+
+ tmp_env1 = env_ptr;
+ tmp_env2 = (env_t *)((ulong)env_ptr + CFG_ENV_SIZE);
+
+ crc1_ok = (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc);
+ crc2_ok = (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc);
+
+ if (!crc1_ok && !crc2_ok)
+ gd->env_valid = 0;
+ else if(crc1_ok && !crc2_ok)
+ gd->env_valid = 1;
+ else if(!crc1_ok && crc2_ok)
+ gd->env_valid = 2;
+ else {
+ /* both ok - check serial */
+ if(tmp_env1->flags == 255 && tmp_env2->flags == 0)
+ gd->env_valid = 2;
+ else if(tmp_env2->flags == 255 && tmp_env1->flags == 0)
+ gd->env_valid = 1;
+ else if(tmp_env1->flags > tmp_env2->flags)
+ gd->env_valid = 1;
+ else if(tmp_env2->flags > tmp_env1->flags)
+ gd->env_valid = 2;
+ else /* flags are equal - almost impossible */
+ gd->env_valid = 1;
+ }
+
+ if (gd->env_valid == 1)
+ env_ptr = tmp_env1;
+ else if (gd->env_valid == 2)
+ env_ptr = tmp_env2;
+#else /* ENV_IS_EMBEDDED */
gd->env_addr = (ulong)&default_environment[0];
gd->env_valid = 1;
+#endif /* ENV_IS_EMBEDDED */
return (0);
}
@@ -236,6 +282,7 @@ void env_relocate_spec (void)
}
#endif /* CFG_ENV_OFFSET_REDUND */
+#if !defined(ENV_IS_EMBEDDED)
static void use_default()
{
puts ("*** Warning - bad CRC or NAND, using default environment\n\n");
@@ -253,5 +300,6 @@ static void use_default()
gd->env_valid = 1;
}
+#endif
#endif /* CFG_ENV_IS_IN_NAND */
diff --git a/common/environment.c b/common/environment.c
index 81471ce..19bdeb0 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -60,7 +60,8 @@
defined(CONFIG_RRVISION) || \
defined(CONFIG_TRAB) || \
defined(CONFIG_PPCHAMELEONEVB) || \
- defined(CONFIG_M5271EVB)) && \
+ defined(CONFIG_M5271EVB) || \
+ defined(CONFIG_NAND_U_BOOT)) && \
defined(ENV_CRC) /* Environment embedded in U-Boot .ppcenv section */
/* XXX - This only works with GNU C */
# define __PPCENV__ __attribute__ ((section(".ppcenv")))
diff --git a/doc/README.nand-boot-ppc440 b/doc/README.nand-boot-ppc440
index a82a10e..a1c1d8c 100644
--- a/doc/README.nand-boot-ppc440
+++ b/doc/README.nand-boot-ppc440
@@ -33,4 +33,28 @@ is set up. While still running from cache, I experienced problems accessing
the NAND controller.
+Example: Build and install NAND boot image for Sequoia (440EPx):
+
+a) Configure for sequoia with NAND boot support:
+# make sequoia_nand_config
+
+b) Build image(s)
+# make
+
+This will generate the SPL image in the "nand_spl" directory:
+nand_spl/u-boot-spl.bin
+Also another image is created spanning a whole NAND block (16kBytes):
+nand_spl/u-boot-spl-16k.bin
+The main NAND U-Boot image is generated in the toplevel directory:
+u-boot.bin
+A combined image of u-boot-spl-16k.bin and u-boot.bin is also created:
+u-boot-nand.bin
+
+This image should be programmed at offset 0 in the NAND flash:
+
+# tftp 100000 /tftpboot/sequoia/u-boot-nand.bin
+# nand erase 0 60000
+# nand write 100000 0 60000
+
+
September 07 2006, Stefan Roese <sr@denx.de>
diff --git a/include/configs/sequoia.h b/include/configs/sequoia.h
index d3fcc03..639765d 100644
--- a/include/configs/sequoia.h
+++ b/include/configs/sequoia.h
@@ -69,14 +69,9 @@
/*-----------------------------------------------------------------------
* Initial RAM & stack pointer
*----------------------------------------------------------------------*/
-#if 0
/* 440EPx/440GRx have 16KB of internal SRAM, so no need for D-Cache */
-#define CFG_INIT_RAM_DCACHE 1 /* d-cache as init ram */
-#define CFG_INIT_RAM_ADDR 0x70000000 /* DCache */
-#else
#define CFG_INIT_RAM_OCM 1 /* OCM as init ram */
#define CFG_INIT_RAM_ADDR CFG_OCM_BASE /* OCM */
-#endif
#define CFG_INIT_RAM_END (4 << 10)
#define CFG_GBL_DATA_SIZE 256 /* num bytes initial data */
@@ -98,18 +93,11 @@
/*-----------------------------------------------------------------------
* Environment
*----------------------------------------------------------------------*/
-/*
- * Define here the location of the environment variables (FLASH or EEPROM).
- * Note: DENX encourages to use redundant environment in FLASH.
- */
-#if 1 /* test-only */
+#if !defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL)
#define CFG_ENV_IS_IN_FLASH 1 /* use FLASH for environment vars */
#else
#define CFG_ENV_IS_IN_NAND 1 /* use NAND for environment vars */
#endif
-#if 0
-#define CFG_ENV_IS_IN_EEPROM 1 /* use EEPROM for environment vars */
-#endif
/*-----------------------------------------------------------------------
* FLASH related
@@ -189,8 +177,12 @@
#undef CFG_NAND_4_ADDR_CYCLE /* No fourth addr used (<=32MB) */
#ifdef CFG_ENV_IS_IN_NAND
-#define CFG_ENV_SIZE 0x4000
-#define CFG_ENV_OFFSET (CFG_NAND_U_BOOT_OFFS + CFG_NAND_U_BOOT_SIZE)
+/*
+ * For NAND booting the environment is embedded in the U-Boot image. Please take
+ * look at the file board/amcc/sequoia/u-boot-nand.lds for details.
+ */
+#define CFG_ENV_SIZE CFG_NAND_BLOCK_SIZE
+#define CFG_ENV_OFFSET (CFG_NAND_U_BOOT_OFFS + CFG_ENV_SIZE)
#define CFG_ENV_OFFSET_REDUND (CFG_ENV_OFFSET + CFG_ENV_SIZE)
#endif
@@ -214,11 +206,6 @@
#define CFG_EEPROM_PAGE_WRITE_BITS 3
#define CFG_EEPROM_PAGE_WRITE_DELAY_MS 10
-#ifdef CFG_ENV_IS_IN_EEPROM
-#define CFG_ENV_SIZE 0x200 /* Size of Environment vars */
-#define CFG_ENV_OFFSET 0x0
-#endif /* CFG_ENV_IS_IN_EEPROM */
-
/* I2C SYSMON (LM75, AD7414 is almost compatible) */
#define CONFIG_DTT_LM75 1 /* ON Semi's LM75 */
#define CONFIG_DTT_AD7414 1 /* use AD7414 */
diff --git a/include/environment.h b/include/environment.h
index 422f800..26b0712 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -79,6 +79,10 @@
# ifdef CFG_ENV_OFFSET_REDUND
# define CFG_REDUNDAND_ENVIRONMENT
# endif
+# if defined(CONFIG_NAND_U_BOOT)
+/* Use embedded environment in NAND boot versions */
+# define ENV_IS_EMBEDDED 1
+# endif
#endif /* CFG_ENV_IS_IN_NAND */
diff --git a/nand_spl/board/amcc/sequoia/Makefile b/nand_spl/board/amcc/sequoia/Makefile
index 6c07e3d..897aa8b 100644
--- a/nand_spl/board/amcc/sequoia/Makefile
+++ b/nand_spl/board/amcc/sequoia/Makefile
@@ -35,11 +35,11 @@ COBJS = nand_boot.o ndfc.o sdram.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
-ALL = u-boot-spl u-boot-spl.bin u-boot-spl-4k.bin
+ALL = u-boot-spl u-boot-spl.bin u-boot-spl-16k.bin
all: $(obj).depend $(ALL)
-u-boot-spl-4k.bin: u-boot-spl
+u-boot-spl-16k.bin: u-boot-spl
$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $< $@
u-boot-spl.bin: u-boot-spl
diff --git a/nand_spl/nand_boot.c b/nand_spl/nand_boot.c
index 6e3af13..21abb09 100644
--- a/nand_spl/nand_boot.c
+++ b/nand_spl/nand_boot.c
@@ -166,8 +166,7 @@ void nand_boot(void)
/*
* Load U-Boot image from NAND into RAM
*/
- ret = nand_load(&nand_info, CFG_NAND_U_BOOT_OFFS,
- CFG_NAND_U_BOOT_SIZE,
+ ret = nand_load(&nand_info, CFG_NAND_U_BOOT_OFFS, CFG_NAND_U_BOOT_SIZE,
(uchar *)CFG_NAND_U_BOOT_DST);
/*