Why nandwrite success but mount complain?
--------------------------------------------------------------------------------
Hi,
My kernel is 2.4.26 mipsel with mtd snapshot 20050416. I erase and program my nand device this way:
# flash_eraseall -j /dev/mtd/3 # mkfs.jffs2 -n -e 16KiB -m none -o nddemo.jffs2 -d /demo # nandwrite -p /dev/mtd/3 nddemo.jffs2 # mount /dev/mtdblock/3 /mnt
The mount did succeed! But there are some dumping messeges and ECC errors. After mounted, some of programs under /mnt could be executed correctly but some others couldn't.
The error messages are like the following during mounting a NAND partition:
#mount /dev/mtdblock3 /mnt
......
--> mtd->read(0x400 bytes from 0xc000) returned ECC error
--> jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000c154:0x05b7 instead
--> jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000c158:0x83a0 instead
......
I nanddump the data from /dev/mtd/3 to a file nandmtd3.dump and look at it:
--> 0x0000c150: 12 00 0b 00 b7 05 00 00 a0 83 41 00 00 00 00 00
I hexedit my JFFS2 image nddemo.jffs2 and look at it:
--> 0x0000c150: 8C 48 44 00 85 19 02 E0 44 10 00 00 6D 58 D1 84
The data indicate the complaints from while mounting JFFS2 is really justified!
Then why nandwrite programing most of data within nddemo.jffs2 correctly but not all of them? BTW, my nddemo.jffs2 is about 8MB.
Which codes should I dig into:
1) NAND Flash drvier?
2) NAND Flash core layer?
3) JFFS2 wbuf.c and other JFFS2 codes in the kernel?
4) the nandwrite program itself?
Please give me some suggestions. Thanks!
Carl Liao
Quoted 6 lines · carl liao
Which codes should I dig into:
1) NAND Flash drvier?
2) NAND Flash core layer?
3) JFFS2wbuf.cand other JFFS2 codes in the kernel?
4) the nandwrite program itself?
I suspect 1.
Signature · 3 lines
Best Regards, Artem B. Bityuckiy, St.-Petersburg, Russia.
This "bug" relates to JFFS2.
User space tools are able to build a file system using 16KiB erase block size, but the kernel part of JFFS2 itself does not support it.
This is because JFFS2 uses kmalloc for allocating memory for jffs2_eraseblock structs. Smaller erase block size means more of this and more memory needed for storage. And kmalloc allows max. 128K allocations. (using 32K block size instead of 16K block size halves the memory requirements)
See jffs2_do_fill_super in fs.c
It's not very easy to circumvent this problem. Memory allocation and handling of jffs2_eraseblocks should be modified.
Bye,
Patrik Kluba