一、ecc 和 spare area 格式的疑问:
具体是这样的:
在代码里面我看到这样的操作
在系统启动的时候,调用flash驱动,进行预留块的读操作,此时读的是spare area, 因为,我的flash是大页的,坏块标记是在列地址为2048的位置,就是spare区的第一个byte,所以,读sectorinfo 的时候是下面的顺序:
(前提,写入列地址为2048)
// Read the bad block mark
pSectorInfoBuff->bBadBlock = (BYTE) NF_RDDATA();
// Read the SectorInfo data (we only need to read first 8 bytes)
pSectorInfoBuff->dwReserved1 = NF_DATA_R4();
// OEM byte
pSectorInfoBuff->bOEMReserved = (BYTE) NF_RDDATA();
// Second reserved field (WORD)
pSectorInfoBuff->wReserved2 = ((BYTE) NF_RDDATA() << 8);
pSectorInfoBuff->wReserved2 |= ((BYTE) NF_RDDATA());
原来小page的flash是这样的顺序:
pSectorInfoBuff->dwReserved1 = NF_DATA_R4();
// OEM byte
pSectorInfoBuff->bOEMReserved = (BYTE) NF_DATA_R();
// Read the bad block mark
pSectorInfoBuff->bBadBlock = (BYTE) NF_DATA_R(); //坏块对应的是spare area的6th byte
// Second reserved field (WORD)
pSectorInfoBuff->wReserved2 = ((BYTE) NF_DATA_R() << 8);
pSectorInfoBuff->wReserved2 |= ((BYTE) NF_DATA_R());
稍微梳理一下:
1、 Spare area的格式是开发人员自己规定的,可以从代码里面对Sprae area的读写看出
2、
typedef struct _SectorInfo
{
DWORD dwReserved1; // Reserved - used by FAL
BYTE bOEMReserved; // For use by OEM
BYTE bBadBlock; // Indicates if block is BAD
WORD wReserved2; // Reserved - used by FAL