Hi Charles,

I am a Chinese engineer in Linux drivers. I am using your nandemul2k in YAFFS2 to simulate NAND FLASH with 2k page size recently. I find I always can’t write and read OOBs right. So I had to trace your codes to find the reason.

At last, I found you made a great mistake in nand_write_oob() function. You call nandemul2k_Program (buf, page, 512 + col,len) in the function. That will write OOB to wrong places. You should verify it to

nandemul2k_Program(buf,page,PAGE_DATA_SIZE + col,len);

When I changed like that, I read and wrote the pages and oobs of NAND in RAW and YAFFS2 mode successfully.

Since your codes are used so far and wide in the world, I’d like you can change it ASAP before puzzling more engineers.

Another bug:

Your nandemul2k will crash when erased by flash_eraseall tool. Then I tested it by MEMERASE ioctl, it was proved your emulation would crash indeed when erasing. Since that doesn’t affect my using, I will not trace the bug. Would you?

Test codes I used:

/* read oob*/

if (ioctl(fd_mtd, MEMREADOOB, &oob) != 0)

{

  perror("ioctl(MEMREADOOB) fail");

}

/* write oob*/

if (ioctl(fd_mtd, MEMWRITEOOB, &oob) != 0)

{

  perror("ioctl(MEMWRITEOOB) fail");

}

/* erase blocks */

if (ioctl(fd_mtd, MEMERASE, &erase) != 0)    //crash here!!!!!

{

  perror("MTD Erase failure");

}

 

Thanks and best regards

Baohua Song