I am struggling on flashing a previous ROM dump of an embedded device in Linux. My previous dump contains oob data. I wrote it with nandwrite -n -N -o /dev/mtd0 backup.bin
, and then take a ROM dump again.
By comparing the old and new ROM dump, I see some un-explainable situation: the last 24 bytes of the oob (ecc bytes) of any empty blocks (filled with 0xFF) is ought to be 0xFF also, but those in the new ROM dump is filled with 0x00, causing later write failures.
oob ought to be:
FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
but for nandwrite
:
FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
FFFFFFFF FFFFFFFF 00000000 00000000
00000000 00000000 00000000 00000000
Anyone has any idea why?
I added a hack in the nandwrite
code, to skip writing to NAND if the content to be written is 0xFF
, and it worked. So the problem exists when trying to write an empty page to the NAND?
ADDED:
Now I am having this problem also when writing a bootloader image. The image isn't page-aligned so nandwrite
padded it with 0xFF
. But for pages with only 0xFF
the ecc bytes are still polluted by 0x00
just like above. Seems that my hack doesn't totally solve my problem. Anyone can help? Perhaps it could be a bug in kernel 2.6.35?
This is my hack:
int i;
int needwrite=0;
for (i = 0 ; i < len ; ++i){
if(((uint8_t*)data)[i]!=0xff){
needwrite=1;
break;
}
}
if(!needwrite)
return 0;
nanddump
on my bizarre hardware? The people are right to tell you not to ignore the OOB data. Can we close this question as it is too localized? As it is now, this sound like a comment on how to hack-upnanddump
for some specific hardware's purpose. Can you fix up the question to make it more relevant for more people? I am usingnanddump -qobf file /dev/mtdXXX
andnandwrite -p /dev/mtdXXX file
and want to know if I am wrong. Google showed me this question. – artless noisenanddump
has different functionality (as well as command line arguments) so I don't think this question can be applied generally. Check the help page of your version. – Alvin Wong