|
BSP中的FMD.CPP驱动怎么不一样呢?同样的ReadBlock(DWORD dwBlock, LPBYTE pbBlock, PSectorInfo pSectorInfoTable)当LPBYTE pbBlock不为空时,ECC校验就错了~~是不是驱动问题啊~~~
BOOL FMD_ReadSector(SECTOR_ADDR startSectorAddr, LPBYTE pSectorBuff, PSectorInfo pSectorInfoBuff, DWORD dwNumSectors)
{
ULONG SectorAddr = (ULONG)startSectorAddr;
ULONG MECC;
if (!pSectorBuff && !pSectorInfoBuff)
return(FALSE);
BOOL bLastMode = SetKMode(TRUE);
NF_nFCE_L(); // Select the flash chip.
NF_WAITRB(); // Wait for flash to complete command.
NF_CMD(CMD_RESET); // Send reset command.
NF_WAITRB(); // Wait for flash to complete command.
while (dwNumSectors--)
{
ULONG blockPage = (((SectorAddr / NAND_PAGE_CNT) * NAND_PAGE_CNT) | (SectorAddr % NAND_PAGE_CNT));
if (!pSectorBuff)
{
NF_CMD(CMD_READ2); // Send read confirm command.
NF_WAITRB(); // Wait for command to complete.
NF_ADDR(0); // Column = 0.
NF_ADDR(blockPage & 0xff); // Page address.
NF_ADDR((blockPage >> 8) & 0xff);
if (NEED_EXT_ADDR)
NF_ADDR((blockPage >> 16) & 0xff);
NF_WAITRB(); // Wait for command to complete.
RdPageInfo((PBYTE)pSectorInfoBuff); // Read page/sector information.
pSectorInfoBuff++;
}
else
{
NF_CMD(CMD_READ); // Send read command.
NF_WAITRB(); // Wait for command to complete.
NF_ADDR(0); // Column = 0.
NF_ADDR(blockPage & 0xff); // Page address.
NF_ADDR((blockPage >> 8) & 0xff);
if (NEED_EXT_ADDR)
NF_ADDR((blockPage >> 16) & 0xff);
NF_WAITRB(); // Wait for command to complete.
// Handle unaligned buffer pointer
NF_RSTECC();
NF_MECC_UnLock();
if( ((DWORD) pSectorBuff) & 0x3)
{
RdPage512Unalign (pSectorBuff);
}
else
{
RdPage512(pSectorBuff); // Read page/sector data.
}
NF_MECC_Lock();
if (pSectorInfoBuff)
{
RdPageInfo((PBYTE)pSectorInfoBuff); // Read page/sector information.
pSectorInfoBuff ++;
}
else
{
BYTE TempInfo[8];
RdPageInfo(TempInfo); // Read page/sector information.
}
MECC = NF_RDDATA() << 0;
MECC |= NF_RDDATA() << 8;
MECC |= NF_RDDATA() << 16;
MECC |= NF_RDDATA() << 24;
NF_WRMECCD0( ((MECC&0xff00)<<8)|(MECC&0xff) );
NF_WRMECCD1( ((MECC&0xff000000)>>8)|((MECC&0xff0000)>>16) );
if (NF_RDESTST0 & 0x3)
{
RETAILMSG(1,(TEXT("ecc error %x %x \r\n"),NF_RDMECC0(),MECC));
NF_nFCE_H(); // Deselect the flash chip.
SetKMode (bLastMode);
return FALSE;
}
pSectorBuff += NAND_PAGE_SIZE;
}
++SectorAddr;
}
NF_nFCE_H(); // Deselect the flash chip.
SetKMode (bLastMode);
return(TRUE);
}
|
|