|
引用 14 楼 sunrain_hjb 的回复:
如果在正常操作的情况不会产生就可以。
拷贝文件时断电,这在PC上也会产生类似的文件,因为已经是非法操作了。
主要是 我是在拷贝结束后 才正常断电的 没有非法操作
这个是 FLASH(k9f1g08) 驱动中 写的部分
BYTE Status;
ULONG SectorAddr = (ULONG)startSectorAddr;
DWORD i;
if (!pSectorBuff && !pSectorInfoBuff)
return(FALSE);
NF_RSTECC(); // Initialize ECC.
NF_nFCE_L(); // Select the flash chip.
NF_CLEAR_RB();
NF_CMD(CMD_RESET); // Send reset command.
for(i=0;i<10;i++);
NF_DETECT_RB();
while (dwNumSectors--)
{
ULONG blockPage = SectorAddr;//(((SectorAddr / NAND_PAGE_CNT) * NAND_PAGE_CNT) | (SectorAddr % NAND_PAGE_CNT));
if (!pSectorBuff)
{
NF_CLEAR_RB();
NF_CMD(CMD_WRITE); // Write 1st command
NF_ADDR((2048+0)&0xff); // Column (A[7:0]) = 0
NF_ADDR(((2048+0)>>8)&0xff); // A[11:8]
NF_ADDR((blockPage)&0xff); // A[19:12]
NF_ADDR((blockPage>>8)&0xff); // A[27:20]
#if (K9F2G08_SUPPORT||K9F4G08_SUPPORT||K9F8G08_SUPPORT)
if((g_pNandFlashChip->FlashID!=0xECF1)&&(g_pNandFlashChip->FlashID!=0xECA1))
NF_ADDR((blockPage>>16)&0xff);
#endif
NF_WRDATA( (pSectorInfoBuff->bBadBlock) );
// Write the first reserved field (DWORD)
NF_DATA_W4(pSectorInfoBuff->dwReserved1);
// Write OEM reserved flag
NF_WRDATA( (pSectorInfoBuff->bOEMReserved) );
// Write the second reserved field
NF_WRDATA( (pSectorInfoBuff->wReserved2 >> 8) & 0xff );
NF_WRDATA( (pSectorInfoBuff->wReserved2) & 0xff );
pSectorInfoBuff++;
}
else
{
NF_CLEAR_RB();
NF_CMD(CMD_WRITE); // Write 1st command
NF_ADDR(0); // Column (A[7:0]) = 0
NF_ADDR(0); // A[11:8]
NF_ADDR((blockPage)&0xff); // A[19:12]
NF_ADDR((blockPage>>8)&0xff); // A[27:20]
#if (K9F2G08_SUPPORT||K9F4G08_SUPPORT||K9F8G08_SUPPORT)
if((g_pNandFlashChip->FlashID!=0xECF1)&&(g_pNandFlashChip->FlashID!=0xECA1))
NF_ADDR((blockPage>>16)&0xff);
#endif
if( ((DWORD) pSectorBuff) & 0x3)
{
// Write the data
WrPage2048Unalign (pSectorBuff,(PULONG)&s2440NAND->rNFDATA);
RETAILMSG(1,(TEXT("o")));
Sleep(1);
}
else
{
WrPage2048(pSectorBuff,(PULONG)&s2440NAND->rNFDATA); // Write page/sector data.
RETAILMSG(1,(TEXT("x")));
Sleep(1);
}
if(pSectorInfoBuff)
{
// Write the bad block flag
NF_WRDATA( (pSectorInfoBuff->bBadBlock) );
// Write the first reserved field (DWORD)
NF_DATA_W4(pSectorInfoBuff->dwReserved1);
// Write OEM reserved flag
NF_WRDATA( (pSectorInfoBuff->bOEMReserved) );
// Write the second reserved field
NF_WRDATA( (pSectorInfoBuff->wReserved2 >> 8) & 0xff );
NF_WRDATA( (pSectorInfoBuff->wReserved2) & 0xff );
pSectorInfoBuff++;
}
pSectorBuff += NAND_PAGE_SIZE;
}
NF_CLEAR_RB();
NF_CMD(CMD_WRITE2); // Send write confirm command.
// Wait for RB
NF_DETECT_RB(); // Wait tR(max 12us)
// Check the status
NF_CMD(CMD_STATUS);
Status = NF_RDDATA();
if (Status & 1)
{
NF_nFCE_H(); // Deselect the flash chip.
//SetKMode (bLastMode);
#ifdef BOOT_LOADER
EdbgOutputDebugString("ERROR: FMD_WriteSector: failed sector write.\r\n");
#else
RETAILMSG(1,(TEXT("ERROR: FMD_WriteSector: failed sector write.\r\n")));
#endif
return(FALSE);
}
// NF_nFCE_H(); // Deselect the flash chip.
++SectorAddr;
}
NF_nFCE_H(); // Deselect the flash chip.
//SetKMode (bLastMode);
return(TRUE); |
|