怎么查nandflash的坏块
1个回答
展开全部
首先调用erase,将NAND全部擦除一遍,然后执行如下检测操作,
如果页大于512字节,
badblockpos = 0;
badblockbytes = 2;
如果页小于512字节,
badblockpos = 5;
badblockbytes = 1;
读取每个block的前两页OOB区域的第badblockpos开始的后badblockbytes字节是否为0xff,
如果是,那么说明该block是好的,否则该block是坏块[gliethttp_20080523]!
UINT_T create_bbt(FlashBootType_T fbt)
{
UINT_T Retval;
P_FlashProperties_T pFlashP = GetFlashProperties(fbt);
UINT_T BlkSize,BlkNum;
UINT_T flash_addr;
#define page_size (2048)
#define page_spare_size (64)
#define block_size (64*page_size)
#define tmp_buffer_addr (0x80200000 - page_size - page_spare_size)
#define tmp_spare_buffer_addr (tmp_buffer_addr + page_size)
int i,j;
char *bbpos;
bbpos = (char*)(tmp_spare_buffer_addr + 0);
BlkSize = pFlashP->BlockSize;
BlkNum = pFlashP->NumBlocks;
for(i = 0;i < BlkNum;i++)
{
flash_addr = i * BlkSize;
for(j = 0;j < 2;j++)
{
Retval = xdfc_read((UINT_T *)tmp_buffer_addr, flash_addr + j*page_size, page_size, (UINT_T *)tmp_spare_buffer_addr, GetNANDProperties());
if(Retval)
{
goto __create_bbt_mark;
}
if(bbpos[0] != 0xff)goto __create_bbt_mark;
if(bbpos[1] != 0xff)goto __create_bbt_mark;
}
continue;
__create_bbt_mark:
RelocateBlock( i, &GetFMProperties()->BBT, fbt );
}
}
如果页大于512字节,
badblockpos = 0;
badblockbytes = 2;
如果页小于512字节,
badblockpos = 5;
badblockbytes = 1;
读取每个block的前两页OOB区域的第badblockpos开始的后badblockbytes字节是否为0xff,
如果是,那么说明该block是好的,否则该block是坏块[gliethttp_20080523]!
UINT_T create_bbt(FlashBootType_T fbt)
{
UINT_T Retval;
P_FlashProperties_T pFlashP = GetFlashProperties(fbt);
UINT_T BlkSize,BlkNum;
UINT_T flash_addr;
#define page_size (2048)
#define page_spare_size (64)
#define block_size (64*page_size)
#define tmp_buffer_addr (0x80200000 - page_size - page_spare_size)
#define tmp_spare_buffer_addr (tmp_buffer_addr + page_size)
int i,j;
char *bbpos;
bbpos = (char*)(tmp_spare_buffer_addr + 0);
BlkSize = pFlashP->BlockSize;
BlkNum = pFlashP->NumBlocks;
for(i = 0;i < BlkNum;i++)
{
flash_addr = i * BlkSize;
for(j = 0;j < 2;j++)
{
Retval = xdfc_read((UINT_T *)tmp_buffer_addr, flash_addr + j*page_size, page_size, (UINT_T *)tmp_spare_buffer_addr, GetNANDProperties());
if(Retval)
{
goto __create_bbt_mark;
}
if(bbpos[0] != 0xff)goto __create_bbt_mark;
if(bbpos[1] != 0xff)goto __create_bbt_mark;
}
continue;
__create_bbt_mark:
RelocateBlock( i, &GetFMProperties()->BBT, fbt );
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |