NAND Configuration
Does I have to set CONFIG_MTD_NAND_ECC_JFFS2=y and CONFIG_JFFS2_FS_NAND=y to use NAND flash? Weh I set these settings, I will get the following easily. If I did not set these settings and the condition is better, still has problem, but it will not halt the system. If I need not set CONFIG_MTD_NAND_ECC_JFFS2=y and CONFIG_JFFS2_FS_NAND=y, I can trace my problem easily. I use mtd-snapshot-20020731.tar.bz2 with uClinux.
Steve Tsai
ARGH. About to write node to 0x0018de8c on flash, but there are data already the
re:0x0018de8c: 85 19 04 20 74 01 00 00 4d 62 52 56 ff ff ff ff pid 24: failed 256
jffs2_flush_wbuf(): Write failed with -5
Write of 68 bytes at 0x004da000 failed. returned -5, retlen 0 Not marking the space at 0x004da000 as dirty because the flash driver returned r
etlen zero
Quoted 7 lines · Steve Tsai
Does I have to set
CONFIG_MTD_NAND_ECC_JFFS2=yandCONFIG_JFFS2_FS_NAND=yto use NAND flash? Weh I set these settings, I will get the following easily. If I did not set these settings and the condition is better, still has problem, but it will not halt the system. If I need not setCONFIG_MTD_NAND_ECC_JFFS2=yandCONFIG_JFFS2_FS_NAND=y, I can trace my problem easily. I use mtd-snapshot-20020731.tar.bz2 with uClinux.
You have to set it. Read http://linux-mtd.infradead.org/tech/nand.html
Quoted 7 lines
ARGH. About to write node to
0x0018de8con flash, but there are data already the
re:0x0018de8c: 85 19 04 20 74 01 00 00 4d 62 52 56 ff ff ff ff pid 24: failed 256
Quoted 5 lines
jffs2_flush_wbuf(): Write failed with -5
Write of 68 bytes at0x004da000failed. returned -5, retlen 0 Not marking the space at0x004da000as dirty because the flash driver returned r
etlen zero
We need more info from mount onwards.
Quoted 5 lines
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Signature · 7 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected] nix.de
On Tue, 2002-08-06 at 09:25, Steve Tsai wrote:
Could you send me your hardware driver ?
Signature · 7 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected] nix.de
I use GPIO to control NCE, ALE and CLE. RE and WE are connected to CS of ROM bank 1 and ROM bank 2.
The test program are work fine to do read/write and it seems work fine also when I did not use CONFIG_JFFS2_FS_NAND. Thanks.
Steve Tsai
================================================================
Change in nand.c for our board.
=================================================================
#undef readb
#undef writeb
#define readb(a) (*(volatile unsigned char *)(a))
/* Use function call for more delay in write cycle */ void writeb(unsigned char v, unsigned int a)
{
*(volatile unsigned char *)(a) = v;
}================================================================Netpower.c for our board - board-specific glue layer.
=================================================================
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <asm/io.h>
/*
* MTD structure for .NETpower board
*/
static struct mtd_info *dnp_mtd = NULL;
/*
* Values specific to the .NETpower board (used with S3C4510 processor) */
#define DNP_FIO_BASE 0x2000000
#define NCE 0x100 #define ALE 0x400 #define CLE 0x200
/*
* Module stuff
*/
static int dnp_fio_base = DNP_FIO_BASE;
#if 0MODULE_PARM(dnp_fio_base, "i");
__setup("dnp_fio_base=",dnp_fio_base);
#endif
/*
* Define partitions for flash device
*/
const static struct mtd_partition partition_info[] = {
{ name: "DNP flash partition 1",
offset: 0,
size: 2*1024*1024 },
{ name: "DNP flash partition 2",
offset: 2*1024*1024,
size: 6*1024*1024 }
};#define NUM_PARTITIONS 2
/*
* hardware specific access to control-lines
*/
void dnp_hwcontrol(int cmd){
switch(cmd){
case NAND_CTL_SETCLE: (*(volatile unsigned int *) (IOPDATA)) |=CLE; break;
case NAND_CTL_CLRCLE: (*(volatile unsigned int *) (IOPDATA)) &=
~CLE; break;
case NAND_CTL_SETALE: (*(volatile unsigned int *) (IOPDATA)) |=
ALE; break;
case NAND_CTL_CLRALE: (*(volatile unsigned int *) (IOPDATA)) &=
~ALE; break;
case NAND_CTL_SETNCE: (*(volatile unsigned int *) (IOPDATA)) &=
~NCE; break;
case NAND_CTL_CLRNCE: (*(volatile unsigned int *) (IOPDATA)) |=
NCE; break;
}
}/*
* Main initialization routine
*/
int __init dnp_init (void)
{
struct nand_chip *this;
/* Allocate memory for MTD device structure and private data */
dnp_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct
nand_chip),
GFP_KERNEL);
if (!dnp_mtd) {
printk ("Unable to allocate DNP NAND MTD device
structure.\n");
return -ENOMEM;
}
/* Get pointer to private data */
this = (struct nand_chip *) (&dnp_mtd[1]);
/* Initialize structures */
memset((char *) dnp_mtd, 0, sizeof(struct mtd_info));
memset((char *) this, 0, sizeof(struct nand_chip));
/* Link the private data with the MTD structure */
dnp_mtd->priv = this;
/*
* Set GPIO Port register so that the pins are configured
* to be outputs for controlling the NAND flash.
*/
*(volatile unsigned int *)(IOPMOD) |= (CLE|ALE|NCE);
*(volatile unsigned int *)(IOPDATA) |= (NCE);
/* Set address of NAND IO lines */
/* 0x2000000 for ROM bank 1, 0x2200000 form ROM bank 2 */
/* Above 0x4000000 is noncachable area
*/
this->IO_ADDR_W = (dnp_fio_base | 0x4000000);
this->IO_ADDR_R = ((dnp_fio_base+0x200000) | 0x4000000);
/* Set address of hardware control function */
this->hwcontrol = dnp_hwcontrol;
this->dev_ready = NULL;
/* 15 us command delay time */
this->chip_delay = 15;
/* Scan to find existance of the device */
if (nand_scan (dnp_mtd)) {
kfree (dnp_mtd);
return -ENXIO;
}
/* Allocate memory for internal data buffer */
this->data_buf = kmalloc (sizeof(u_char) * (dnp_mtd->oobblock +
dnp_mtd->oobsize), GFP_KERNEL);
if (!this->data_buf) {
printk ("Unable to allocate NAND data buffer for
DNP.\n");
kfree (dnp_mtd);
return -ENOMEM;
}
/* Register the partitions */
add_mtd_partitions(dnp_mtd, partition_info, NUM_PARTITIONS);
/* Return happy */
return 0;
}module_init(dnp_init);
/*
* Clean up routine
*/
#ifdef MODULE
static void __exit dnp_cleanup (void)
{
struct nand_chip *this = (struct nand_chip *) &dnp_mtd[1];
/* Unregister the device */
del_mtd_device (dnp_mtd);
/* Free internal data buffer */
kfree (this->data_buf);
/* Free the MTD device structure */
kfree (dnp_mtd);
}module_exit(dnp_cleanup);
#endif
MODULE_LICENSE("GPL");MODULE_AUTHOR("Steve Tsai <[email protected]"); MODULE_DESCRIPTION("Board-specific glue layer for NAND flash on DNP board");
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Gleixner
Sent: Tuesday, August 06, 2002 5:46 PM
To: Steve Tsai
Cc: Linux MTD mailing list
Subject: Re: NAND Configuration
On Tue, 2002-08-06 at 09:25, Steve Tsai wrote:
Could you send me your hardware driver ?
Signature · 13 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected] nix.de ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Thomas Gleixner
Sent: Tuesday, August 06, 2002 5:08 PM
To: Steve Tsai
Cc: Linux MTD mailing list
Subject: Re: NAND Configuration
Quoted 7 lines · Steve Tsai
Does I have to set
CONFIG_MTD_NAND_ECC_JFFS2=yandCONFIG_JFFS2_FS_NAND=yto use NAND flash? Weh I set these settings, I will get the following easily. If I did not set these settings and the condition is better, still has problem, but it will not halt the system. If I need not setCONFIG_MTD_NAND_ECC_JFFS2=yandCONFIG_JFFS2_FS_NAND=y, I can trace my problem easily. I use mtd-snapshot-20020731.tar.bz2 with uClinux.
You have to set it. Read http://linux-mtd.infradead.org/tech/nand.html
I read it many time, but CONFIG_JFFS2_FS_NAND use to take care buffering and OOB . Does I have to use it absolutely? If I do not use it, what's the result of the driver?
Quoted 11 lines
ARGH. About to write node to
0x0018de8con flash, but there are data already the
re:0x0018de8c: 85 19 04 20 74 01 00 00 4d 62 52 56 ff ff ff ff pid 24:
failed 256
jffs2_flush_wbuf(): Write failed with -5
Write of 68 bytes at0x004da000failed. returned -5, retlen 0 Not marking the space at0x004da000as dirty because the flash driver returned r etlen zero
We need more info from mount onwards.
Maybe I do not provide repeatable messages and steps. The following are the steps I use.
1. eraseall /dev/mtd1
2. mount -t jffs2 /dev/mtdblock1 /mnt
3. Make directory to /mnt
4. Use ftp to copy files to /mnt
5. Change the kernel to to mount /dev/mtdblock1 as root FS.
6. Copy or delete files and sometime the message display
ARGH. About to write node to 0x003f9e2c on flash, but there are
data already the re:...
After that, the patition will display more error messages, ECC error
and others.
Regards,
Steve tsai
Quoted 3 lines · Steve Tsai
I read it many time, but
CONFIG_JFFS2_FS_NANDuse to take care buffering and OOB . Does I have to use it absolutely? If I do not use it, what's the result of the driver?
Yes, you _HAVE_ _ABSOLUTELY_ to use it !
IF not, no buffering and OOB check, no bad block management ..--> no JFFS2 on NAND.
Quoted 10 lines
We need more info from mount onwards.
Maybe I do not provide repeatable messages and steps. The following are the steps I use.
1. eraseall/dev/mtd1
2. mount -t jffs2/dev/mtdblock1/mnt
3. Make directory to /mnt
4. Use ftp to copy files to /mnt
5. Change the kernel to to mount/dev/mtdblock1as root FS.
6. Copy or delete files and sometime the message display
Quoted 4 lines
ARGH. About to write node to 0x003f9e2c on flash, but there aredata already the re:...
After that, the patition will display more error messages, ECC error
and others.
I meant, could you get full logs with CONFIG_JFFS2_FS_DEBUG=1 from mounting the file system to the ARGH? Make sure you are logging over a serial console so you catch _ALL_ the messages, and remember they're at level KERN_DEBUG so echo 9 > /proc/sys/kernel/printk before mount.
Signature · 7 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected] nix.de
Quoted 5 lines · Steve Tsai
I use GPIO to control NCE, ALE and CLE. RE and WE are connected to CS of ROM bank 1 and ROM bank 2.
The test program are work fine to do read/write and it seems work fine also when I did not useCONFIG_JFFS2_FS_NAND. Thanks.
Quoted 8 lines
================================================================
Change innand.cfor our board.
=================================================================#undef readb
#undef writeb#define readb(a) (*(volatile unsigned char *)(a))
It's really innovative to reinvent the wheel.
Quoted 5 lines
/* Use function call for more delay in write cycle */ void
writeb(unsigned char v, unsigned int a){ *(volatile unsigned char *)(a) = v; }
For what do you need more delay ??? NAND is fast enough.
Quoted 8 lines
/* Set address of NAND IO lines */ /* 0x2000000 for ROM bank 1, 0x2200000 form ROM bank 2 */ /* Above 0x4000000 is noncachable area */ this->IO_ADDR_W = (dnp_fio_base | 0x4000000); this->IO_ADDR_R = ((dnp_fio_base+0x200000) | 0x4000000);
Is your read address really different to your write address ??? If yes, get a baseball bat and trim the hardware guy. :) If no, you read and write from/to different address ranges.
Quoted 5 lines
/* Set address of hardware control function */ this->hwcontrol = dnp_hwcontrol; this->dev_ready = NULL; /* 15 us command delay time */ this->chip_delay = 15;
Could you try to set chipdelay to a longer value ?
Signature · 5 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected]
Quoted 3 lines · [email protected] said:
Quoted 1 line
RE and WE are connected to CS of ROM bank 1 and ROM bank 2.
Is your read address really different to your write address ???
That's what he said.
Quoted 1 line
If yes, get a baseball bat and trim the hardware guy. :)
Nah -- that's not so bad. There are hardware guys _far_ more deserving of a batting than this one.
--
dwmw2
Quoted 3 lines · David Woodhouse
Quoted 1 line · [email protected] said:
Quoted 1 line
RE and WE are connected to CS of ROM bank 1 and ROM bank 2.
Sorry, I must have missed this line.
Quoted 2 lines
Signature · 7 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected] nix.de
Quoted 9 lines
Quoted 3 lines
I read it many time, but
CONFIG_JFFS2_FS_NANDuse to take care buffering and OOB . Does I have to use it absolutely? If Ido not use
Quoted 1 line
it, what's the result of the driver?
Yes, you _HAVE_ _ABSOLUTELY_ to use it !
IF not, no buffering and OOB check, no bad block management ..--> no JFFS2 on NAND.
JFFS2 on NOR type flash does not use buffering, OOB check and bad block management, but it can be used now. I meant that CONFIG_JFFS2_FS_NAND is not defined, maybe the driver still can work, but it is not good as the original one.
Quoted 13 lines
Quoted 9 lines
We need more info from mount onwards.
Maybe I do not provide repeatable messages and steps. The following are the steps I use.
1. eraseall/dev/mtd1
2. mount -t jffs2/dev/mtdblock1/mnt
3. Make directory to /mnt
4. Use ftp to copy files to /mnt
5. Change the kernel to to mount/dev/mtdblock1as root FS.6. Copy or
Quoted 2 lines
delete files and sometime the message display
ARGH. About to write node to 0x003f9e2c on flash, butthere are data
Quoted 10 lines
Quoted 3 lines
already the re:...
After that, the patition will display more error messages, ECC
error and others.I meant, could you get full logs with
CONFIG_JFFS2_FS_DEBUG=1from mounting the file system to the ARGH? Make sure you are logging over a serial console so you catch _ALL_ the messages, and remember they're at levelKERN_DEBUGso echo 9Quoted 1 line
/proc/sys/kernel/printkbefore mount.
OK. I log the file. I have two files, one is logging the process to build the file system, anothor is logging the process of file operation. The attached file is the second file. Thanks.
Steve Tsai
.NETpower is starting...
Press <ESC> key to enter console mode.
Boot .NETpower ...........................................g
13,939 lines not shown · raw message
Part of this message is not shown here. View the raw message.
Quoted 4 lines · [email protected] said:
JFFS2 on NOR type flash does not use buffering, OOB check and bad block management, but it can be used now. I meant that
CONFIG_JFFS2_FS_NANDis not defined, maybe the driver still can work, but it is not good as the original one.
JFFS2 cannot work on NAND flash without the extra code enabled by CONFIG_JFFS2_FS_NAND. You need to batch writes into page-sized chunks and use ECC. It looks like you have enabled CONFIG_JFFS2_FS_NAND in the log you show -- is that correct?
--
dwmw2
Quoted 4 lines
Quoted 3 lines
JFFS2 on NOR type flash does not use buffering, OOB check and bad block management, but it can be used now. I meant that
CONFIG_JFFS2_FS_NANDis not defined, maybe the driver stillcan work,
Quoted 9 lines
Quoted 1 line
but it is not good as the original one.
JFFS2 cannot work on NAND flash without the extra code enabled by
CONFIG_JFFS2_FS_NAND. You need to batch writes into page-sized chunks and
use ECC. It looks like you have enabledCONFIG_JFFS2_FS_NANDin the log you
show -- is that correct?
Yes, I enable CONFIG_JFFS2_FS_NAND. I follow
http://www.linux-mtd.infradead.org/tech/nand.html to config the settings. Can I do not care ECC on NAND flash?
Steve Tsai
Quoted 2 lines
Could you try to set chipdelay to a longer value ?
I try to set chip_delay to a longer value, but I got the same result.
Steve tsai
Quoted 14 lines · Steve Tsai
Quoted 4 lines
Quoted 3 lines
JFFS2 on NOR type flash does not use buffering, OOB check and bad block management, but it can be used now. I meant that
CONFIG_JFFS2_FS_NANDis not defined, maybe the driver stillcan work,
Quoted 9 lines
Quoted 1 line
but it is not good as the original one.
JFFS2 cannot work on NAND flash without the extra code enabled by
CONFIG_JFFS2_FS_NAND. You need to batch writes into page-sized chunks and
use ECC. It looks like you have enabledCONFIG_JFFS2_FS_NANDin the log you
show -- is that correct?
Quoted 4 lines
Yes, I enable
CONFIG_JFFS2_FS_NAND. I follow
http://www.linux-mtd.infradead.org/tech/nand.html to config the settings. Can I do not care ECC on NAND flash?
ECC _HAS_ to be enabled !
Have you ever erased your flash with erase /dev/mtdX ?
This may have caused the problem, because erase is not aware of bad block handling and may have erased a block, which was marked as bad already and erased the bad block marker too. So if you write to this block, you get a write failure and therefor a read failure afterwards. I will change nand.c, so that bad blocks cannot be erased anymore.
Another problem could be your command delay time. You have set it to 15µsec. Is that correct for your chip ? Which chip are you using ? Have you tried to set it to a higher value ?
Signature · 5 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected]
Quoted 29 lines · Thomas Gleixner
Quoted 14 lines · Steve Tsai
Quoted 4 lines
Quoted 3 lines
JFFS2 on NOR type flash does not use buffering, OOB check and bad block management, but it can be used now. I meant that
CONFIG_JFFS2_FS_NANDis not defined, maybe the driver stillcan work,
Quoted 9 lines
Quoted 1 line
but it is not good as the original one.
JFFS2 cannot work on NAND flash without the extra code enabled by
CONFIG_JFFS2_FS_NAND. You need to batch writes into page-sized chunks and
use ECC. It looks like you have enabledCONFIG_JFFS2_FS_NANDin the log you
show -- is that correct?Quoted 4 lines
Yes, I enable
CONFIG_JFFS2_FS_NAND. I follow
http://www.linux-mtd.infradead.org/tech/nand.html to config the settings. Can I do not care ECC on NAND flash?ECC _HAS_ to be enabled !
Have you ever erased your flash with erase
/dev/mtdX?
This may have caused the problem, because erase is not aware of bad block handling and may have erased a block, which was marked as bad already and erased the bad block marker too. So if you write to this block, you get a write failure and therefor a read failure afterwards. I will changenand.c, so that bad blocks cannot be erased anymore.
Quoted 1 line
From looking at
nand_erase(), it appears that the attempted erase of a bad
block would
result in not performing the erase and exiting with -EIO, correct?
What is the preferred method to erase nand?
Alice
Quoted 15 lines
Another problem could be your command delay time. You have set it to 15µsec. Is that correct for your chip ? Which chip are you using ? Have you tried to set it to a higher value ?
--
Thomas
____________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 29 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
JFFS2 on NOR type flash does not use buffering, OOB
check and bad
Quoted 13 lines
Quoted 12 lines
Quoted 2 lines
block management, but it can be used now. I meant that
CONFIG_JFFS2_FS_NANDis not defined, maybe the driver stillcan work,
Quoted 1 line
but it is not good as the original one.
JFFS2 cannot work on NAND flash without the extra code enabled by
CONFIG_JFFS2_FS_NAND. You need to batch writes into page-sized chunks and
use ECC. It looks like you have enabledCONFIG_JFFS2_FS_NANDin the log you
show -- is that correct?Quoted 4 lines
Yes, I enable
CONFIG_JFFS2_FS_NAND. I follow
http://www.linux-mtd.infradead.org/tech/nand.html to config the settings. Can I do not care ECC on NAND flash?ECC _HAS_ to be enabled !
Have you ever erased your flash with erase
/dev/mtdX? This may have caused the problem, because erase is not aware of bad block handling and may have erased a block, which was marked as bad already and erased the bad block marker too. So if you write to this block, you get a write failure and therefor a read failure afterwards.
I will changenand.c, so that bad blocks cannot be erased anymore.
Quoted 4 lines
Another problem could be your command delay time. You have set it to 15µsec. Is that correct for your chip ? Which chip are you using ? Have you tried to set it to a higher value ?
Yes, I use eraseall /dev/mtd1 to erase the partition. But I check the page that causes the problem, it is fine to read/write all the page.
I use Samsung K9F6408 and I try to set the delay time to 20µsec and it can not solve the problem.
Could I use the content of the page that the error occures to trace the problem? Can it help to solve the problem? Thanks.
Steve Tsai
Thomas,
The following are the content of the page writing error. All the tests have the similar data in the page and the area have the data already always start with 0x1985 and there are empty data next to the area. Does it mean that the area was written before?
Steve TSai
85 19 01 e0 2b 00 00 00 e6 6e 26 7d 02 00 00 00 27 00 00 00 00 00 00 00 48 01 00 00 03 00 e3 01 3f 18 e6 6c 5f cb 19 04 61 72 70 ff 85 19 04 20 <------ start with 85 19 d4 01 00 00 48 7b 39 1b ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
Quoted 8 lines · Alice Hennessy
Quoted 7 lines
Have you ever erased your flash with erase
/dev/mtdX?
This may have caused the problem, because erase is not aware of bad block handling and may have erased a block, which was marked as bad already and erased the bad block marker too. So if you write to this block, you get a write failure and therefor a read failure afterwards. I will changenand.c, so that bad blocks cannot be erased anymore.
Quoted 7 lines
Quoted 1 line
From looking at
nand_erase(), it appears that the attempted erase of a badblock would
result in not performing the erase and exiting with-EIO, correct?What is the preferred method to erase nand?
Alice
With actual code in CVS you can use erase(all) /dev/mtdX. I modified it, that attempts to erase bad block's are rejeceted in any case. The previous version let you erase bad blocks, if CONFIG_NAND_ECC_JFFS2 was not set. But now it's forced by default.
Signature · 5 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected]
Quoted 5 lines · Steve Tsai
Thomas,
The following are the content of the page writing error. All the tests have the similar data in the page and the area have the data already always start with0x1985and there are empty data next to the area. Does it mean that the area was written before?
Yep.
Can you please do the following ?
Update to latest CVS code.
Erase the partition, you can use erase(all) /dev/mtdX echo 9 >/proc/sys/kernel/printk
Start log
mount
do your mkdir, cp ...
if this happens again, please send a dump of the concerned page and the logfile
Thanks
Signature · 5 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected]
Quoted 5 lines · [email protected] said:
From looking at
nand_erase(), it appears that the attempted erase of
a bad block would result in not performing the erase and exiting with-EIO, correct?What is the preferred method to erase nand?
As I understand it, the preferred method to erase factory-marked bad blocks is not at all.
--
dwmw2
Quoted 10 lines · David Woodhouse
Quoted 5 lines · [email protected] said:
From looking at
nand_erase(), it appears that the attempted erase of
a bad block would result in not performing the erase and exiting with-EIO, correct?What is the preferred method to erase nand?
As I understand it, the preferred method to erase factory-marked bad blocks is not at all.
nand.c takes care of factory-marked blocks now, wether CONFIG_NAND_ECC_JFFS2 is set of not. So you can use erase(all) and bad blockes are skipped.
Signature · 5 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected]
Maybe I found the problem here. I find jffs2 will write to the page that was used. The proble is that jffs2_wbuf_process make jffs2_do_reserve_space caculate wrong ofs.
In jffs2_wbuf_process, when free_size is smaller than (c->wbuf_pagesize
- c->wbuf_len), jffs2_flush_wbuf(c, 1) was called, but free_size will not be assigned right value. In the case, the block can not be used anymore because the last page in the block was used here, but jffs2_do_reserve_space does not know.jffs2_do_reserve_space will use the block, if minsize > jeb->free_size and it maybe happen here.
jffs2_wbuf_process
==============if(!c->nextblock || (c->nextblock->free_size < (c->wbuf_pagesize - c->wbuf_len)))
jffs2_flush_wbuf(c, 1); /* pad only */ <========== should take
care free_size here
else
jffs2_flush_wbuf(c, 2); /* pad and adjust nextblock */
static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, uint32_t *ofs, uint32_t *len)
{
struct jffs2_eraseblock *jeb = c->nextblock;restart:
if (jeb && minsize > jeb->free_size) { <====== if
minisize > free_size, the block will be used
/* Skip the end of this block and file it as having some
dirty space */
/* If there's a pending write to it, flush now */
if (c->wbuf_len) {I add the following codes and I am still testing it.
if(!c->nextblock || (c->nextblock->free_size <
(c->wbuf_pagesize - c->wbuf_len))){
jffs2_flush_wbuf(c, 1); /* pad only */
c->dirty_size += c->nextblock->free_size;
c->free_size -= c->nextblock->free_size;
c->nextblock->dirty_size +=
c->nextblock->free_size;
c->nextblock->free_size = 0;
}
else
jffs2_flush_wbuf(c, 2); /* pad and adjustnextblock */
Steve Tsai
Quoted 13 lines
Can you please do the following ?
Update to latest CVS code.
Erase the partition, you can use erase(all)/dev/mtdXecho 9 >/proc/sys/kernel/printk
Start log
mount
do your mkdir, cp ...if this happens again, please send a dump of the concerned page and the logfile
Quoted 6 lines · [email protected] said:
In
jffs2_wbuf_process, whenfree_sizeis smaller than (c->wbuf_pagesize-c->wbuf_len),jffs2_flush_wbuf(c, 1)was called, butfree_sizewill not be assigned right value. In the case, the block can not be used anymore because the last page in the block was used here, butjffs2_do_reserve_spacedoes not know.jffs2_do_reserve_spacewill use the block, if minsize >jeb->free_sizeand it maybe happen here.
Try this (it's in CVS)....
Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.12
retrieving revision 1.13
wbuf.c +35 -11
@@ -7,7 +7,7 @@* * For licensing information, see the file 'LICENCE' in this directory. * -* $Id: wbuf.c,v 1.12 2002/05/20 14:56:39 dwmw2 Exp $ +* $Id: wbuf.c,v 1.13 2002/08/08 11:04:40 dwmw2 Exp $ * */
@@ -80,17 +80,33 @@ void jffs2_wbuf_process (void *data)D1 (printk (KERN_DEBUG "jffs2_wbuf_process() entered\n" )); -if (!down_trylock (&c->alloc_sem)) { -D1 (printk (KERN_DEBUG "jffs2_wbuf_process() alloc_sem got\n" )); - -if (!c->nextblock || (c->nextblock->free_size < (c->wbuf_pagesize - c->wbuf_len))) -jffs2_flush_wbuf (c,1 );/* pad only */ -else -jffs2_flush_wbuf (c,2 );/* pad and adjust nextblock */ -up (&c->alloc_sem); - }else { +if (down_trylock (&c->alloc_sem)) { +/* If someone else has the alloc_sem, they're about to +write anyway. So no need to waste space by +padding */ D1 (printk (KERN_DEBUG "jffs2_wbuf_process() alloc_sem already occupied\n" )); +return ; } + +D1 (printk (KERN_DEBUG "jffs2_wbuf_process() alloc_sem got\n" )); + +if (!c->nextblock) { +D1 (printk (KERN_DEBUG "jffs2_wbuf_process(): nextblock NULL, nothing to do\n" )); +if (c->wbuf_len) { +printk (KERN_WARNING "jffs2_wbuf_process(): c->wbuf_len is 0x%03x but nextblock is NULL!\n" , c->wbuf_len); +up (&c->alloc_sem); +BUG (); + } +return ; + } + + +/* if !c->nextblock then the tail will have got flushed from +jffs2_do_reserve_space() anyway. */ +if (c->nextblock) +jffs2_flush_wbuf (c,2 );/* pad and adjust nextblock */ + +up (&c->alloc_sem); }
@@ -166,8 +182,16 @@ int jffs2_flush_wbuf(struct jffs2_sb_infspin_lock_bh (&c->erase_completion_lock);if (!c->nextblock)BUG (); -if (c->nextblock->free_size < (c->wbuf_pagesize - c->wbuf_len)) +/* wbuf_pagesize - wbuf_len is the amount of space that's to be +padded. If there is less free space in the block than that, +something screwed up */ +if (c->nextblock->free_size < (c->wbuf_pagesize - c->wbuf_len)) { +printk (KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n" , + c->wbuf_ofs, c->wbuf_len, c->wbuf_pagesize-c->wbuf_len); +printk (KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n" , + c->nextblock->offset, c->nextblock->free_size);BUG (); + } c->nextblock->free_size -= (c->wbuf_pagesize - c->wbuf_len); c->nextblock->dirty_size += (c->wbuf_pagesize - c->wbuf_len);spin_unlock_bh (&c->erase_completion_lock);
--
dwmw2
The patch can work on my system. Thanks.
I got another problem in mounting JFFS2 file system. When I write a JFFS2 image into the NAND partition, I can mount it on /mnt. If I write a JFFS2 image into the NAND partition and reboot system to use it as the root file system, there are some CRC errors occur. When the system mounts the root file system, it will start to access files also. Does the kernel access file on jffs2 file system too early?
Steve Tsai
Quoted 9 lines
Try this (it's in CVS)....
Index:
wbuf.c
===================================================================
RCS file:/home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -p -r1.12 -r1.13
Quoted 8 lines · Steve Tsai
The patch can work on my system. Thanks.
I got another problem in mounting JFFS2 file system. When I write a JFFS2 image into the NAND partition, I can mount it on /mnt. If I write a JFFS2 image into the NAND partition and reboot system to use it as the root file system, there are some CRC errors occur. When the system mounts the root file system, it will start to access files also. Does the kernel access file on jffs2 file system too early?
No, also the kernel has to wait until the filesystem is mounted complete. The kernel reads files, which you probably do not access, when you mount it manually on /mnt. Try to copy all your files from /mnt to anywhere and check, if the same errors occure.
Signature · 5 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected]
That's the fault of our board. We can not adujst a proper chip_delay, so we add a circuit to check the ready bit and it does not have these errors so far. Do you think chip_delay can be used with NAND flash? I don't think it is good idea to use chip_delay.
Steve Tsai
Quoted 15 lines
Quoted 1 line
I got another problem in mounting JFFS2 file system. When
I write a
Quoted 2 lines
JFFS2 image into the NAND partition, I can mount it on /mnt. If I write a JFFS2 image into the NAND partition and reboot
system to use
Quoted 1 line
it as the root file system, there are some CRC errors
occur. When the
Quoted 2 lines
system mounts the root file system, it will start to access files also. Does the kernel access file on jffs2 file system too early?
No, also the kernel has to wait until the filesystem is mounted complete. The kernel reads files, which you probably do not access, when you mount it manually on /mnt. Try to copy all your files from /mnt to anywhere and check, if the same errors occure.
Quoted 5 lines · Steve Tsai
That's the fault of our board. We can not adujst a proper
chip_delay, so we add a circuit to check the ready bit and it does not have these errors so far. Do you thinkchip_delaycan be used with NAND flash? I don't think it is good idea to usechip_delay.
I'm pretty sure, that chip_delay is working.
Cite from data sheet:
'..Page Read... by writing 00h to the command register along with three address cycles. ...
The 528 bytes of data within the selected page are transferred to the data registers in _LESS_ than 10us(tR). The system controller _CAN_ detect the completion of this data transfer(tR) by analyzing the output of R/B pin. Once the data in a page is loaded into the registers, they may be read out by sequential RE pulse of 70ns/50n(K9F2808Q0B:70ns, K9F2808U0B:50ns) period cycle. High to low transitions of the RE clock take out the data from the selected column address up to the last column address. '
As tR is defined as a max value of x ms, it's safe to use it. I tested this, when we started the work on JFFS2/NAND. I could verify with the scope, that R/B high transition was always within the specified time.
For program and erase we use a different scheme. If we have no access to the R/B pin, we read back the Status Register. Bit 6 is a mirror of R/B pin.
If increasing of chip_delay has no effect on your device, could you verify all the other timing constraints ? AS you use chipselects for WE and RE, are you sure that data hold time (tdh) is guaranteed ? Usually tdh on a CPU is specified from the rising egde of WE, which is earlier than the rising egde of a CS.
Have you ever tried to set chip_delay to 1 ? Then you should get a bunch of errors.
Signature · 5 lines
Thomas ____________________________________________________ linutronix - competence in embedded & realtime linux http://www.linutronix.de mail: [email protected]
Quoted 42 lines · Steve Tsai
Quoted 1 line
That's the fault of our board. We can not adujst a proper
chip_delay,Quoted 1 line
so we add a circuit to check the ready bit and it does not
have these
Quoted 1 line
errors so far. Do you think
chip_delaycan be used withNAND flash? I
Quoted 2 lines
don't think it is good idea to use
chip_delay.I'm pretty sure, that
chip_delayis working.Cite from data sheet:
'..Page Read... by writing 00h to the command register along with three address cycles. ... The 528 bytes of data within the selected page are transferred to the data registers in _LESS_ than 10us(tR). The system controller _CAN_ detect the completion of this data transfer(tR) by analyzing the output of R/B pin. Once the data in a page is loaded into the registers, they may be read out by sequential RE pulse of 70ns/50n(K9F2808Q0B:70ns,
K9F2808U0B:50ns) period cycle. High to low transitions of the RE clock take out the data from the selected column address up to the last column address. 'As tR is defined as a max value of x ms, it's safe to use it. I tested this, when we started the work on JFFS2/NAND. I could verify with the scope, that R/B high transition was always within the specified time.
For program and erase we use a different scheme. If we have no access to the R/B pin, we read back the Status Register. Bit 6 is a mirror of R/B pin.
If increasing of
chip_delayhas no effect on your device, could you verify all the other timing constraints ? AS you use chipselects for WE and RE, are you sure that data hold time (tdh) is guaranteed ? Usually tdh on a CPU is specified from the rising egde of WE, which is earlier than the rising egde of a CS.
Quoted 3 lines
Have you ever tried to set
chip_delayto 1 ? Then you should get a bunch of errors.
We use udelay function here, but I found that ARM uClinux can not provide a stable delay function. I write my own delay function and I will not get errors. I will use ready bit , because it make the JFFS2 drivers faster.
Steve Tsai