- 论坛徽章:
- 0
|
把sumsung的flash 16M*8 的驱动从LINUX 2.4 移植到 linux 2.6后。
不管对flash写入什么数据,读出的数据都是oxff是怎么回事呢?
代码如下:
printk("********************************************\n");
struct nftl_oob oob;
size_t retlen;
int j;
memset(&oob,0xff,sizeof(struct nftl_oob));
oob.b.Status = oob.b.Status1 = SECTOR_USED;
unsigned int block;
u8 buf[SECTORSIZE];
printk("***FORMAT SECTOR\n");
int i;
for(i=0;i<512;i++)
buf[i]=0x11;
for (block = 0; block < nftl->nb_blocks; block++)
{
if (NFTL_formatblock(nftl, block) < 0)
printk("format error\n");
// if( MTD_WRITECC(nftl->mbd.mtd, block * nftl->EraseSize,512, &retlen, (char *)buf, (char *)&oob, &nftl->oobinfo)<0)
if( MTD_WRITE(nftl->mbd.mtd, block * nftl->EraseSize,512, &retlen, (char *)buf)<0)
{
printk("write error\n");
}
}
printk("\n");
for(j=0;j<512;j++)
{
printk("0x%02x ",buf[j]);
}
if(MTD_READ(nftl->mbd.mtd, 0 * nftl->EraseSize, SECTORSIZE, &retlen, buf)<0)
printk("read error\n");
printk("\n");
for(j=0;j<512;j++)
{
printk("0x%02x ",buf[j]);
}
printk("****************************************************\n"); |
|