public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Ricard Wanderlof <ricard.wanderlof@axis.com>
Cc: Kelly Anderson <kelly@silka.with-linux.com>,
	Linux mtd <linux-mtd@lists.infradead.org>
Subject: Re: How to write to nand with an image containing oob data, including ECC?
Date: Tue, 29 Mar 2011 18:42:51 +0300	[thread overview]
Message-ID: <1301413371.21445.15.camel@localhost> (raw)
In-Reply-To: <Pine.LNX.4.64.1103291723240.25520@lnxricardw.se.axis.com>

On Tue, 2011-03-29 at 17:30 +0200, Ricard Wanderlof wrote:
> Hi,
> 
> In order to test an ECC algorithm (BCH in this case, as I recently posted 
> about), i want to write an image to a nand flash which contains bit 
> errors.
> 
> What I want to do, and I seem to remember doing this in the past, is to 
> dump the whole image, change a single bit, and write it back, including 
> the oob.
> 
> So what I'm doing is
> 
> $ nandwrite -o -n /dev/mtd3 /tmp/mtd3-badimage
> 
> where /tmp/mtd3-badimage contains an image including all oobs for all 
> pages.
> 
> However, this fails saying
> 
> Writing data to block 0 at offset 0x0
> libmtd: error!: cannot write 2048 bytes to mtd3 (eraseblock 0, offset 0)
>          error 22 (Invalid argument)
> nandwrite: error!: /dev/mtd3: MTD write failure
>             error 22 (Invalid argument)
> Data was only partially written due to error
> : Invalid argument
> 
> Using just -o doesn't work because it seems nandwrite writes the oob, but 
> then since it doesn't write the main page in raw mode, the ecc gets 
> overwritten. Strangely enough, the ECC doesn't seem to match the data 
> written, as I get uncorrectable errors when reading back (not just with 
> BCH, but also with the standard mtd built-in algorithm). Perhaps the oob 
> gets written twice, once with my data and once more with the calculated 
> ecc?
> 
> Is this a known bug, or are the some other options I should be using?

Check this bug-report, probably it is about the same. Not sure, I did
not have time to look at this:

http://lists.infradead.org/pipermail/linux-mtd/2011-March/034505.html

would be great if someone just sent a fix :-)

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

  reply	other threads:[~2011-03-29 15:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-29 15:30 How to write to nand with an image containing oob data, including ECC? Ricard Wanderlof
2011-03-29 15:42 ` Artem Bityutskiy [this message]
2011-03-29 22:00   ` Kelly Anderson
2011-03-30  7:33     ` Ricard Wanderlof
2011-04-01  8:27 ` 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=1301413371.21445.15.camel@localhost \
    --to=dedekind1@gmail.com \
    --cc=kelly@silka.with-linux.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=ricard.wanderlof@axis.com \
    /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