mtd nand erase and bad block

Angus CLARK angus.clark at st.com
Tue Jul 3 11:05:06 EDT 2012


Hi Artem,

On 07/03/2012 01:22 PM, Artem Bityutskiy wrote:
> On Mon, 2012-07-02 at 08:14 +0100, Angus CLARK wrote:
>> On 06/29/2012 11:31 AM, Artem Bityutskiy wrote:
>>> On Wed, 2012-06-27 at 13:37 +0100, Angus CLARK wrote:
>>>> However, for case 2, I just want to force the erase operation so I can wipe the
>>>> BBTs and return the device as close as possible to its original state.  We could
>>>> put some logic in the kernel, "if 'MEMBBSCRUB" on BBT blocks, do not
>>>> update/rewrite BBTs", but I think this "policy" decision would be better handled
>>>> in userspace.
>>>
>>> Sounds like you need 2 separate ioctls:
>>> 1. MEMBBSCRUB
>>
>> There are occasions when it is useful to unmark a bad block, but without erasing
>> first.  Therefore, I guess my preference would be to split this further:
>> 'erase-bad-block' and 'mark-block-as-good'.
> 
> I can smell over-engineering 

Indeed.  The solution I shared at the start of this thread involved a 3-line
patch to add a debugfs entry!  This meets our own requirements for
debug/development, although I admit it is a little unsafe when used
inappropriately ;-)

> - any good example? 

One example would to be regain access to blocks that were incorrectly identified
as bad during the creation of the BBTs.  This can happen when the NAND device is
pre-programmed with a boot-loader or test-software, but the process used to
perform the pre-programming does not write the BBTs.  If the ECC data is such
that it clashes with the OOB BBM, then linux will detect these as bad blocks on
first boot.  Of course, the problem lies with the pre-programmer, but it is
helpful to get access to the blocks in linux without erasing the data first.

> Note, you will leave
> unused bytes in the ioctl data structure an make it extandable in the
> future.

So, are you suggesting that I implement a MEMBBSCRUB ioctl, with a flag to
indicate whether or not the BBTs should be updated (and some extra padding for
future-proofing)?  Might have think about what happens when called on blocks
reserved for the BBTs...

Cheers,

Angus




More information about the linux-mtd mailing list