NAND: redirect the pointer of bbt pattern to RAM
Subsystems (2)
PATCH 1/1 NAND: redirect the pointer of bbt pattern to RAM
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.
---
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(-)
drivers/mtd/nand/fsl_elbc_nand.c +4 -0
@@ -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 */
Signature · 1 line
1.5.4
[U-Boot] Manual relocation sucks.
Quoted 7 lines · Mingkai Hu
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 <[email protected]>
Applied to u-boot-nand-flash, with the subject changed to reflect that this is only for one driver.
Quoted 6 lines
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.cmay 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. :-)
Agreed. Can anyone shed some light on what the problems were the last time, and whether they're still around with current toolchains?
-Scott