Quantcast
Channel: Linux Device Hacking
Viewing all articles
Browse latest Browse all 3247

Restore to mtd partitions (no replies)

$
0
0
Hi
I have some files and I want to write in mtd partitions.

My files name are:
- BOOT.bin
- devicetree.dtb
- rootfs.jffs2
- uImage

How can I do it?
These images has a .sh file to install.
here is the code:

if [ -e BOOT.bin ]; then
        flash_erase /dev/mtd0 0x0 0x80 >/dev/null 2>&1
        nandwrite -p -s 0x0 /dev/mtd0 ./BOOT.bin >/dev/null 2>&1
        rm -rf BOOT.bin
    fi

    if [ -e devicetree.dtb ]; then
        flash_erase /dev/mtd0 0x1020000 0x1 >/dev/null 2>&1
        nandwrite -p -s 0x1020000 /dev/mtd0 ./devicetree.dtb >/dev/null 2>&1
        rm devicetree.dtb
    fi

    if [ -e uImage ]; then 
      flash_erase /dev/mtd0 0x1100000 0x40 >/dev/null 2>&1
      nandwrite -p -s 0x1100000 /dev/mtd0 ./uImage >/dev/null 2>&1
      rm uImage
    fi

    if [ -e rootfs.jffs2 ]; then
      if [ -f /dev/mtd3 ];then
          flash_erase /dev/mtd2 0x0 0x1E0 >/dev/null 2>&1
      else
          flash_erase /dev/mtd2 0x0 0x280 >/dev/null 2>&1
      fi
      nandwrite -p -s 0x0 /dev/mtd2 ./rootfs.jffs2 >/dev/null 2>&1
      rm rootfs.jffs2
    fi

When I want to run "flash_erase /dev/mtd0 0x0 0x80"
I get this error:

libmtd: error!: "/dev/mtd0" is not a character device
flash_erase: error!: mtd_get_dev_info failed

How can I do it?
thanks

Viewing all articles
Browse latest Browse all 3247

Trending Articles