From: Angus CLARK <angus.clark@st.com>
To: linux-mtd@lists.infradead.org
Subject: Re: mtd nand erase and bad block
Date: Fri, 01 Jun 2012 09:29:22 +0100 [thread overview]
Message-ID: <4FC87D62.6020402@st.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1206010837100.4247@lnxricardw.se.axis.com>
I have to do this regularly for testing new NAND drivers. After getting fed up
with doing temporary hacks all the time, I ended up adding a
'nand_erasebadblock' entry to debugfs, which overrides the check in
nand_erase_nand():
...
if (!nand_erasebadblock &&
nand_block_checkbad(mtd, ((loff_t) page) <<
chip->page_shift, 0, allowbbt)) {
...
The sequence in userspace would then be something like:
target% echo 1 > /sys/kernel/debug/nand_erasebadblock
target% flash_erase -N /dev/mtd6 0x00200000 1
target% echo 0 > /sys/kernel/debug/nand_erasebadblock
You need to be careful to only erase marked bad blocks that you know are
actually good, or else you risk loosing the factory-programmed bad block markers.
This method is also useful for erasing the BBTs, which will then force the
driver to re-scan for OOB markers on the next boot. Again care needs to be
taken, as you may loose information about blocks that have gone bad through
wear. (The recent patch "mtd: nand: write BBM to OOB even with flash-based BBT"
partly overcomes this issue.)
Typically, debugfs is only enabled in development environments, and even then it
requires explicit user action, so this method of enabling erasing bad blocks is
safe enough for our needs.
Happy to do a patch if others are interested...
Cheers,
Angus
On 06/01/2012 07:37 AM, Ricard Wanderlof wrote:
>
> On Fri, 1 Jun 2012, Adrian Hunter wrote:
>
>>> What's the way for recheck bad blocks and refresh the BBT from userspace
>>> application?
>>
>> I always just temporarily hack the kernel driver to allow the erase of
>> the
>> bad block in question.
>
> I agree. Having that capability available at all times would be scary.
>
> /Ricard
next prev parent reply other threads:[~2012-06-01 8:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-31 12:12 mtd nand erase and bad block Matteo Facchinetti
2012-05-31 13:28 ` Adrian Hunter
2012-05-31 14:28 ` Matteo Facchinetti
2012-05-31 19:57 ` Shmulik Ladkani
2012-06-01 6:24 ` Adrian Hunter
2012-06-01 6:37 ` Ricard Wanderlof
2012-06-01 8:29 ` Angus CLARK [this message]
2012-06-01 8:42 ` Artem Bityutskiy
2012-06-01 11:04 ` Shmulik Ladkani
2012-06-01 14:03 ` Angus CLARK
2012-06-01 14:54 ` Shmulik Ladkani
2012-06-01 15:28 ` Angus CLARK
2012-06-05 12:17 ` Artem Bityutskiy
2012-06-14 17:48 ` Brian Norris
2012-06-14 21:31 ` Shmulik Ladkani
2012-06-15 6:55 ` Angus CLARK
2012-06-26 22:10 ` Tomer Barletz
2012-06-18 9:34 ` Angus CLARK
2012-06-27 9:54 ` Artem Bityutskiy
2012-06-27 12:37 ` Angus CLARK
2012-06-29 10:31 ` Artem Bityutskiy
2012-07-02 7:14 ` Angus CLARK
2012-07-03 12:22 ` Artem Bityutskiy
2012-07-03 15:05 ` Angus CLARK
2012-07-16 14:37 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FC87D62.6020402@st.com \
--to=angus.clark@st.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).