Hi,
Have you resolved this problem? Maybe it is a late reply. Because I have just understood the mtd and nand driver's structure.
This problem is caused by the mis-match between mkyaffs2image tool and nandwrite command of mtd-utils. Please look at the function write_chunk() in mkyaffs2imge.c, you will see the yaffs2 tags will be located in first 28 bytes in oob area. It will cause conflicts while there is some bytes in the first location used for NAND ECC, so you can manually move the yaffs2 tags to the available oob area.
To read the source code of linux mtd. you will find a data struct for oob autoplacement mechanism located in drivers/mtd/nand/nand_base.c
static struct nand_ecclayout nand_oob_64 = {
.eccbytes = 24,
.eccpos = {
40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, 52, 53, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63},
.oobfree = {
{.offset = 2,
.length = 38}}
};
This is the default ecclayout of the large-page nand chip while you do not set the one in you nand specific driver. The tags of the yaffs2 filesystem should be placed into the oobfree area. ( from index 2 to 39 ).
So you can modified the function write_chunk() in mkyaffs2image.c as followed:
static int write_chunk(__u8 *data, __u32 objId, __u32 chunkId, __u32 nBytes)
{
yaffs_ExtendedTags t;
yaffs_PackedTags2 pt;
unsigned char oobbuf[ 64 ];
unsigned char *u8;
int len;
memset ( oobbuf, 0xFF, sizeof ( oobbuf ) );
error = write(outFile,data,chunkSize);
if(error < 0) return error;
yaffs_InitialiseTags(&t);
t.chunkId = chunkId;
// t.serialNumber = 0;
t.serialNumber = 1; // **CHECK**
t.byteCount = nBytes;
t.objectId = objId;
t.sequenceNumber = YAFFS_LOWEST_SEQUENCE_NUMBER;
// added NCB **CHECK**
t.chunkUsed = 1;
if (convert_endian)
{
little_to_big_endian(&t);
}
nPages++;
yaffs_PackTags2(&pt,&t);
len = sizeof ( pt );
u8 = ( unsigned char * ) ( &pt );
memcpy ( oobbuf + 2, u8, len );
// return write(outFile,&pt,sizeof(yaffs_PackedTags2));
//return write(outFile,&pt,spareSize);
return write(outFile,oobbuf,spareSize);
}
The high-lighted code is modified by me. You can take a try. Any questions you can contact me using this email address. ( In Chinese )
BR
Jerry (Õ½Ü)
Hi,Please forgive me if this is not the place to ask such kind of questions.I checkout the latest yaffs2 code and patched to kernel. The kernel options are:<*> YAFFS2 file system support
-*- 512 byte / page devices
[ ] Use older-style on-NAND data format with pageStatus byte
[ ] Lets Yaffs do its own ECC
-*- 2048 byte (or larger) / page devices
[*] Autoselect yaffs2 format
[ ] Disable lazy loading
[ ] Turn off wide tnodes
[ ] Force chunk erase check
[*] Cache short names in RAMI created a yaffs2 file system with mkyaffs2image, and then I "burned" the image to flash:flash_eraseall /dev/mtd2
nandwrite -a -o /dev/mtd2 ./rootfs.yaffs2After successfully (?) mounting the root fs I found there is nothing except a empty lost+found directory.kernel version: 2.6.24.Flash type: (Sumsung K9F4G08U0A)I appreciate your help.
_______________________________________________
yaffs mailing list
yaffs@lists.aleph1.co.uk
http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs