Hi Charles, This patch is indeed working. Note that before adding your line, I also need to add dev->nFreeChunks += dev->param.nChunksPerBlock; Otherwise, I get error of "Freechunks verification failure" -----Original Message----- From: Charles Manning [mailto:manningc2@actrix.gen.nz] Sent: Monday, March 07, 2011 12:09 AM To: yaffs@lists.aleph1.co.uk Cc: Amir Comforti Subject: Re: [Yaffs] "garbage" blocks during mount On Monday 07 March 2011 00:24:42 Amir Comforti wrote: > Hi, > > I am working with yaffs2 with "direct" approach (no linux). > During development of my system, there could be a case where some of the > blocks on NAND which should be dedicated for yaffs partition were written > previously by some other layer. Sometimes, yaffs mount succeeds, but those > several blocks are kept in NEEDS_SCANNING state and yaffs can't use them. > Is there a way for me to know (i.e. during or after yaffs mount) that there > are blocks that yaffs can't handle, so I will erase them? It is better to erase the flash area before you use yaffs on it if you can. You could try the following patch to see if that works for you: diff --git a/yaffs_yaffs2.c b/yaffs_yaffs2.c index 961f01e..c16dce7 100644 --- a/yaffs_yaffs2.c +++ b/yaffs_yaffs2.c @@ -1420,6 +1420,7 @@ int yaffs2_scan_backwards(struct yaffs_dev *dev) yaffs_trace(YAFFS_TRACE_SCAN, "Block scanning block %d has bad sequence number %d", blk, seq_number); + yaffs_block_became_dirty(dev, blk); } } bi++; If a block has stuff in it but does not have a valid sequence number then it is erased. Try that and see if it works. -- CHarles