Count bad blocks on NAND -

Martin Langhoff martin.langhoff at
Tue Sep 1 07:48:42 EDT 2009

I've wanted for a while to have a userland means to get a precise
report on the number of bad blocks (as seen by the MTD driver, which
reads the NAND BBT). MTD has this info, but it's only accesible via an
ioctl(). Mitch added a similar trick to OFW -- in practice a
self-standing binary is a lot easier to use on suspect machines.

Here's a very rough-but-works patch, and a precompiled 'mtd_debug'
binary that has been tested to work on 656 and 802.

How to use - as root:

  modprobe mtdchar
  /path/to/mtd_debug info /dev/mtd0

The output will include a line about "mtd.badblockscount".

Note: The number is over-reported by 4 when you compare it with OFW --
I am not sure why the accounting done by the MTD driver differs from
the accounting done by OFW.

Wiki is dead at the moment -- will add this info when the wiki is back.


 martin.langhoff at
 martin at -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first

More information about the Devel mailing list