Search code examples
linuxu-boot

How to transfer firmware from device to device using u-boot and linux console?


I have identical devices and I want to copy the firmware of one to another. I have tried the way described here at Hacking HI3518 based IP camera that is copying mtd partitions and storing them to other device using sf commands. However, I failed at probing stage (another problem). So, I am looking for another way.

Do you know how to transfer firmware from device to device using u-boot and linux console?


Solution

    • Check mtd partions: cat /proc/mtd (linux device)

      mtd0: 00100000 00020000 "boot1"
      mtd1: 00100000 00020000 "m0patch"
      mtd2: 00100000 00020000 "dtb"
      mtd3: 00200000 00020000 "config"
      mtd4: 00100000 00020000 "info"
      mtd5: 00200000 00020000 "u-boot1"
      mtd6: 00200000 00020000 "u-boot2"
      mtd7: 00800000 00020000 "kernel1"
      mtd8: 00800000 00020000 "kernel2"
      mtd9: 01e00000 00020000 "initrd"
      mtd10: 3c600000 00020000 "rootfs"
      
    • Copy the mtd partion: dd if=/dev/mtdblock9 of=/tmp/mtdblock9 bs=65536 (linux device)

    • Copy the mtd from device to host using whatever channel avaliable (I use z-modem) : lsz /tmp/mtdblock9

    • Delete the mtd partion from Nand: nand erase initrd (u-boot of other device)

    • Delete the mtd partion from mtdparts mtdparts del initrd(u-boot of other device)

    • Get the mtd image from host to other device (I use kermit and loadb): gives the address and size which is used in the next command. (Lets say they are 0x00000001 and 0x4000 respectively)

    • Write to nand this copied image: nand write <memory address> <offset> <size> (0x1e00000 is given in the first command as offset)

       nand write 0x00000001  0x1e00000  0x4000
      
      NAND write: device 0 offset 0x01e00000  , size 0x4000
      16384 bytes written: OK