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

Charles Manning manningc2@actrix.gen.nz
Fri, 21 Feb 2003 09:23:43 +1300


--------------Boundary-00=_JBJMQVEE9ZLWYB6927B7
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

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: <yaffs-request@banenet.co.uk>
X-Original-To: manningc2@actrix.gen.nz
Delivered-To: manningc2@actrix.gen.nz
Received: from blood.actrix.co.nz (unknown [192.168.30.20])
	by blonde.actrix.co.nz (Postfix) with ESMTP id 67A32208050
	for <manningc2@actrix.gen.nz>; 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 <manningc2@actrix.gen.nz>; 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: toby-churchill-org-info@toby-churchill.org
Delivered-To: toby-churchill-org-yaffs@toby-churchill.org
Date: Tue, 18 Feb 2003 23:28:02 +0100
From: Thomas Gleixner <tglx@linutronix.de>
Subject: Re: NAND changes
In-reply-to: <200302181822.03529.tglx@linutronix.de>
To: yaffs@toby-churchill.org
Cc: manningc2@actrix.gen.nz
Reply-To: tglx@linutronix.de
Message-id: <200302182328.02908.tglx@linutronix.de>
Organization: linutronix
MIME-version: 1.0
Content-type: multipart/mixed;
  boundary="Boundary_(ID_h4GhB29+MM6nsLwOoIsW4A)"
User-Agent: KMail/1.4.1
References: <200302181430.30132.tglx@linutronix.de>
 <200302181822.03529.tglx@linutronix.de>
Resent-Message-ID: <S56vuB.A.ogE.zsrU-@p133>
Resent-From: yaffs@toby-churchill.org
X-Mailing-List: <yaffs@toby-churchill.org> archive/latest/234
X-Loop: yaffs@toby-churchill.org
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: yaffs-request@toby-churchill.org
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: tglx@linutronix.de

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



--------------Boundary-00=_JBJMQVEE9ZLWYB6927B7
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="yaffs.diff"
Content-Transfer-Encoding: 7BIT
Content-Disposition: attachment; filename=yaffs.diff

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);
 					}
 				}
 			}

--------------Boundary-00=_JBJMQVEE9ZLWYB6927B7--

---------------------------------------------------------------------------------------
This mailing list is hosted by Toby Churchill open software (www.toby-churchill.org).
If mailing list membership is no longer wanted you can remove yourself from the list by 
sending an email to yaffs-request@toby-churchill.org with the text "unsubscribe" 
(without the quotes) as the subject.