NAND bad blocks
Charles Manning
manningc2 at actrix.gen.nz
Thu Apr 15 18:35:17 EDT 2004
On Friday 16 April 2004 04:39, J.D. Bakker wrote:
> Hi all,
>
> There's a slight discrepancy between what mtd and mkyaffs consider a bad
> block.
>
> From mtd/drivers/mtd/nand/nand.c:
>
> static int nand_block_bad(struct mtd_info *mtd, unsigned long page)
> {
> struct nand_chip *this = mtd->priv;
>
> this->cmdfunc (mtd, NAND_CMD_READOOB, NAND_BADBLOCK_POS, page);
> if (this->read_byte(mtd) != 0xff)
> return 1;
>
> return 0;
> }
>
> ...which would indicate that even one bit set to zero would mark the
> block bad. However, mkyaffs.c has this code:
>
> /* Read the OOB data to determine if the block is valid.
> * If the block is damaged, then byte 5 of the OOB data will
> * have at least 2 zero bits.
> */
>
> ..snip..
>
> if(countBits[oobbuf[5]] < 7)
> {
> printf("Block at 0x08%lx is damaged and is not being
> formatted\n",addr);
> }
The idea with the bit counting in YAFFS is to prevent a single bad bit
causing a block to be erroneously marked bad, thereby losing your data.
In reality this situation hardly ever, if ever, arises and the two code
sequences are pretty much equivalent.
-- Charles
More information about the linux-mtd
mailing list