linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Shmulik Ladkani <shmulik.ladkani@gmail.com>
To: Matteo Facchinetti <matteo.facchinetti@sirius-es.it>
Cc: linux-mtd@lists.infradead.org, Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: mtd nand erase and bad block
Date: Thu, 31 May 2012 22:57:12 +0300	[thread overview]
Message-ID: <20120531225712.79f0c6f2@halley> (raw)
In-Reply-To: <4FC78012.5010704@sirius-es.it>

Hi Matteo,

On Thu, 31 May 2012 16:28:34 +0200 Matteo Facchinetti <matteo.facchinetti@sirius-es.it> wrote:
> On 05/31/2012 03:28 PM, Adrian Hunter wrote:
> > On 31/05/12 15:12, Matteo Facchinetti wrote:
> >> If I try to erase with -N parameter I read the following output:
> >> ~# flash_erase -N /dev/mtd6 0 0
> >> Erasing 1024 Kibnand_erase_nand: attempt to erase a bad block at page
> >> 0x00001600
> >> yte @ 200000 --  5 % complete libmtd: error!: MEMERASE64 ioctl failed for
> >> eraseblock 2 (mtd6)
> >>          error 5 (Input/output error)
> >> flash_erase: error!: /dev/mtd6: MTD Erase failure
> >>               error 5 (Input/output error)
> >> Erasing 1024 Kibyte @ 2700000 -- 100 % complete
> >>
> >> I espected that with -N option, flash_erase should erase the hand-damaged
> >> block, recovering the usability of the block. Is it true?
> >>
> >> What's going wrong?
> >
> > The NAND driver has validation to prevent erasure of bad blocks.  Refer
> > nand_erase_nand() in drivers/mtd/nand/nand_base
> >
> > 		/* Check if we have a bad block, we do not erase bad blocks! */
> > 		if (nand_block_checkbad(mtd, ((loff_t) page)<<
> > 					chip->page_shift, 0, allowbbt)) {
> > 			pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
> > 				    __func__, page);
> > 			instr->state = MTD_ERASE_FAILED;
> > 			goto erase_exit;
> > 		}
> >
> >
> this means that -N parameter bypass only the BBT table check, but in the 
> erase routine there is a low level check that forbids the bad block erase.
> 
> What's the way for recheck bad blocks and refresh the BBT from userspace 
> application?

Well, seems there's no way doing so via Linux MTD APIs.

I know u-boot allows doing so, using its 'scrub' command.
Actually, what it really does is hacks the exact condition quoted above
by Adrian, adding a '!instr->scrub &&' to the condition expression.

I assume such an option could be added to the MEMERASE ioctl.

Regards,
Shmulik

  reply	other threads:[~2012-05-31 19:57 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 [this message]
2012-06-01  6:24     ` Adrian Hunter
2012-06-01  6:37       ` Ricard Wanderlof
2012-06-01  8:29         ` Angus CLARK
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=20120531225712.79f0c6f2@halley \
    --to=shmulik.ladkani@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=matteo.facchinetti@sirius-es.it \
    /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).