[Yaffs-archive] Fwd: [YAFFS]Re: NAND changes

Top Page
Attachments:
Message as email
+ (text/plain)
+ yaffs.diff (text/x-diff)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: yaffs
Subject: [Yaffs-archive] Fwd: [YAFFS]Re: NAND changes
Hi Yaffsers

Thanx Thomas. Before I check these in I'd like a second set of eyes over these.
Could someone try out these patches and get back to me?

Thanx

-- CHarles



---------- Forwarded Message ----------

Return-Path: <>
X-Original-To: 
Delivered-To: 
Received: from blood.actrix.co.nz (unknown [192.168.30.20])
    by blonde.actrix.co.nz (Postfix) with ESMTP id 67A32208050
    for <>; Wed, 19 Feb 2003 11:50:38 +1300 (NZDT)
Received: from cmailm5.svr.pol.co.uk (cmailm5.svr.pol.co.uk [195.92.193.21])
    by blood.actrix.co.nz (Postfix) with ESMTP id B4B2220C12C
    for <>; Wed, 19 Feb 2003 11:50:37 +1300 (NZDT)
Received: from modem-976.gazelle.dialup.pol.co.uk ([81.78.67.208] helo=p133)
    by cmailm5.svr.pol.co.uk with esmtp (Exim 4.10.11)
    id 18lGXQ-0003Ia-00; Tue, 18 Feb 2003 22:48:33 +0000
Received: from list by p133 with local (Exim 3.35 #1 (Debian))
    id 18lGjc-0004o2-00; Tue, 18 Feb 2003 23:01:08 +0000
Delivered-To: 
Delivered-To: 
Date: Tue, 18 Feb 2003 23:28:02 +0100
From: Thomas Gleixner <>
Subject: Re: NAND changes
In-reply-to: <>
To: 
Cc: 
Reply-To: 
Message-id: <>
Organization: linutronix
MIME-version: 1.0
Content-type: multipart/mixed;
  boundary="Boundary_(ID_h4GhB29+MM6nsLwOoIsW4A)"
User-Agent: KMail/1.4.1
References: <>
 <>
Resent-Message-ID: <S56vuB.A.ogE.zsrU-@p133>
Resent-From: 
X-Mailing-List: <> archive/latest/234
X-Loop: 
List-Post: <mailto:yaffs@toby-churchill.org>
List-Help: <mailto:yaffs-request@toby-churchill.org?subject=help>
List-Subscribe: <mailto:yaffs-request@toby-churchill.org?subject=subscribe>
List-Unsubscribe: <mailto:yaffs-request@toby-churchill.org?subject=unsubscribe>
Precedence: list
Resent-Sender: 
Resent-Date: Tue, 18 Feb 2003 23:01:08 +0000
Status: R 
X-Status: N
On Tuesday 18 February 2003 18:22, Thomas Gleixner wrote:

> Sorry for making noise. I was slightly brain damaged and confused of a lot
> of discussions. I'm going to change it again. Will make more noise, if
> finished.


Making noise again. Attached a patch against current CVS code.

Sorry for any disturbance or inconvenience.

--
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail:

-------------------------------------------------------


Index: yaffs/yaffs_mtdif.c
===================================================================
RCS file: /home/aleph1/cvs/yaffs/yaffs_mtdif.c,v
retrieving revision 1.7
diff -u -r1.7 yaffs_mtdif.c
--- yaffs/yaffs_mtdif.c    17 Jan 2003 04:19:08 -0000    1.7
+++ yaffs/yaffs_mtdif.c    18 Feb 2003 21:15:26 -0000
@@ -29,6 +29,16 @@
 #include "linux/mtd/nand.h"
 #endif


+struct nand_oobinfo yaffs_oobinfo = {
+    useecc: 1,
+    eccpos: {8, 9, 10, 13, 14, 15}
+};
+
+struct nand_oobinfo yaffs_noeccinfo = {
+    useecc: 0,
+};
+
+
 int nandmtd_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_Spare *spare)
 {
     struct mtd_info *mtd = (struct mtd_info *)(dev->genericDevice);
@@ -43,9 +53,9 @@
     if(data && spare)
     {
         if(dev->useNANDECC)
-            mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,NAND_YAFFS_OOB);
+            mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_oobinfo);
         else
-            mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,NAND_NONE_OOB);
+            mtd->write_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_noeccinfo);
     }
     else
     {
@@ -80,12 +90,12 @@
         if(dev->useNANDECC)
         {
                 u8 tmpSpare[ YAFFS_BYTES_PER_SPARE + (2*sizeof(int)) ];
-            retval = mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,tmpSpare,NAND_YAFFS_OOB);
+            retval = mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,tmpSpare,yaffs_oobinfo);
                 memcpy(spareAsBytes, tmpSpare, YAFFS_BYTES_PER_SPARE);
         }
         else
         {
-            retval = mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,NAND_NONE_OOB);
+            retval = mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_noeccinfo);
         }
     }
     else
Index: yaffs/utils/mkyaffs.c
===================================================================
RCS file: /home/aleph1/cvs/yaffs/utils/mkyaffs.c,v
retrieving revision 1.5
diff -u -r1.5 mkyaffs.c
--- yaffs/utils/mkyaffs.c    13 Dec 2002 00:13:06 -0000    1.5
+++ yaffs/utils/mkyaffs.c    18 Feb 2003 21:15:26 -0000
@@ -66,6 +66,19 @@
 unsigned char oobbuf[16];
 unsigned char imgpage[528];


+/*
+ * OOB layout
+ */
+
+struct nand_oobinfo yaffs_oobinfo = {
+    useecc: 1,
+    eccpos: {8, 9, 10, 13, 14, 15}
+};
+
+struct nand_oobinfo yaffs_noeccinfo = {
+    useecc: 0,
+};
+


 /*
  * Main program
@@ -76,19 +89,26 @@
     unsigned long offset;
     int fd;
     int img=-1;
+    int optcnt = 1;
+    int usemtdecc = 0;
     int imglen = 0;
     struct mtd_oob_buf oob = {0, 16, (unsigned char *) &oobbuf};
     mtd_info_t meminfo;
     erase_info_t erase;
+    struct nand_oobinfo oobsel;


+    if (strcmp (argv[optcnt], "-e") == 0) {
+        optcnt++;
+        usemtdecc = 1;
+    }
+    
     /* Make sure a device was specified */
-    if(argc < 2) {
-        printf("usage: %s <mtdname> [image name]\n", argv[0]);
+    if(argc < (optcnt + 2)) {
+        printf("usage: %s -e <mtdname> <image name>\n", argv[0]);
         exit(1);
     }
-    
-    if(argc > 2 && 
-       (img = open(argv[2],O_RDONLY)) == -1)    {
+
+    if((img = open(argv[optcnt + 1],O_RDONLY)) == -1) {
         perror("opening image file");
         exit(1);
     }
@@ -104,7 +124,7 @@
     lseek(img,0,SEEK_SET);


     /* Open the device */
-    if((fd = open(argv[1], O_RDWR)) == -1) {
+    if((fd = open(argv[optcnt], O_RDWR)) == -1) {
         perror("opening flash");
         exit(1);
     }
@@ -116,6 +136,14 @@
         exit(1);
     }


+    // set the appropriate oob layout selector
+    oobsel = usemtdecc ? &yaffs_oobinfo : &yaffs_noeccinfo;
+    if (ioctl (fd, MEMSETOOBSEL, &oobsel) != 0) {
+        perror ("MEMSETOOBSEL");
+        close (fd);
+        exit (1);
+    } 
+
     /* Make sure device page sizes are valid */
     if( !(meminfo.oobsize == 16 && meminfo.oobblock == 512)) 
     {
@@ -171,12 +199,21 @@
                 for(offset = 0; offset <meminfo.erasesize; offset+=512)
                 {
                     if(read(img,imgpage,528) == 528){
-                        lseek(fd,addr+offset,SEEK_SET);
-                        write(fd,imgpage,512);
+                        if (usemtdecc) {
+                            imgpage[512+8] = 0xff;
+                            imgpage[512+9] = 0xff;
+                            imgpage[512+10] = 0xff;
+                            imgpage[512+13] = 0xff;
+                            imgpage[512+14] = 0xff;
+                            imgpage[512+15] = 0xff;
+                        }
                         oob.start = addr+offset;
                         oob.length=16;
                         oob.ptr=&imgpage[512];
                         ioctl(fd,MEMWRITEOOB,&oob);
+
+                        lseek(fd,addr+offset,SEEK_SET);
+                        write(fd,imgpage,512);
                     }
                 }
             }