UBI: badblock management confusion!

Adrian Hunter ext-adrian.hunter at nokia.com
Mon Apr 28 10:08:06 EDT 2008


Nancy wrote:
>>> Let me clarify the problem I met:
>>>        there are so many Nand flash for burning. Each one of them may have
>>> different numbers of badblocks, but that number do not exceed the reserved
>>> badblock number. Each one of them should have the same maximum avaliable
>>> volume size. But the practice tell no, the maximum avaliable volume size
>>> effect by number of badblocks the current MTD partition has. That's wrong.
>>> You can try by yourself.
>>>
>>>
>> The following section from UBI documentation may help you:
>>
>>
>> http://linux-mtd.infradead.org/doc/ubi.html#L_autoresize
>>
>> Let us know if it doesn't meet your needs.
> 
> Sorry, my bad english, I can't get what autoresize for.
> I just want to set every Nand same! Just like I defined my MTD
> partitions. Each product has same partitions table.
> same reserved badblock number.
> same user space useable blocks.
> Is that requirement abnormal?

Well, the number of initial bad blocks does not affect how many will become
bad over time.  So it is not part of the calculation.  For example, if you
have 2048 PEBs and 17 are bad initially and you want to reserve 1% for (more)
bad blocks then the number reserved is (2048 - 17) / 100 = 20.  That makes the
default maximum volume size 2048 - 17 - 20 = 2011.  Whereas, if you are lucky
and there are no initial bad blocks, then the number reserved for bad block
handling is 2048 / 100 = 20, and the default maximum volume size is
2048 - 20 = 2028.

Just because 17 are initially bad in the first case does not mean only 3 more
will become bad in the time it takes for 20 to become bad in the second case.

So 20 are reserved for bad block handling in both cases.

And that means that the maximum volume size varies.

What we do here is we don't have the same partition table.  We fix the size of
every partition except the last and let the start of each partition be adjusted
if there are bad blocks.  For the last partition, it ends up being smaller by the
total number of bad blocks.  We then use the "autoresize" of UBI to automatically
fit the volume size of the last volume to the partition size.  Since our last
volume is UBIFS, there is no problem because UBIFS also automatically adjusts
(so long as the volume size is larger that the flashed image created by
mkfs.ubifs).

If you want to have the same volume size, then you can but you must make the
size smaller than the maximum.  You will need to consult your documentation
about what the maximum number of initial bad blocks is.  For example, for
OneNAND with 2048 PEBs, when a OneNAND comes from the factory it may have
as many as 40 PEBs that are bad.  So 2048 - 40 = 2008 good PEBs minimum.
2008 / 100 = 20 PEBs reserved for (more) bad blocks (assuming you use the 1%
setting).  2008 - 20 = 1988 PEBs for the volume size.  The exact volume size is
then 1988 * LEB size = 1988 * 258048 (in your case) = 512999424.





More information about the linux-mtd mailing list