u8 FTL_BlockCompare(u32 blockx,u32 cmpval)
{
u8 res;
u16 i,j,k;
for(i=0;i<3;i++)//允许3次机会
{
for(j=0;j<nand_dev.block_pagenum;j++)
{
NAND_ReadPageComp(
blockx*nand_dev.block_pagenum,0,cmpval,nand_dev.page_mainsize/4,&k);//检查一个page,并与0XFFFFFFFF对比
if(k!=(nand_dev.page_mainsize/4))break;
}
if(j==nand_dev.block_pagenum)return 0; //检查合格,直接退出
res=NAND_EraseBlock(blockx);
if(res)printf("error erase block:%d
",i);
else
{
if(cmpval!=0XFFFFFFFF)//不是判断全1,则需要重写数据
{
for(k=0;k<nand_dev.block_pagenum;k++)
{
NAND_WritePageConst(blockx*nand_dev.block_pagenum+k,0,0,nand_dev.page_mainsize/4);//写PAGE
}
}
}
}
printf("bad block checked:%d
",blockx);
return 1;
}
@正点原子 原子哥标记的这个是不是要加上+j,不然后面的63个page就没检测到了
一周热门 更多>