[Yaffs-archive] RE: [YAFFS]Re: NAND changes
Christian Gan
cgan@iders.ca
Fri, 21 Feb 2003 16:52:49 -0600
This is a multi-part message in MIME format.
------=_NextPart_000_0065_01C2D9C9.AA9F3690
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hey people,
I'm just starting to catch up on getting the newest MTD and YAFFS to use for
our board. I'm having strange problems but I'm just beginning to
investigate so right now it could be anything (hw or sw). I'll get back to
you if I get stuck.
BUT, I did have a chance to try the new patch a shot and found a small
compile error for mkyaffs.c. I took Thomas' patch and edited it with a
small change, it is attached.
Changed:
+ oobsel = usemtdecc ? &yaffs_oobinfo : &yaffs_noeccinfo;
To:
+ oobsel = usemtdecc ? yaffs_oobinfo : yaffs_noeccinfo;
Since oobsel is not a pointer.
Christian
> -----Original Message-----
> From: Charles Manning [mailto:manningc2@actrix.gen.nz]
> Sent: Thursday, February 20, 2003 2:24 PM
> To: yaffs@toby-churchill.org
> Subject: 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: <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
>
> -------------------------------------------------------
>
>
>
------=_NextPart_000_0065_01C2D9C9.AA9F3690
Content-Type: application/octet-stream;
name="yaffs.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="yaffs.diff"
Index: yaffs/yaffs_mtdif.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D {
+ useecc: 1,
+ eccpos: {8, 9, 10, 13, 14, 15}
+};
+
+struct nand_oobinfo yaffs_noeccinfo =3D {
+ useecc: 0,
+};
+
+
int nandmtd_WriteChunkToNAND(yaffs_Device *dev,int chunkInNAND,const =
__u8 *data, yaffs_Spare *spare)
{
struct mtd_info *mtd =3D (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,&yaf=
fs_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,&yaf=
fs_noeccinfo);
}
else
{
@@ -80,12 +90,12 @@
if(dev->useNANDECC)
{
u8 tmpSpare[ YAFFS_BYTES_PER_SPARE + (2*sizeof(int)) ];
- retval =3D =
mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,tmpSpare,NAND_YAFF=
S_OOB);
+ retval =3D =
mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,tmpSpare,yaffs_oob=
info);
memcpy(spareAsBytes, tmpSpare, YAFFS_BYTES_PER_SPARE);
}
else
{
- retval =3D =
mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,NAND_=
NONE_OOB);
+ retval =3D =
mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaff=
s_noeccinfo);
}
}
else
Index: yaffs/utils/mkyaffs.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D {
+ useecc: 1,
+ eccpos: {8, 9, 10, 13, 14, 15}
+};
+
+struct nand_oobinfo yaffs_noeccinfo =3D {
+ useecc: 0,
+};
+
/*
* Main program
@@ -76,19 +89,26 @@
unsigned long offset;
int fd;
int img=3D-1;
+ int optcnt =3D 1;
+ int usemtdecc =3D 0;
int imglen =3D 0;
struct mtd_oob_buf oob =3D {0, 16, (unsigned char *) &oobbuf};
mtd_info_t meminfo;
erase_info_t erase;
+ struct nand_oobinfo oobsel;
+ if (strcmp (argv[optcnt], "-e") =3D=3D 0) {
+ optcnt++;
+ usemtdecc =3D 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 =3D open(argv[2],O_RDONLY)) =3D=3D -1) {
+
+ if((img =3D open(argv[optcnt + 1],O_RDONLY)) =3D=3D -1) {
perror("opening image file");
exit(1);
}
@@ -104,7 +124,7 @@
lseek(img,0,SEEK_SET);
/* Open the device */
- if((fd =3D open(argv[1], O_RDWR)) =3D=3D -1) {
+ if((fd =3D open(argv[optcnt], O_RDWR)) =3D=3D -1) {
perror("opening flash");
exit(1);
}
@@ -116,6 +136,14 @@
exit(1);
}
+ // set the appropriate oob layout selector
+ oobsel =3D usemtdecc ? yaffs_oobinfo : yaffs_noeccinfo;
+ if (ioctl (fd, MEMSETOOBSEL, &oobsel) !=3D 0) {
+ perror ("MEMSETOOBSEL");
+ close (fd);
+ exit (1);
+ }
+
/* Make sure device page sizes are valid */
if( !(meminfo.oobsize =3D=3D 16 && meminfo.oobblock =3D=3D 512))
{
@@ -171,12 +199,21 @@
for(offset =3D 0; offset <meminfo.erasesize; offset+=3D512)
{
if(read(img,imgpage,528) =3D=3D 528){
- lseek(fd,addr+offset,SEEK_SET);
- write(fd,imgpage,512);
+ if (usemtdecc) {
+ imgpage[512+8] =3D 0xff;
+ imgpage[512+9] =3D 0xff;
+ imgpage[512+10] =3D 0xff;
+ imgpage[512+13] =3D 0xff;
+ imgpage[512+14] =3D 0xff;
+ imgpage[512+15] =3D 0xff;
+ }
oob.start =3D addr+offset;
oob.length=3D16;
oob.ptr=3D&imgpage[512];
ioctl(fd,MEMWRITEOOB,&oob);
+
+ lseek(fd,addr+offset,SEEK_SET);
+ write(fd,imgpage,512);
}
}
}
------=_NextPart_000_0065_01C2D9C9.AA9F3690--
---------------------------------------------------------------------------------------
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.