Skip to contentSkip to conversation

A question on ECC

DISCUSSION Edward Lee \(이장원\) 5 participants 14 messages Apr 14, 2003 – Apr 19, 2003 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hello. I'm Edward Lee in Korea.

I'm using samsung NAND flash, with YAFFS on it..
But I'm having problems with ECC.
I wrote a file that's needed to use the flash chip with my board, and here's a small part of code that defines the partitions.

static struct mtd_partition partition_info[] = {
    { name: "a",
      offset: 0,
      size: 32 * 512 },
    { name: "b",
      offset: 16384,
      size: 2 * 1024 * 1024 },
    { name: "c",
      offset: 2113536,
      size: 2 * 1024 * 1024 },
    { name: "d",
      offset: 4210688,
      size: 11 * 1024 * 1024 },
    { name: "e",
      offset: 15745024, 
      size: 1032192 }
};

#define NUM_PARTITIONS 5

I'm using YAFFS on partitions "d" and "e".
But I can't stop recieving annoying kernel messages saying "Reading data from NAND FLASH without ECC is not recommended".

On YAFFS's side, I set the option CONFIG_YAFFS_USE_NANDECC,
which I believe that asks the mtd NAND to do the ECC.
So, I would like to ask if any other settings are necessary in order to enable ECC. (Probably something should be added to the stuff above?)

Well, that's all, and thanks for the great work.

#1 lore raw

Hi Edward,

I am using a similar chip with JFFS2. When you wrote the image, did you use the supplied utility 'nandwrite'? If you did, did you invoke it with the "--yaffs" option?

I hope this helps,
Earl Manning

Quoted 36 lines · On Mon, 14 Apr 2003 09:18:09 +0900 Edward Lee \(ÀÌÀå¿ø\) <[email protected]>…

Hello. I'm Edward Lee in Korea.

I'm using samsung NAND flash, with YAFFS on it..
But I'm having problems with ECC.
I wrote a file that's needed to use the flash chip with my board, and here's a small part of code that defines the partitions.

static struct mtd_partition partition_info[] = {
    { name: "a",
      offset: 0,
      size: 32 * 512 },
    { name: "b",
      offset: 16384,
      size: 2 * 1024 * 1024 },
    { name: "c",
      offset: 2113536,
      size: 2 * 1024 * 1024 },
    { name: "d",
      offset: 4210688,
      size: 11 * 1024 * 1024 },
    { name: "e",
      offset: 15745024, 
      size: 1032192 }
};

#define NUM_PARTITIONS 5

I'm using YAFFS on partitions "d" and "e".
But I can't stop recieving annoying kernel messages saying "Reading data from NAND FLASH without ECC is not recommended".

On YAFFS's side, I set the option CONFIG_YAFFS_USE_NANDECC,
which I believe that asks the mtd NAND to do the ECC.
So, I would like to ask if any other settings are necessary in order to enable ECC. (Probably something should be added to the stuff above?)

Well, that's all, and thanks for the great work.

#2 lore raw

Hi Earl, thanks for the help.

I didn't use nandwrite, I wrote on the chip using plain stuff like 'cp' or 'tar', etc. (having a file system on my device, I couldn't find a reason to write files using
other programs)

----- Original Message -----
From: "Earl Manning" <[email protected]>
To: <[email protected]>
Sent: Monday, April 14, 2003 11:01 AM
Subject: Re: A question on ECC

Hi Edward,

I am using a similar chip with JFFS2. When you wrote the image, did you use the supplied utility 'nandwrite'? If you did, did you invoke it with the "--yaffs" option?

I hope this helps,
Earl Manning

Quoted 30 lines · On Mon, 14 Apr 2003 09:18:09 +0900 Edward Lee \(ÀÌÀå¿ø\) <[email protected]>…

Hello. I'm Edward Lee in Korea.

I'm using samsung NAND flash, with YAFFS on it..
But I'm having problems with ECC.
I wrote a file that's needed to use the flash chip with my board, and here's a small part of code that defines the partitions.

static struct mtd_partition partition_info[] = {
    { name: "a",
      offset: 0,
      size: 32 * 512 },
    { name: "b",
      offset: 16384,
      size: 2 * 1024 * 1024 },
    { name: "c",
      offset: 2113536,
      size: 2 * 1024 * 1024 },
    { name: "d",
      offset: 4210688,
      size: 11 * 1024 * 1024 },
    { name: "e",
      offset: 15745024, 
      size: 1032192 }
};

#define NUM_PARTITIONS 5

I'm using YAFFS on partitions "d" and "e".
But I can't stop recieving annoying kernel messages saying "Reading data from NAND FLASH without ECC is not recommended".

Quoted 6 lines

On YAFFS's side, I set the option CONFIG_YAFFS_USE_NANDECC,
which I believe that asks the mtd NAND to do the ECC.
So, I would like to ask if any other settings are necessary in order to enable ECC. (Probably something should be added to the stuff above?)

Well, that's all, and thanks for the great work.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#3 lore raw
Quoted 5 lines · Edward Lee (???)

Hi Earl, thanks for the help.

I didn't use nandwrite, I wrote on the chip using plain stuff like 'cp' or 'tar', etc. (having a file system on my device, I couldn't find a reason to write files using other programs)

nandwrite is just used to copy a filesystem image to a unformatted chip. If you have mounted the fs already, then nandwrite would be the wrong tool.

These messages have a different reason. I assume that you followed the advice on yaffs list and you have enabled YAFFS_USE_NANDECC and disabled YAFFS_USE_OLD_MTD.

Then I can only guess, that you did not select a ecc mode in your board driver code.

<SNIP>

	/* 20 us command delay time */
	this->chip_delay = 20;		
	this->eccmode = NAND_ECC_SOFT;

<SNIP>

NAND_ECC_SOFT is the right choice, if you don't have a hardware ecc generator. If you have one, you must supply the neccecary functions to use it.

Signature · 5 lines
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]
#4 lore raw
Quoted 17 lines · Thomas Gleixner
Quoted 7 lines · Edward Lee (???)

Hi Earl, thanks for the help.

I didn't use nandwrite, I wrote on the chip using plain stuff like 'cp' or 'tar', etc. (having a file system on my device, I couldn't find a reason to write files using other programs)

nandwrite is just used to copy a filesystem image to a unformatted chip. If you have mounted the fs already, then nandwrite would be the wrong tool.

These messages have a different reason. I assume that you followed the advice on yaffs list and you have enabled YAFFS_USE_NANDECC and disabled YAFFS_USE_OLD_MTD.

Then I can only guess, that you did not select a ecc mode in your board driver code.

Quoted 11 lines

<SNIP>

	/* 20 us command delay time */
	this->chip_delay = 20;		
	this->eccmode = NAND_ECC_SOFT;

<SNIP>

NAND_ECC_SOFT is the right choice, if you don't have a hardware ecc generator. If you have one, you must supply the neccecary functions to use it.

this->eccmode is indeed set to NAND_ECC_SOFT.
I guess my case is kind of 'extra-tricky'. I just found out another weird thing, that the warning messages complaining '...without ECC...' do NOT appear when I'm 'writing' on the chip. Strange, eh. :'(

#5 lore raw

Hi,

Which eccmode is used seems to be set from the calling function of nand_read_ecc. I found:

in nandwrite.c:

struct nand_oobinfo jffs2_oobinfo = {
	useecc: 1,
	eccpos:	{ 0, 1, 2, 3, 6, 7}
};

<SNIP>

// force oob layout for jffs2 or yaffs ?

if (forcejffs2 || forceyaffs) {
	struct nand_oobinfo *oobsel = forcejffs2 ? &jffs2_oobinfo :
	&yaffs_oobinfo;
	if (ioctl (fd, MEMSETOOBSEL, oobsel) != 0) {
		perror ("MEMSETOOBSEL");
		close (fd);
		exit (1);
	}
}

Here useecc is set to 1, which is found in nand.h:
#define NAND_ECC_SOFT 1

Similar in wbuf.c

struct nand_oobinfo jffs2_oobinfo = {
	useecc: 1,
	eccpos: {JFFS2_OOB_ECCPOS0, JFFS2_OOB_ECCPOS1,
		JFFS2_OOB_ECCPOS2, JFFS2_OOB_ECCPOS3, JFFS2_OOB_ECCPOS4,
		JFFS2_OOB_ECCPOS5}
};

int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len,
size_t *retlen, u_char *buf)

{
	loff_t	orbf = 0, owbf = 0, lwbf = 0;
	int	ret;

	/* Read flash */
	if (!jffs2_can_mark_obsolete(c)) {
		ret = c->mtd->read_ecc(c->mtd, ofs, len, retlen, buf,
			NULL, &jffs2_oobinfo);

<SNIP>

I found this while studying nftlmount.c. In function find_boot_record there might be a bug.

In line 223:
if ((ret = MTD_READECC(nftl->mtd, block * nftl->EraseSize +

		i + SECTORSIZE, SECTORSIZE, &retlen, buf,(char *)&oob,
		NAND_ECC_DISKONCHIP)) < 0) {

NAND_ECC_DISKONCHIP is #defined as 5. As I steped over MTD_READECC I found called nand_read_ecc, which wants a pointer (struct nand_oobinfo *oobsel )as last argument.

I use a cvs snapshot dated 20030318, cross compiled for ARM7TDMI

Hope this all makes some sense and helps.

regards
Gerhard Uttenthaler

Quoted 40 lines · Edward J. Lee
Quoted 17 lines · Thomas Gleixner
Quoted 6 lines · Edward Lee (???)

Hi Earl, thanks for the help.

I didn't use nandwrite, I wrote on the chip using plain stuff like 'cp' or 'tar', etc. (having a file system on my device, I couldn't find a reason to write files using other programs)

nandwrite is just used to copy a filesystem image to a unformatted chip. If you have mounted the fs already, then nandwrite would be the wrong tool.

These messages have a different reason. I assume that you followed the advice on yaffs list and you have enabled YAFFS_USE_NANDECC and disabled YAFFS_USE_OLD_MTD.

Then I can only guess, that you did not select a ecc mode in your board driver code. <SNIP>

Quoted 10 lines
    /* 20 us command delay time */
    this->chip_delay = 20;       
    this->eccmode = NAND_ECC_SOFT;

<SNIP>

NAND_ECC_SOFT is the right choice, if you don't have a hardware ecc generator. If you have one, you must supply the neccecary functions to use it.

this->eccmode is indeed set to NAND_ECC_SOFT.
I guess my case is kind of 'extra-tricky'. I just found out another weird thing, that the warning messages complaining '...without ECC...' do NOT appear when I'm 'writing' on the chip. Strange, eh. :'(

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#6 lore raw
Quoted 2 lines · Gerhard Uttenthaler

Which eccmode is used seems to be set from the calling function of nand_read_ecc. I found:

TRUE

Quoted 7 lines

in nandwrite.c:

struct nand_oobinfo jffs2_oobinfo = {
	useecc: 1,
	eccpos:	{ 0, 1, 2, 3, 6, 7}
};

Here useecc is set to 1, which is found in nand.h:
#define NAND_ECC_SOFT 1

CRAP.
ECC_TYPE (SOFT OR HARD) is set in the board specific driver and nowhere else.

Read: http://www.linux-mtd.infradead.org/tech/nand.html

useecc is given by the calling program (filesystem or userspace utility) to tell the nand driver to USE ECC. eccpos is given to tell te nand driver WHERE to put / get ECC in oobarea
This was made to have support for different filesystems on one NAND chip. eg. JFFS2 and YAFFS.

Quoted 3 lines

I found this while studying nftlmount.c. In function find_boot_record there might be a bug.

NTFL does _NOT_ use nand.c functions at all !!!!!! DO NOT MIXUP STUFF HERE !

Quoted 1 line

Hope this all makes some sense and helps.

NO, see above

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

#7 lore raw
In reply to Edward J. Lee
Quoted 6 lines · Edward J. Lee

this->eccmode is indeed set to NAND_ECC_SOFT.
I guess my case is kind of 'extra-tricky'. I just found out another weird thing,
that the warning messages complaining '...without ECC...' do NOT appear when I'm 'writing' on the chip. Strange, eh. :'(

Can you put some debug output YAFFS ?

yaffs_mtdif.c +0 -0
@@ -90,10 +90,12 @@
 		if(dev->useNANDECC)
 		{   // Careful, this call adds 2 ints to the end of the spare data.  

Calling function should

             // allocate enough memory for spare, i.e. 

[YAFFS_BYTES_PER_SPARE+2*sizeof(int)].
+ printk (KERN_DEBUG "YAFFS ReadChunk with real ECC_INFO\n");
retval =
mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_oobinfo);
}
else
{
+ printk (KERN_DEBUG "YAFFS ReadChunk with dummy ECC_INFO\n");
retval =
mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_noeccinfo);
}
}

Signature · 5 lines
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]
#12 lore raw
In reply to Edward J. Lee

Hi Tom and Edward,

I guess I misunderstood the question. I didn't realize that the image was already up and running. On my board I got that message because I had laid down the original image on the NAND flash without putting ECC into the OOB.

Althought, it does sound like new writes do use the SOFT ECC flag and that is why there are no complaints. How did you get the ECC stuff into the OOB to start with?

Earl

Quoted 43 lines · On Tue, 15 Apr 2003 02:40:05 +0900 "Edward J. Lee" <[email protected]> wrote:
Quoted 20 lines · Thomas Gleixner
Quoted 7 lines · Edward Lee (???)

Hi Earl, thanks for the help.

I didn't use nandwrite, I wrote on the chip using plain stuff like 'cp' or 'tar', etc. (having a file system on my device, I couldn't find a reason to write files using other programs)

nandwrite is just used to copy a filesystem image to a unformatted chip. If you have mounted the fs already, then nandwrite would be the wrong tool.

These messages have a different reason. I assume that you followed the advice on yaffs list and you have enabled YAFFS_USE_NANDECC and disabled YAFFS_USE_OLD_MTD.

Then I can only guess, that you did not select a ecc mode in your board driver code.

Quoted 11 lines

<SNIP>

	/* 20 us command delay time */
	this->chip_delay = 20;		
	this->eccmode = NAND_ECC_SOFT;

<SNIP>

NAND_ECC_SOFT is the right choice, if you don't have a hardware ecc generator. If you have one, you must supply the neccecary functions to use it.

this->eccmode is indeed set to NAND_ECC_SOFT.
I guess my case is kind of 'extra-tricky'. I just found out another weird thing,
that the warning messages complaining '...without ECC...' do NOT appear when I'm 'writing' on the chip. Strange, eh. :'(

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#13 lore raw
Quoted 3 lines · Earl Manning

Althought, it does sound like new writes do use the SOFT ECC flag and that is why there are no complaints. How did you get the ECC stuff into the OOB to start with?

I think you missunderstand it again. :)
The offending message
"Reading data from NAND FLASH without ECC is not recommended".
is printed, if nand_read_ecc is called with a oobinfo structure, which has set useecc to zero or without a oobinfo pointer.
That's not related to writing data with or without ECC.

Please read and understand the code there and then post helpful suggestions.

Signature · 5 lines
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]
#8 lore raw
In reply to Thomas Gleixner
Quoted 29 lines · Thomas Gleixner
Quoted 7 lines · Edward J. Lee

this->eccmode is indeed set to NAND_ECC_SOFT.
I guess my case is kind of 'extra-tricky'. I just found out another weird thing,
that the warning messages complaining '...without ECC...' do NOT appear when I'm 'writing' on the chip. Strange, eh. :'(

Can you put some debug output YAFFS ?

yaffs_mtdif.c +0 -0
@@ -90,10 +90,12 @@
 		if(dev->useNANDECC)
 		{   // Careful, this call adds 2 ints to the end of the spare data.  

Calling function should

            // allocate enough memory for spare, i.e. 

[YAFFS_BYTES_PER_SPARE+2*sizeof(int)].

yaffs_mtdif.c +1 -0
+	    	printk (KERN_DEBUG "YAFFS ReadChunk with real ECC_INFO\n");
    		retval = 
mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_oobinfo);            
		}
		else
		{
yaffs_mtdif.c +1 -0
+		    	printk (KERN_DEBUG "YAFFS ReadChunk with dummy ECC_INFO\n");

retval =

Quoted 7 lines
mtd->read_ecc(mtd,addr,dev->nBytesPerChunk,&dummy,data,spareAsBytes,&yaffs_noeccinfo);
		}
	}

I tried this last night, and I got a bunch of "YAFFS ReadChunk with real ECC_INFO". when both reading/writing.
Nothing else, do we need more information?

#9 lore raw
Quoted 5 lines · Edward J. Lee

I tried this last night, and I got a bunch of "YAFFS ReadChunk with real ECC_INFO".
when both reading/writing.
Nothing else, do we need more information?

I assume there were no messages containing YAFFS ReadChunk with dummy ECC info.
That means, YAFFS supplies always a pointer to yaffs_oobinfo structure. Do the "I'ts not recommended ...." messages follow up the above message, or show they up elsewhere ? That means, are they really related to accessing the YAFFS partitions ? Please provide a short debug output, where I can see the context of those "It's not recommended ..." messages.

Are there any other functions accessing the flash device ?

You use 2 partitions out of 5 for YAFFS. What are the other partitions for?

Signature · 5 lines
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]
#10 lore raw

----- Original Message -----
From: "Thomas Gleixner" <[email protected]>
To: "Edward J. Lee" <[email protected]>; <[email protected]>
Sent: Friday, April 18, 2003 5:49 PM
Subject: Re: A question on ECC

Quoted 9 lines · Edward J. Lee
Quoted 5 lines

I tried this last night, and I got a bunch of "YAFFS ReadChunk with real ECC_INFO".
when both reading/writing.
Nothing else, do we need more information?

I assume there were no messages containing YAFFS ReadChunk with dummy ECC info.

right.

Quoted 5 lines

That means, YAFFS supplies always a pointer to yaffs_oobinfo structure. Do the "I'ts not recommended ...." messages follow up the above message, or show they up elsewhere ? That means, are they really related to accessing the YAFFS partitions ? Please provide a short debug output, where I can see the context of those "It's not recommended ..." messages.

I'm currently not in the proper environment to send you the debug msgs, but I can tell you that the 'It's not recommended...' stuff came out just 'before' the YAFFS msgs did. A bunch of 'It's not recommended...', and then another bunch of 'Real Chunk..'.
I send you the output next monday, I'll have to newly setup a few things before trying it again.

Quoted 5 lines

Are there any other functions accessing the flash device ?

You use 2 partitions out of 5 for YAFFS. What are the other partitions for?

The first partition contains the state of the whole device,
the second and third has the kernel image, (the first three partitions are stored as raw binary) and the forth and fifth is used as YAFFS.

Quoted 8 lines
Signature · 5 lines
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]
#11 lore raw
Quoted 3 lines · Edward Lee (???)
Quoted 3 lines

That means, YAFFS supplies always a pointer to yaffs_oobinfo structure. Do the "I'ts not recommended ...." messages follow up the above message, or

show they up elsewhere ? That means, are they really related to

Quoted 7 lines
Quoted 2 lines

accessing the YAFFS partitions ? Please provide a short debug output, where I can see the context of those "It's not recommended ..." messages.

I'm currently not in the proper environment to send you the debug msgs, but I can tell you that the 'It's not recommended...' stuff came out just 'before'

the YAFFS msgs did. A bunch of 'It's not recommended...', and

Quoted 3 lines

then another bunch of 'Real Chunk..'.
I send you the output next monday, I'll have to newly setup a few things before

trying it again.

Add "rootfs=yaffs" to your commandline.

The kernel tries various filesystems before it hits yaffs

Quoted 3 lines

The first partition contains the state of the whole device, the second and third has the kernel image, (the first three partitions are stored as raw binary)

and the forth and fifth is used as YAFFS.

OK, but you don't access them from Linux ?

Signature · 5 lines
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]