How to write to nand with an image containing oob data, including ECC?

Ricard Wanderlof ricard.wanderlof at axis.com
Wed Mar 30 03:33:36 EDT 2011


On Wed, 30 Mar 2011, Kelly Anderson wrote:

>>> $ 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
>>>
>>>
>>> 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 :-)
>>
> OK, I'll be nice.
>
> When I sent the original bug report I was dog tired.  Now with a good
> nights sleep I've got the energy to write a fix.
> ...

Artem, my case seems to be a completely different problem. I tried 
applying Kelly's patch and it didn't make a difference in my case. Makes 
sense, as the error messages in the bug report were entirely different 
from what I was getting.

(That's not to say Kelly's patch doesn't work or do what it's supposed to 
do, it just didn't seem to be related to the problem I've been having).

But I am I right in understanding that nandwrite should perform as I 
expect it to when I say -o and -n to it? I.e. the -o means there's oob 
data in the image, and -n means don't write any ECC, so the image I'm 
supplying should be written exactly as it looks to the flash, including 
the oob?

If it is in fact the case I might have a go at fixing it eventually. Need 
to find some other solution right now though (like patching the kernel to 
force errors on write or something like that).

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30



More information about the linux-mtd mailing list