1

I have an embedded system that I want to read its nand flash and write it back to another system's nand flash. I have access to root of Linux system which is running on device. The system is based on AM3874 and I have access to its JTAG too. My questions are:

1- Can I do this by login to system as root and writing nand flash data to a SD card and then one new system write it back to nand flash?

2- If the answer to above question is yes, what is the procedures and what software I need?

3- If the answer is no, Can I use JTAG interface to read NAND Flash and writing it to another device?

tomlogic
  • 11,489
  • 3
  • 33
  • 59
mans
  • 17,104
  • 45
  • 172
  • 321

2 Answers2

3

You can copy whole device or a partition to a file by using dd command.

Example:

dd if=/dev/mtd/mtd4 of=/mnt/sdcard/system.img bs=4096

Similar way you can copy a file to device.

Edit:

This of course works only with NAND flashes which have device driver in your linux.

If you have mounted filesystem in the flash, then you can use fd or mount commands for finding the correct device name. This way:

~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                53504     13580     39924  25% /
tmpfs                    25600        68     25532   0% /tmp
/dev/mmcblk0p1           77077     67089    722524  92% /mnt/test

~ # dd if=/dev/root of=/mnt/test/root.img bs=4096
13376+0 records in
13376+0 records out

~ # ls -l /mnt/test/root.img
-rw-r--r--    1 root     root     54788096 Oct 26 13:17 /mnt/test/root.img
~ #
SKi
  • 8,007
  • 2
  • 26
  • 57
  • This is correct if the device is handled by a mtd driver in the kernel. Not all flash chips are exposed that way, however. It's not uncommon for things like boot storage to have a separate programming interface hanging on a gpio line somewhere which requires board-specific tools. – Andy Ross Oct 24 '12 at 19:33
  • How can I find which device is my nand flash? – mans Oct 25 '12 at 13:33
  • Really you need to ask your hardware vendor, or someone else who knows about it. There's no generic framework for this stuff. – Andy Ross Oct 25 '12 at 18:16
  • @User1: Thanks. In your example, how did you find that /dev/rot is the nandflash system? – mans Oct 26 '12 at 10:46
  • @mans : I just make copy of the root file system "/" for example. There can be several NAND- or NOR- flash devices in your system. If the wanted data is in behind a mount point /foo/bar, then use dd for device which is mounted to that point. – SKi Oct 26 '12 at 11:45
  • @User1 What do you mean by "bs=4096" ? – Dr.jacky Oct 07 '15 at 05:02
  • instead of `dd` on the mtd device, it's better to use `nanddump` because this tool can handle memory errors – Daniel Alder Jul 07 '16 at 10:36
1

You might be able to use the dd command in Linux to read the device on the first system. On the target, you'll want to unmount any filesystems on the NAND flash before writing it out. Can you run entirely from a ramfs or a filesystem on the SD card? If you're able to unmount it, dd should allow you to write the contents back out.

If possible, you might want to unmount the NAND on the source system before copying it with dd, so you're not copying a live filesystem.

Do you just need to copy the files? If so, would creating a tarball from the first device and unpacking it on the other be an option?

tomlogic
  • 11,489
  • 3
  • 33
  • 59