我根据BSP里面的NAND YAFFS2的例程调试NANDFLASH。
我现在不想使用YAFFS2文件系统。想直接调NANDflash驱动写。
int main(void)
{
char *ptr;
char mtpoint[] = "user";
char buf[8];
int vola
tile i;
sysInitializeUART();
sysprintf("\n");
sysprintf("==========================================\n");
sysprintf(" FMI NAND YAFFS2 \n");
sysprintf("==========================================\n");
sysDisableCache();
sysInvalidCache();
sysSetMMUMappingMethod(MMU_DIRECT_MAPPING);
sysEnableCache(CACHE_WRITE_BACK);
SYS_Init();
nand_init();
// cmd_yaffs_devconfig(mtpoint, 0, 0x10, 0x14);
// cmd_yaffs_dev_ls();
// cmd_yaffs_mount(mtpoint);
// cmd_yaffs_dev_ls();
nand_read_chip();
while(1)
{
}
}
void nand_read_chip(void)
{
struct mtd_info *mtd = &nand_info[0];
struct nand_chip *nand = &nand_chip[0];
size_t retlen;
u_char buf1[2048];
u_char buf[2048];
unsigned int i=0;
struct erase_info ei;
int retval = 0;
//擦除
ei.mtd = mtd;
ei.addr = 0x1600000;
//// ei.len = dev->data_bytes_per_chunk * dev->param.chunks_per_block;
ei.len = 2048*64;
ei.time = 1000;
ei.retries = 2;
ei.callback = NULL;
ei.priv = 0;
/* Todo finish off the ei if required */
retval = mtd->erase(mtd, &ei);
//写
memset(buf, 0x88, 2048);
mtd->write(mtd ,0x1600000,2048,&retlen,buf);
//读
mtd->read(mtd ,0x1600000,2048,&retlen,buf1);
for(i =0; i < 2048; i++)
sysPutChar(buf1[i]);
}
擦除,写,读数据不成功,有没有人调试过