I've been tasked with creating a golden image for pre-programming production NAND flash parts that will be soldered onto our AM3352 based board running Linux. We are using a Macronix MX30LF2G28AB 2Gbit part.
In my research I've come up with a lot of questions and I'm hoping that someone with some experience can help me out.
1. My first question is: Is this actually typically done with NAND flash for mass production? Everything I've seen on the web talks about programming the NAND flash through u-boot or JTAG so that bad blocks and ECC is handled correctly. This makes me think that I might be on a fools errand here.
2. I have found a little information and it seems to suggest that the process is highly dependent on the Flash programmer that is used and that in general it is a good idea to included the OOB data with the calculated ECC values in the image(s). So I've gone looking for a tool to add the OOB and ECC data to the MLO, u-boot.img, zImage, and rootfs.ubi files. I haven't really found this tool, I did get a bin2nand tool from a TI rep. but it only supports BCH8 for ECC and I've selected BCH16. I can probably get by with BCH8 but if BCH16 fits why not use it? I find it really odd that there is no tool to do this, am I missing something?
3. I did come up with a novel way to create the files with the correct OOB/ECC data, but I'd like some confirmation that the method is sound.
1. Use the u-boot command 'nand write' to write the data to the nand, skipping bad blocks and writing the ECC data.
2. Boot to Linux and use the MTD utils command nanddump to read the data out with the OOB data, and skipping any bad blocks, something like this:
$ nanddump --bb='skipbad' -o -l <size> -f zImage.oob.bin /dev/mtd4
This should give me a copy of the data from NAND with the correct ECC for BCH16. I even tested this by writing it back to NAND with the u-boot command 'nand write.raw' and it worked. Btw I first checked that there were no bad blocks on the device because nand write.raw doesn't skip bad blocks.
However, I read something here that makes me question if my approach is correct. Basically I think the logic goes if there were a bit error in the source NAND and if nanddump didn't correct it during read it would get transferred to the image and therefore transferred to any NAND programmed from the image, of course the ECC checksum should be able to correct it. I'm not sure if nanddump does the correction, I think it does but I'm not sure (I suppose that I can test this by inducing a bit error, doing the nanddump, removing the OOB data and comparing the image to the original.
If anybody can share any experiences you have with this I'd very much appreciate it.
Thanks,
Matt S.