All of lore.kernel.org
 help / color / mirror / Atom feed
* nandwrite vs. flashcp when writing image to mtd device
@ 2019-03-20  6:45 Shibin George
  2019-03-21  7:54 ` David Oberhollenzer
  0 siblings, 1 reply; 2+ messages in thread
From: Shibin George @ 2019-03-20  6:45 UTC (permalink / raw)
  To: linux-mtd

Hi,

I wanted to write an image to a mtd device. Here is the /proc/mtd
entry for that mtd device.

/ # cat /proc/mtd
dev: size erasesize name
...
mtd10: 007c0000 00040000 "recovery"
...

First I performed a flash_eraseall on /dev/mtd10 which was successful.
Then, I tried flashcp:
flashcp /path/to/image /dev/mtd10

This command fails with the error:
"While erasing blocks from 0x00000000-0x00680000 on /dev/mtd10:
Invalid argument"

dmesg has the following error:
"msm_nand_erase: unsupported erase len, 6815744"

But if I use nandwrite to write the image, the write works fine:

/ # nandwrite -p /dev/mtd10 /path/to/image
"
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x40000
...
Writing data to block 5 at offset 0x140000
...
Writing data to block 17 at offset 0x440000
Writing data to block 18 at offset 0x480000
Writing data to block 19 at offset 0x4c0000
...
Writing data to block 24 at offset 0x600000
Writing data to block 25 at offset 0x640000"

So is nandwrite the recommended way to write a raw image to a mtd device?
Any reason why flashcp wouldn't work? One query I have is /proc/mtd
lists that the erasesize if 00040000 (262144) but flashcp is reporting
erase len as 6815744..

Appreciate any help in this matter..

Regards,
Shibin George

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: nandwrite vs. flashcp when writing image to mtd device
  2019-03-20  6:45 nandwrite vs. flashcp when writing image to mtd device Shibin George
@ 2019-03-21  7:54 ` David Oberhollenzer
  0 siblings, 0 replies; 2+ messages in thread
From: David Oberhollenzer @ 2019-03-21  7:54 UTC (permalink / raw)
  To: Shibin George, linux-mtd

Hi,

flashcp is a rather crude program and hasn't seen any improvements in way over a decade.
All it does is round the size of your input file up to the reported block size, erases
that range and then writes the input file.

It directly opens the device file, works on the raw fd and does 2 ioctls to retrieve
the erase size and erase that range.

The size of 6815744 happens to be the reported block size of 262144 * 26. Erasing multiple
blocks in one go is supported by the erase ioctl, it is also what libmtd does internally.

However, flashcp is completely oblivious of bad blocks, OOB size and other fun stuff.

nandwrite is somewhat more sophisticated. It is aware of all of the above and has a lot of
extra command line options for fine grained control over those things. It also uses libmtd
to access the flash which in turn is aware of a lot of newer ioctls and provides a number
of fallback code paths.

So yes, I would recommend using nandwrite for writing images to nand flashes.

Regards,

David

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-21  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20  6:45 nandwrite vs. flashcp when writing image to mtd device Shibin George
2019-03-21  7:54 ` David Oberhollenzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.