Thank you! What I change is same to you, but now still has some questions, look below: --- /work/embedded_book_source/Development/yaffs2/yaffs_mtdif1.c 2007-07-24 03:14:04.000000000 +0800 +++ yaffs_mtdif1.c 2007-09-25 05:59:29.000000000 +0800 @@ -208,6 +208,9 @@ switch (retval) { case 0: /* no error */ + etags->blockBad = (mtd->block_isbad)(mtd, addr); + if (etags->blockBad) + return YAFFS_FAIL; break; Another question: linux 2.6.22.6, yaffs_mtdif1.c's version is : "$Id: yaffs_mtdif1.c,v 1.2 2007/07/23 19:14:04 imcd Exp $" Flash Type: 512Byte/Page Even for yaffs1, the default nand_ecclayout of yaffs_mtdif1.c is: static struct nand_ecclayout nand_oob_16 = { .eccbytes = 6, .eccpos = {0, 1, 2, 3, 6, 7}, .oobfree = { { .offset = 8, . length = 8}} }; But the nand_ecclayout of utils/mkyaffsimage.c is: static struct nand_ecclayout nand_oob_16 = { .eccbytes = 6, .eccpos = { 8, 9, 10, 13, 14, 15 }, .oobavail = 9, .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } } }; They are diffrent, this is the reason my yaffs partition can be mount, but can't work: in nandmtd1_ReadChunkWithTagsFromNAND, 'retval = yaffs_CheckECCOnTags((yaffs_Tags *)&pt1)' is -1, so all blocks are treated as 'Empty'. I use the second nand_oob_16 above, configure CONFIG_YAFFS_9BYTE_TAGS. And then the system can boot, the content in the yaffs root filesystem can be seen. The question is: it can't boot next time. After the first booting, I do nothing but run 'reset'. The kernel log at the second booting is: VFS: Mounted root (yaffs filesystem). Freeing init memory: 124K Kernel panic - not syncing: No init found. Try passing init= option to kernel. By the way, change the nand_ecclayout seem to be ugly, there is another partions on the nand flash, the ECC layout should be consistent to another tools, such as U-Boot. Do you have some idea? Thank you. >On Tuesday 25 September 2007 09:42, thisway.diy@163.com 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); ĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦembedded technology ĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦthisway.diy@163.com ĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦĦ2007-09-26