This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM355 NAND ECC failures on read



We have a product that uses a DM355 and two different types of NANDs. ubl, uboot, the kernel, and the file system live on a YAFFS file system on a Micron MT29F4G08AACWC-ET, we have a data storage NAND that is a Samsung K9WBG08U1M device. We are running an old kernel from Montavista 2.6.18. I wanted to do a raw dump of the Samsung NAND, but the nanddump (from mtdutils) didn't work, so I grabbed the source and modified it to support the large block and oob sizes of the Samsung NAND.

When I started dumping the NAND I noticed I was getting a lot of uncorrectable bit-flips. I started digging into this and it looks like the kernel is reporting a good deal of uncorrectable ecc errors on both the Micron and Samsung NANDs. But we aren't seeing corruption of the ubl, u-boot, the kernel, the filesystem, and the data NAND. I looked at the errata on the DM355 and there are several items listed with regard to RBL and NAND ECC, but I don't see any problems with the EMIF controller.

Has anyone else seen problems like this? I pulled in the ECC check code from the latest Arago kernel and that does the same thing. I'm starting to think this is a problem with the EMIF silicon. Can TI help or verify this?

Thank you.

  • Nick Butts said:
    I wanted to do a raw dump of the Samsung NAND, but the nanddump (from mtdutils) didn't work

    What initiated this whole series of events, i.e. what issue were you having with the Samsung NAND where you needed to dump the NAND?

     

    Nick Butts said:
    When I started dumping the NAND I noticed I was getting a lot of uncorrectable bit-flips.

    How did you notice?  Was this by inspection of the data or by a message being printed out somewhere?  If by message, what exactly was the message, and have you been able to confirm the message is correct?

     

     

    Nick Butts said:
    I started digging into this and it looks like the kernel is reporting a good deal of uncorrectable ecc errors on both the Micron and Samsung NANDs. But we aren't seeing corruption of the ubl, u-boot, the kernel, the filesystem, and the data NAND.

    So are you saying there are false positives in the error reporting, i.e. the kernel is reporting errors that are not in fact errors?

  • Brad Griffis said:
    What initiated this whole series of events, i.e. what issue were you having with the Samsung NAND where you needed to dump the NAND?

    We refactored the way we are storing data in the Samsung NAND. So we started doing raw dumps of the data until we were sure we had the structure of the data storage correct.

    Brad Griffis said:
    How did you notice?  Was this by inspection of the data or by a message being printed out somewhere?  If by message, what exactly was the message, and have you been able to confirm the message is correct?

    By using mtdutils nanddump utility and then kernel printk statements in the davinci-nand.c module when it read the 512 bytes of data and feed the oob ECC codes into the EMIF for verification. The EMIF would report that too many ECC errors occurred to fix (I.E. 5 or more bits had flipped).

    Brad Griffis said:
    So are you saying there are false positives in the error reporting, i.e. the kernel is reporting errors that are not in fact errors?

    I am in the process of grabbing both the data and the ECC codes, then I will write a program or do something in Matlab to manually check the ECC codes to see what that reports. If the data was truely corrupt, I would expect to see other issues, such as the kernel randomly not booting or a linux command failing, or our data's checksum failing. But we don't see that. So I suspect one of the following is happening:

    1) The ECC codes are being incorrectly calculated when data is written.

    2) The ECC codes are not being written to the NAND correctly.

    3) The data is correct when reading from NAND. As I described above, I don't think this is happening.

    4) The ECC data is not read correctly.

    5) The ECC data had the bit-flip NOT the data. This is what I suspect, but it could also be a problem the EMIF calculating the resulting ECC code.

  • Nick Butts said:
    I am in the process of grabbing both the data and the ECC codes, then I will write a program or do something in Matlab to manually check the ECC codes to see what that reports.

    Let us know the results of this testing and then we can figure out where to go next.

  • Is there any app note on how the ECC code is calculated? For example here is a 2 KB page of data with ECC codes that failed.

    root@MV0159:/mnt/mmc# ~/nanddump -p -s 4509696 -l 512 /dev/mtd3 | more
    ECC failed: 18
    ECC corrected: 0
    Number of bad blocks: 5
    Number of bbt blocks: 0
    Block size 131072, page size 2048, OOB size 64
    Dumping data starting at 0x0044d000 and ending at 0x0044d200...
    ECC: 1 uncorrectable bitflip(s) at offset 0x0044d000
    0x0044d000: 30 30 30 30 31 00 00 00 00 00 00 00 00 00 00 00
    0x0044d010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      OOB Data: 13 25 00 00 ca 12 53 f7 b7 42 d1 b3 97 bf 24 e3
      OOB Data: 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
      OOB Data: 0a 00 00 00 ff ff 00 00 00 00 00 00 00 00 00 00
      OOB Data: ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00

  • First download the DM35x Flash and Boot Utils from here:

    http://sourceforge.net/projects/dvflashutils/files/

    Once you extract the tarball you'll find the following:

    • DM35x_FlashAndBootUtils_1_50\Common\genecc (C# source code for ECC calculation)
    • DM35x_FlashAndBootUtils_1_50\DM35x\GNU\genecc_DM35x.exe (.NET executable for ECC calculation)

    The genecc tool is discussed a bit more here:

    http://processors.wiki.ti.com/index.php/NAND_ECC_Generation_for_DaVinci_Family_of_Devices

    It takes a binary input so you might need to do a little intermediate work to turn your ascii data into a binary file.

    Brad

  • OK, I'm very confused. I found another page in flash that happens to have the exact same data and ECC codes. In one case the kernel (EMIF hardware) indicates there are no "bad" bits. In the other case it indicates there are 5 or more uncorrectable bits. Yet they have the EXACT same data and ECC codes. The ECC failure is not a one off event. It happens every time I read that memory location. This really looks like some sort of problem with the ECC HW.

    Here is the "good" page:

    root@MV0159:~# ~/nanddump -p -s 4513792 -l 512 /dev/mtd3 | more
    ECC failed: 91
    ECC corrected: 0
    Number of bad blocks: 5
    Number of bbt blocks: 0
    Block size 131072, page size 2048, OOB size 64
    Dumping data starting at 0x0044e000 and ending at 0x0044e200...
    0x0044e000: 30 30 30 30 31 00 00 00 00 00 00 00 00 00 00 00
    0x0044e010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e1c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e1d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e1e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e1f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e2a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e2b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e2c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e2d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e2e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e3a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e3b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e3c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e3d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e3e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e3f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e4a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e4b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e4c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e4d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e4e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e4f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e5a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e5b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e5c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e5d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e5e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e5f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e6a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e6b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e6c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e6d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e6e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e6f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e7a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e7b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e7c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e7d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e7e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044e7f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      OOB Data: 13 25 00 00 d5 04 1b c8 9b 55 4e 8e 7a ac 25 75
      OOB Data: 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
      OOB Data: 0a 00 00 00 ff ff 00 00 00 00 00 00 00 00 00 00
      OOB Data: ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00
     

     

    Bad page:

    root@MV0159:~# ~/nanddump -p -s 4509696 -l 512 /dev/mtd3 | more
    ECC failed: 91
    ECC corrected: 0
    Number of bad blocks: 5
    Number of bbt blocks: 0
    Block size 131072, page size 2048, OOB size 64
    Dumping data starting at 0x0044d000 and ending at 0x0044d200...
    ECC: 1 uncorrectable bitflip(s) at offset 0x0044d000
    0x0044d000: 30 30 30 30 31 00 00 00 00 00 00 00 00 00 00 00
    0x0044d010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d1f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d220: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d230: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d240: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d250: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d260: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d270: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d2f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d310: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d320: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d340: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d350: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d360: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d390: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d3f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d410: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d440: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d450: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d460: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d470: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d490: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d4f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d510: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d520: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d530: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d540: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d550: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d570: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d590: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d5f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d6f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d710: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d730: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d740: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d750: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d770: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    0x0044d7f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      OOB Data: 13 25 00 00 ca 12 53 f7 b7 42 d1 b3 97 bf 24 e3
      OOB Data: 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
      OOB Data: 0a 00 00 00 ff ff 00 00 00 00 00 00 00 00 00 00
      OOB Data: ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00

     

    Here is what the generic_DM35x.exe produces for the ECC codes for the two data examples:

    Good data

    C:\NickTemp\DM35x_FlashAndBootUtils_1_50\DM35x\GNU>genecc_DM35x.exe -v data_good
    .bin
    -----------------------------------------------------
       TI EMIF2.5 ECC Parity Generator for DM35x
       (C) 2009, Texas Instruments, Inc.
       Ver. 1.01
    -----------------------------------------------------


    NAND operation #1
            NAND4BITECC1 = 02F2001B
            NAND4BITECC2 = 01390159
            NAND4BITECC3 = 031E028E
            NAND4BITECC4 = 01D4025A
    NAND operation #2
            NAND4BITECC1 = 00000000
            NAND4BITECC2 = 00000000
            NAND4BITECC3 = 00000000
            NAND4BITECC4 = 00000000
    NAND operation #3
            NAND4BITECC1 = 00000000
            NAND4BITECC2 = 00000000
            NAND4BITECC3 = 00000000
            NAND4BITECC4 = 00000000
    NAND operation #4
            NAND4BITECC1 = 00000000
            NAND4BITECC2 = 00000000
            NAND4BITECC3 = 00000000
            NAND4BITECC4 = 00000000

    Bad data:

    C:\NickTemp\DM35x_FlashAndBootUtils_1_50\DM35x\GNU>genecc_DM35x.exe -v data_bad.
    bin
    -----------------------------------------------------
       TI EMIF2.5 ECC Parity Generator for DM35x
       (C) 2009, Texas Instruments, Inc.
       Ver. 1.01
    -----------------------------------------------------


    NAND operation #1
            NAND4BITECC1 = 02F2001B
            NAND4BITECC2 = 01390159
            NAND4BITECC3 = 031E028E
            NAND4BITECC4 = 01D4025A
    NAND operation #2
            NAND4BITECC1 = 00000000
            NAND4BITECC2 = 00000000
            NAND4BITECC3 = 00000000
            NAND4BITECC4 = 00000000
    NAND operation #3
            NAND4BITECC1 = 00000000
            NAND4BITECC2 = 00000000
            NAND4BITECC3 = 00000000
            NAND4BITECC4 = 00000000
    NAND operation #4
            NAND4BITECC1 = 00000000
            NAND4BITECC2 = 00000000
            NAND4BITECC3 = 00000000
            NAND4BITECC4 = 00000000

     

    Now the kernel takes the ECC registers and unpacks the data into 16-bit words. I extracted the function from the kernel that does this bit twiddling and wrapped a program around it. Here is what I get when I do the bit-twiddling with the values:

    ~/temp$ ./ecc 02f2001b 01390159 031e028e 01d4025a
    Input data: 02F2001B 01390159 031E028E 01D4025A
    Output data: 1B C8 9B 55 4E 8E 7A AC 25 75 00 00 00 00 00 00

    Which doesn't match the oob data nanddump spits out. Here is my ecc.c code:

    static int calculate_ecc(uint32_t * hw_4ecc, uint8_t *ecc_code)
    {
        unsigned int const1 = 0, const2 = 0;
        unsigned char count1 = 0;

        /*Convert 10 bit ecc value to 8 bit */
        for (count1 = 0; count1 < 2; count1++) {
            const2 = count1 * 5;
            const1 = count1 * 2;

            /* Take first 8 bits from val1 (count1=0) or val5 (count1=1) */
            ecc_code[const2] = hw_4ecc[const1] & 0xFF;

            /*
             * Take 2 bits as LSB bits from val1 (count1=0) or val5
             * (count1=1) and 6 bits from val2 (count1=0) or val5 (count1=1)
             */
            ecc_code[const2 + 1] =
                ((hw_4ecc[const1] >> 8) & 0x3) | ((hw_4ecc[const1] >> 14) &
                                  0xFC);

            /*
             * Take 4 bits from val2 (count1=0) or val5 (count1=1) and
             * 4 bits from val3 (count1=0) or val6 (count1=1)
             */
            ecc_code[const2 + 2] =
                ((hw_4ecc[const1] >> 22) & 0xF) |
                ((hw_4ecc[const1 + 1] << 4) & 0xF0);

            /*
             * Take 6 bits from val3(count1=0) or val6 (count1=1) and
             * 2 bits from val4 (count1=0) or  val7 (count1=1)
             */
            ecc_code[const2 + 3] =
                ((hw_4ecc[const1 + 1] >> 4) & 0x3F) |
                ((hw_4ecc[const1 + 1] >> 10) & 0xC0);

            /* Take 8 bits from val4 (count1=0) or val7 (count1=1) */
            ecc_code[const2 + 4] = (hw_4ecc[const1 + 1] >> 18) & 0xFF;
        }
        return 0;
    }


    int main(int argc, char * argv[])
    {
        uint32_t hwecc[4];
        uint8_t ecc[16];
        uint32_t i;
        memset(ecc, 0, 16);
        if (argc == 5)
        {
            sscanf(argv[1], "%x", &hwecc[0]);
            sscanf(argv[2], "%x", &hwecc[1]);
            sscanf(argv[3], "%x", &hwecc[2]);
            sscanf(argv[4], "%x", &hwecc[3]);

            printf("Input data: %08X %08X %08X %08X\n", hwecc[0], hwecc[1], hwecc[2], hwecc[3]);
            calculate_ecc(hwecc, ecc);       
            printf("Output data: ");
            for (i = 0; i < 16; i++)
            {
                printf("%02X ", ecc[i]);
            }
            printf("\n");
        }

        return 0;
    }

     

    Any ideas?

  • Nick Butts said:
    In one case the kernel (EMIF hardware) indicates there are no "bad" bits. In the other case it indicates there are 5 or more uncorrectable bits. Yet they have the EXACT same data and ECC codes.

    But they are not the same -- the OOB is different.  Here's a snippet from your "good" block:

    Nick Butts said:
    OOB Data: 13 25 00 00 d5 04 1b c8 9b 55 4e 8e 7a ac 25 75

    Here's the corresponding snippet from your "bad" block:

    Nick Butts said:
    OOB Data: 13 25 00 00 ca 12 53 f7 b7 42 d1 b3 97 bf 24 e3

  • OK, my data does match. I happen to front load the converted ECC data and zero pad the end, whereas Linux random fills the first 6 bytes and then writes the 10 bytes of ECC data. So the first 6 bytes in the read ECC data is garbage and the last 10 bytes are the actual ECC data.

  • Looks like the ECC is correct for the "good" block:

    Nick Butts said:
    OOB Data: 13 25 00 00 d5 04 1b c8 9b 55 4e 8e 7a ac 25 75

    Here's the corresponding snippet from your program you wrote:

    Nick Butts said:

    ~/temp$ ./ecc 02f2001b 01390159 031e028e 01d4025a
    Input data: 02F2001B 01390159 031E028E 01D4025A
    Output data: 1B C8 9B 55 4E 8E 7A AC 25 75 00 00 00 00 00 00

  • Yep, it looks like it is correct for both the "good" and the "bad" pages. So why would the EMIF controller indicate one has 0 errors and the other has 5 or more errors?

  • Nick Butts said:

    Yep, it looks like it is correct for both the "good" and the "bad" pages. So why would the EMIF controller indicate one has 0 errors and the other has 5 or more errors?

    I disagree -- it is correct only for the "good" page.  It is incorrect for the bad page.  The good page and the bad page have different data in the OOB as I mentioned back in this post

  • I missed your post. OK, so it looks like the page data was either cleared to zeros and the ECC codes where not updated or the ECC codes were written incorrectly the first time around. I tried to re-read the bad page but YAFFs and already garbage collected it. I will keep looking into the problem.

  • Just to update anyone on this. In the davinci-nand.c (at least in the old 2.6.18 MontaVista kernel), if you have multiple NAND chips on a product you need to initialize the nand_chip->controller pointer to the SAME controller structure so the lock will prevent multiple threads from trying to use the EMIF controller at the same time.

    So our problem was multiple threads trying to access use the EMIF controller at the same time.

  • Would you be able to point me to the bit of code that you modified? I'm currently trying to flash a new kernel over the old one currently stored in the flash which was written there by u-boot. The new one, written from Linux is reporting checksum errors and I suspect that it is exactly this problem with the ECC and nanddump of a working partition reports lots of ECC errors but u-boot reports a good checksum. I'm also on Montavista 2.6.18.