Greetings!
We are doing a project where we are attempting to use the AM3715’s built in ECC generator to compute a BCH8 codeword, including 8 bytes of spare data in a page. However, we are having difficulty getting it to do this properly.
Some background on the NAND Flash we are using:
Hynix
2048 byte pages
64 byte spares
8 bit bus
Requires at least 4 bit EDC
When a write page is requested, here is the sequence of commands we are sending:
- Send reset command to nand
- Check ready status
- Send program command
- Initialize ecc by setting eccconfig to bch mode, bch8, 8 bit bus, 4-512 segments, chip select 0, enabled
- Set wrap mode for write to mode 7
- Set ecc size config to size1 = 0x1A (13 bytes) and size0 = 0x10 (8 bytes) to include 8 bytes in ecc computation.
- Set the ecc control to enable result1 and then clear ecc
- Send 2048 bytes (not using prefetch)
- Send 8 bytes of the spare area
- Read the result registers to get the codeword (result registers 0-3, 4 times with the 14th byte filled with 0xFF)
- Disable ecc engine
- Write the code into the spare area at offset of 8 bytes
- Send program start command
Here is the program flow for a read:
- Same as above for the commands
- Initialize ecc by setting the same registers to the same values, but setting wrap mode to 3 with same size1 and size0.
- Read 2048 bytes
- Read 64 bytes of spare
- Read ecc result registers to get 56 bytes
- Reset ecc engine
We are assuming that at this point, the on the fly calculated BCH8 should be the same as the stored one from the write before, because the data matches if it is compared. However, the codewords are not equal, and there appears to be no order or pattern to them. Once the code is retrieved, it goes into the algorithm to decode bch, and count the number of errors, which comes out -1.
Should the stored code from a write be equal to the code generated during the read, or is this an incorrect assumption? (they are equal when using mode 6 for read and write on data only). For wrapmode 7/3 (write,read), is the sequence of instructions being used the correct procedure for including 8 bytes of spare area in the BCH8 protection?
Is there some errata or technical note that we're missing that indicates that we can't really do what we're attempting?
Thanks in advance for any advice.
Best Regards,
Tony