Re: [Yaffs] function nandmtd1_ReadChunkWithTagsFromNAND in y…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Ian McDonnell
Date:  
To: yaffs, embedded technology
CC: Jonathan McDowell
Subject: Re: [Yaffs] function nandmtd1_ReadChunkWithTagsFromNAND in yaffs_mtdif1.c can't recognise the bad block?
On Tuesday 25 September 2007 09:42, wrote:
>         My kernel is linux 2.6.22.6,
>         and yaffs_mtdif1.c's version is : "$Id:
> yaffs_mtdif1.c,v 1.2 2007/07/23 19:14:04 imcd Exp $";
>
>         My nand flash has many bad blocks, but the yaffs can't
> recognise them: there isn't any "block %d is bad" information,
> and the yaffs partition can be mounted, but can't be used(it
> is the root filesystem, can't boot).
>
>         When I use linux 2.6.13, and the code of yaffs2 is the
> same, and it can boot on the nand flash, and print more
> information of bad block , such as:
>         block 3 is bad
>     block 100 is bad
>
>         In the function nandmtd1_ReadChunkWithTagsFromNAND,
> the 'etags->blockBad' won't be set if 'retval =
> mtd->read_oob(mtd, addr, &ops)' is 0, so it can't recognise
> any bad block, isn't it ?


You're right mtd->read_oob does not return an error when reading
a bad-block. Thanks for pointing this out. This may well be
the source of the issue reported yesterday by Jonathan.

This patch adds a direct call to mtd's bad-block test function
during the initial scan, where Yaffs learns about the block state.
Unfortunately the fix can slow down the scan, but I don't see any
better solution without a functional tweak to MTD.

-imcd

diff -u -I ''\''$Id'\''' -I ''\''$Revision'\''' -u -a -r1.2 yaffs_mtdif1.c
--- yaffs_mtdif1.c    23 Jul 2007 19:14:04 -0000    1.2
+++ yaffs_mtdif1.c    25 Sep 2007 16:05:45 -0000
@@ -327,6 +327,7 @@
 {
     struct mtd_info * mtd = dev->genericDevice;
     int chunkNo = blockNo * dev->nChunksPerBlock;
+    loff_t addr = (loff_t)chunkNo * dev->nDataBytesPerChunk;
     yaffs_ExtendedTags etags;
     int state = YAFFS_BLOCK_STATE_DEAD;
     int seqnum = 0;
@@ -340,6 +341,7 @@
     }


     retval = nandmtd1_ReadChunkWithTagsFromNAND(dev, chunkNo, NULL, &etags);
+    etags.blockBad = (mtd->block_isbad)(mtd, addr);
     if (etags.blockBad) {
         yaffs_trace(YAFFS_TRACE_BAD_BLOCKS,
             "block %d is marked bad", blockNo);