Hi Sol,
I am a colleague of Jon, and supporting him with this issue.
After some testing, we found that some cards are able to read/write from/to the NAND Flash device, however some are not.
As Jon explains, we have two methods of testing the NFC. One using the BSP driver, and another using the FFS/MFS drivers, bundled with MQX. The BSP driver does work when setting NUM_ECC_BYTES > 0, and returns NANDFLASHERR_ECC_FAILED when attempting to read. Setting NUM_ECC_BYTES = 0 however seems to work fine.
The FFS/MFS solution seem to work fine, even with NUM_ECC_BYTES=4 or NUM_ECC_BYTES=8.
Some of our cards, those used in initial testing of the NFC, seem to have reached a state where nothing works. We will have one of our HW Engineers take a look at this.
We have examined and compared the sources of the BSP driver and the NFC driver included in the FFS/MFS-driver. There are several differences between the two, most of it due to the FFS/MFS-driver also reading some meta-data with every read. However, we noticed one curious difference we cannot quite understand:
[C++] MQX Vybrid NFC ECC check - Pastebin.com
The confusing part is the offset added to VIRTUAL_PAGE_SIZE. VIRTUAL_PAGE_SIZE=512 and num_ecc_bytes=15 have been confirmed to be identical on both setups, so why do the BSP check the NFC_ECC_STATUS_CORFAIL flag at offset NFC_ECC_STATUS_OFFSET=0x0C, and FFS check it at offset (num_ecc_bytes + 4) = 19 = 0x13?
NFC_ECC_STATUS_OFFSET is defined on the top of nfc.c, and only used twice in this file, only to check status flags. It is never used in defining the location of the status field, and thus its origin and use is unclear.
The FFS driver is also using a magic number when adding 4, but the motivation for this is found in the reference manual:
NOTE
The address of the ECC status byte = Buffer n's start address +NFC_CFG[ECCAD] + 4 (n=0,1,2,3).
- Vybrid Reference Manual (Rev. 8), Ch. 10.3.4.2. Page 1724.
The two drivers appear to use different definitions of the ECC status word. It therefore seem to us that we are missing some information.
Could you elaborate on this.
/Tom
Edit:
Here are the values for ECCAD:
BSP - NFC_CFG[ECCAD] = 65
FFS - NFC_CFG[ECCAD] = 66