[Yaffs] Re: How to do "low-level format" on NAND MTD partito…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Wookey
Date:  
To: yaffs
Subject: [Yaffs] Re: How to do "low-level format" on NAND MTD partiton?
On 2007-04-06 00:04 +0800, Tian Jin wrote:
> Hi, I'm using a 4GB(4 x 1GB NAND chips) NAND partition on my at91rm9200 ARM
> board, recently, I found half of my NAND eraseblocks were reported as "bad
> block" by yaffs2(v1.59, v1.48) at mount time. I think those blocks must be
> marked "BAD" by mistake, because those NAND chips are quite new and show
> few bad blocks by MTD driver at boot time:
>


>
> As we can see, the first two NAND chips are reported correctlly, but the
> last two chips are reported 99% bad blocks, but the freespace of 4GB
> partiton is 3.5GB NOT 2GB:
>
> ARM nand]# du
> 2    ./lost+found
> 4    .
> [ARM nand]# df
> Filesystem           1k-blocks      Used Available Use% Mounted on
> tmpfs                    14984         4     14980   0% /dev
> /dev/mtdblock6         4194176    620032   3574144  15% /mnt/nand

>
> I have used nand_erase to erase entire NAND partiton but the problem
> remains.
> Is it a yaffs bug? If it's not, how can I low-level format it (to clear
> those bad block marks) ?


The bad block marker position depends on flash page size/MTD
version/yaffs version, but is normally OOB byte 5 for 512b page/yaffs1
and OOB byte 0 for 2K nand/yaffs2. 0xFF is good, anything else is bad.
All the normal flash utils will respect these markers and refuse to
write such blocks so to fix this you need to hack the tools a little.
It is easy to just go through and set them all to 'OK', but beware
that there are a few that probably _are_ bad so you really want
something (like yaffs) so read and write it all to check for genuine
failures and mark accordingly.

Your problem could be caused by a nand driver bug which is doing the
wrong thing for the last 2 chips (i.e. messing up the oob layout), or
it could be due to some previous driver bug which caused all writes to
fail and get the blocks marked bad accordingly. Maarking them all good
again is a sensible thing to try at this stage.

Just pass over all the blocks, erasing them, ignoring any bad-block
checking, which will normally be present. There is a (n unecessarily
complicated) example here:
http://balloonboard.org/cgi-bin/viewcvs.cgi/balloon/branches/bootldr36-pxa-sa1100/nand/nand_base.c?rev=104&view=markup
(grep for 'force_erase')

the nand-utils probably have an example that is much simpler.

The above is boot-loader code so can be run without userspace (but
that bootloader needs gcc 2.95 to compile properly so I certainly
don't recommend you actually use it :-) I just happen to be familiar.

Wookey
--
Principal hats: Balloonz - Toby Churchill - Aleph One - Debian
http://wookware.org/