Skip to content

HowTo make backup snapshot of your device state via the console

Sander edited this page May 11, 2017 · 16 revisions

It can be a good idea to a backup of your device's memory state, especially before installing a new firmware. New firmware versions may introduce bugs, region blocking or firmware downgrading blocking. With backups of the current state of your device, it !MIGHT! help you to get your device back to it's current state.

Based upon firmware version v3.0.3.56.

Backup via console to SDCard

If you have access to the console (SSH, telnet, serial), you should be able to login to your device and create a snapshot of the state of your device and store it for when-needed. These are the steps to follow:

  1. Logon to your device via SSH, Telnet of Serial. (root / ismart12)
  2. Insert a SD card in your device to store the various backup files.
  3. Change directory to the mountpoint of your SDCard.
  4. Execute: cat /proc/partitions > partitions.proc
  5. Execute: cat /proc/mtd > mtd.proc
  6. Execute: dd if=/dev/mtdblock0 of=mtdblock0.bin bs=4096 [hw-setting,u-boot,u-env,flash-layout,factory]
  7. Execute: dd if=/dev/mtdblock1 of=mtdblock1.bin bs=4096 [kernel]
  8. Execute: dd if=/dev/mtdblock2 of=mtdblock2.bin bs=4096 [rootfs-r]
  9. Execute: dd if=/dev/mtdblock3 of=mtdblock3.bin bs=4096 [rescue]
  10. Execute: dd if=/dev/mtdblock4 of=mtdblock4.img bs=4096 [rootfs-rw]
  11. Execute: dd if=/dev/mtdblock5 of=mtdblock5.img bs=4096 [user]
  12. Execute: /bin/nvram_utility list
  13. Execute: /bin/nvram_get -f UserRelated UserRelated.nvr [273 bytes]
  14. Execute: /bin/nvram_get -f UserRelated_UID UserRelated_UID.nvr [200 bytes]
  15. Execute: /bin/nvram_get -f UserRelated_SSID UserRelated_SSID.nvr [73 bytes]
  16. Execute: /bin/nvram_get -f NetRelated NetRelated.nvr [0 bytes]
  17. Execute: /bin/nvram_get -f NetRelated_IP NetRelated_IP.nvr [0 bytes]
  18. Execute: /bin/nvram_get -f NetRelated_MAC NetRelated_MAC.nvr [0 bytes]
  19. Eject the SDCard and check the result of the backup

Backup via snx_autorun.sh on SDCard

  1. Create the file 'snx_autorun.sh' on your sdcard and paste the following content:

    #!/bin/sh

    cd /media/$MDEV/

    cat /proc/partitions > partitions.proc

    cat /proc/mtd > mtd.proc

    dd if=/dev/mtdblock0 of=mtdblock0.bin bs=4096

    dd if=/dev/mtdblock1 of=mtdblock1.bin bs=4096

    dd if=/dev/mtdblock2 of=mtdblock2.bin bs=4096

    dd if=/dev/mtdblock3 of=mtdblock3.bin bs=4096

    dd if=/dev/mtdblock4 of=mtdblock4.img bs=4096

    dd if=/dev/mtdblock5 of=mtdblock5.img bs=4096

    /bin/nvram_utility list > list.nvr

    /bin/nvram_get -f UserRelated UserRelated.nvr

    /bin/nvram_get -f UserRelated_UID UserRelated_UID.nvr

    /bin/nvram_get -f UserRelated_SSID UserRelated_SSID.nvr

    /bin/nvram_get -f NetRelated NetRelated.nvr

    /bin/nvram_get -f NetRelated_IP NetRelated_IP.nvr

    /bin/nvram_get -f NetRelated_MAC NetRelated_MAC.nvr

Backup via Serial console, U-Boot

[Not (yet) possible]

Restore from SDCard via Serial console, U-Boot

To restore your device based on these backups, you'll have to do it via a serial console via u-boot. You can then use fatupdate to restore the data on your device. The files do need some preperation before a restore can be done. For some reason the files are too long for flashing and need to be truncated to a specific size. The end of the files are padded with the same character. I used https://code.google.com/archive/p/trunc/ to cut my files down to the correct size.

  • mtdblock0.bin: backup-size= 786.432 bytes fatupdate-size:
  • mtdblock1.bin: backup-size=3.145.728 bytes fatupdate-size: 3.038.292 bytes
  • mtdblock2.bin: backup-size=7.340.032 bytes fatupdate-size: 7.155.824 bytes
  • mtdblock3.bin: backup-size=4.194.304 bytes fatupdate-size:
  • mtdblock4.bin: backup-size=1.048.576 bytes fatupdate-size:
  • mtdblock5.bin: backup-size= 262.144 bytes fatupdate-size:

These are the commands you can use to restore the different parts:

  1. Connect your serial
  2. Start Putty and connect on 115200 baud
  3. Put truncated MTD files in the root of your SDCard (FAT formatted)
  4. Put SDCard in the slot of the camera
  5. Rapidly press enter in the putty console when powering on the device. The U-boot delay is set to 0 seconds. If you see the kernel booting... try... try again!
  6. The U-boot command prompt should appear: #sonix
  7. Execute: help [Will display the list of U-boot commands]
  8. Execute: fatls mmc 0 [Will display the files on your SDCard]
  9. Execute: fatupdate mmc 0x0c0000 mtdblock1.bin kernel
  10. Execute: fatupdate mmc 0x3c0000 mtdblock2.bin rootfs-r
  11. Execute: reset

At the moment i don't know why the backup files can't directly/unaltered be flashed back to MTD blocks.

The NVRam backups probably can be restored via the console (ssh, telnet, serial) with the utility "/bin/nvram_set". I didn't try this yet.