If the page is larger than 5 12 bytes,
badblockpos = 0;
bad block bytes = 2;
If the page is less than 5 12 bytes,
badblockpos = 5;
bad block bytes = 1;
Reading whether the last badblockbytes byte starting from badblockpos in the OOB area of the first two pages of each block is 0xff,
If yes, then the block is good, otherwise the block is bad [gliethttp_20080523]!
UINT_T create_bbt
{
UINT _ T Retval
p _ flash properties _ T pFlashP = getflash properties(fbt);
UINT_T BlkSize,BlkNum
UINT _ T flash _ addr
# Define Page Size (2048)
# Define Page Spare Size (64)
# Define the 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
bb pos =(char *)(tmp _ spare _ buffer _ addr+0);
BlkSize = pFlashP->。 BlockSize
blk num = pFlashP-& gt; Digital block;
for(I = 0; I & ltBlkNumi++)
{
flash _ addr = i * BlkSize
for(j = 0; j & lt2; j++)
{
retval = xdfc _ read((UINT _ T *)tmp _ buffer _ addr,flash_addr + j*page_size,page_size,(UINT_T *)tmp_spare_buffer_addr,GetNANDProperties());
If (return)
{
goto _ _ create _ bbt _ mark
}
if(bbpos[0]! = 0x ff)goto _ _ create _ bbt _ mark;
if(bbpos[ 1]! = 0x ff)goto _ _ create _ bbt _ mark;
}
Continue;
__create_bbt_mark:
Relocation block (I&; GetFMProperties()-& gt; BBT,fbt);
}
}