[U-Boot] [PATCH] NAND: redirect the pointer of bbt pattern to RAM

Mingkai Hu Mingkai.hu at freescale.com
Thu Jun 18 12:23:27 CEST 2009


The bbt descriptors contains the pointer to the bbt pattern which
are statically initialized memory struct. When relocated to RAM,
these pointers will continue point to NOR flash(or L2 SRAM, or
other boot device). If the contents of NOR flash changed or L2
SRAM disabled, it'll hang the system.

Signed-off-by: Mingkai Hu <Mingkai.hu at freescale.com>
---

I came across this issue when worked on boot-from-nand on MPC8536DS
board. Generally the 4K NAND loader initializes the RAM through fixed
DDR config parameters, then copy the u-boot image to RAM. In order to
allow SPD memory config, I load the u-boot image into L2 SRAM first,
then initialize the memory, relocate the u-boot image into RAM and
transfer control to u-boot image.

The u-boot image bring up and run to cpu_init_r() to disable the L2 SRAM
and enable it as L2 cache, then hang at env_relocate() owing to check if
the NAND block is bad. The nand_block_isbad() will use the statically
initialized struct bbt_main_descr which contains a pointer pointed to L2
SRAM yet. 

I fixed this issue by redirecting the pointer to the data address in RAM
at driver level. Fixing up the generic structures in nand_bbt.c may be a
little more awkward, so I try the -mrelocatble flag and it also works.

Although the relocation changs were backouted, can we re-investigate this
method again? After all, this is the ultimate method. :-)


 drivers/mtd/nand/fsl_elbc_nand.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 3f318e0..77a33c0 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -766,6 +766,9 @@ int board_nand_init(struct nand_chip *nand)
 	nand->waitfunc = fsl_elbc_wait;
 
 	/* set up nand options */
+	/* redirect the pointer of bbt pattern to RAM */
+	bbt_main_descr.pattern = bbt_pattern;
+	bbt_mirror_descr.pattern = mirror_pattern;
 	nand->bbt_td = &bbt_main_descr;
 	nand->bbt_md = &bbt_mirror_descr;
 
@@ -812,6 +815,7 @@ int board_nand_init(struct nand_chip *nand)
 	/* Large-page-specific setup */
 	if (or & OR_FCM_PGS) {
 		priv->page_size = 1;
+		largepage_memorybased.pattern = scan_ff_pattern;
 		nand->badblock_pattern = &largepage_memorybased;
 
 		/* adjust ecc setup if needed */
-- 
1.5.4



More information about the U-Boot mailing list