Re: [Yaffs] Problem with Yaffs on Routerboard RB112 and kern…

Top Page
Attachments:
Message as email
+ (text/plain)
+ yaffs_mtdif.diff (text/x-patch)
Delete this message
Reply to this message
Author: Claudio Lanconelli
Date:  
To: yaffs
Subject: Re: [Yaffs] Problem with Yaffs on Routerboard RB112 and kernel 2.6.19
David Goodenough wrote:
> On Monday 14 May 2007, Claudio Lanconelli wrote:
>
>> Hi David,
>>
>> I suggest you to try this with the latest Yaffs + recent kernel (2.6.19
>> or newer):
>>
>> Use MTD_OOB_AUTO with the following layout (as suggested by Ian):
>>
> Where do I put the MTD_OOB_AUTO?
>

It's the default, you can find it in mtdif.c nandmtd_WriteChunkToNAND() and
nandmtd_ReadChunkFromNAND().
>> static struct nand_ecclayout nand_oob_16 = {
>>     .eccbytes = 6,
>>     .eccpos = { 9, 8, 10, 14, 13, 15 },
>>     .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 } }
>> };

>>
>> with CONFIG_NAND_ECC_SMC = N
>>
> Ian suggested using .oobfree 0,5 not 0,4 for the newer MTD API,
> and I am using the newer MTD API as far as I know.
>
> This is the form I am using with ...ECC_SMC = N.
>
> But he also suggested:-
>
>>> AND fix up the yaffs pack/unpack funcs and calls to MTD
>>> read/write to understand this. The block status can be gotten
>>> the same way, but this should only be needed by the scan step
>>> and can be retrieved from the (new) mtd using the bad-block test
>>> call.
>>>
> and I do not know how to do this or whether you are saying that
> this should not be necessary.
>

You can try the simple way first, with oobfree 0,4 and no change in mtdif.c.

If it doesn't work you can try oob 0,5 but you should fix mtdif.c.
Try this patch

Index: yaffs_mtdif.c
===================================================================
RCS file: /home/aleph1/cvs/yaffs2/yaffs_mtdif.c,v
retrieving revision 1.19
diff -u -r1.19 yaffs_mtdif.c
--- yaffs_mtdif.c    14 Feb 2007 01:09:06 -0000    1.19
+++ yaffs_mtdif.c    14 May 2007 14:56:20 -0000
@@ -44,11 +44,11 @@
     oob[2] = spare->tagByte2;
     oob[3] = spare->tagByte3;
     oob[4] = spare->tagByte4;
-    oob[5] = spare->tagByte5 & 0x3f;
-    oob[5] |= spare->blockStatus == 'Y' ? 0: 0x80;
-    oob[5] |= spare->pageStatus == 0 ? 0: 0x40;
-    oob[6] = spare->tagByte6;
-    oob[7] = spare->tagByte7;
+    oob[5] = spare->pageStatus;
+    oob[6] = spare->tagByte5 & 0x3f;
+    oob[6] |= spare->blockStatus == 'Y' ? 0: 0x80;
+    oob[7] = spare->tagByte6;
+    oob[8] = spare->tagByte7;
 }


 static inline void translate_oob2spare(yaffs_Spare *spare, __u8 *oob)
@@ -59,12 +59,12 @@
     spare->tagByte2 = oob[2];
     spare->tagByte3 = oob[3];
     spare->tagByte4 = oob[4];
-    spare->tagByte5 = oob[5] == 0xff ? 0xff : oob[5] & 0x3f;
-    spare->blockStatus = oob[5] & 0x80 ? 0xff : 'Y';
-    spare->pageStatus = oob[5] & 0x40 ? 0xff : 0;
+    spare->pageStatus = oob[5];
+    spare->blockStatus = oob[6] & 0x80 ? 0xff : 'Y';
+    spare->tagByte5 = oob[6] == 0xff ? 0xff : oob[5] & 0x3f;
     spare->ecc1[0] = spare->ecc1[1] = spare->ecc1[2] = 0xff;
-    spare->tagByte6 = oob[6];
-    spare->tagByte7 = oob[7];
+    spare->tagByte6 = oob[7];
+    spare->tagByte7 = oob[8];
     spare->ecc2[0] = spare->ecc2[1] = spare->ecc2[2] = 0xff;


     nspare->eccres1 = nspare->eccres2 = 0; /* FIXME */
@@ -83,7 +83,7 @@


     loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
-    __u8 spareAsBytes[8]; /* OOB */
+    __u8 spareAsBytes[9]; /* OOB */


     if (data && !spare)
         retval = mtd->write(mtd, addr, dev->nDataBytesPerChunk,
@@ -92,7 +92,7 @@
         if (dev->useNANDECC) {
             translate_spare2oob(spare, spareAsBytes);
             ops.mode = MTD_OOB_AUTO;
-            ops.ooblen = 8; /* temp hack */
+            ops.ooblen = 9; /* temp hack */
         } else {
             ops.mode = MTD_OOB_RAW;
             ops.ooblen = YAFFS_BYTES_PER_SPARE;
@@ -147,7 +147,7 @@


     loff_t addr = ((loff_t) chunkInNAND) * dev->nDataBytesPerChunk;
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
-    __u8 spareAsBytes[8]; /* OOB */
+    __u8 spareAsBytes[9]; /* OOB */


     if (data && !spare)
         retval = mtd->read(mtd, addr, dev->nDataBytesPerChunk,
@@ -155,7 +155,7 @@
     else if (spare) {
         if (dev->useNANDECC) {
             ops.mode = MTD_OOB_AUTO;
-            ops.ooblen = 8; /* temp hack */
+            ops.ooblen = 9; /* temp hack */
         } else {
             ops.mode = MTD_OOB_RAW;
             ops.ooblen = YAFFS_BYTES_PER_SPARE;