Hello,
I am cloning my device's firmware to another same model by doing this:
Backup:
Open LuCi -> go to Flash/Backup Firmware -> select mtdblock8 (firmware) -> save mtdblock which generates the firmware.bin file.
Restore on a new device:
Open LuCi -> go to Flash/Backup Firmware -> Flash firmware -> select the firmware.bin file, and I get exact clone of the original device.
I want to make the procedure easier by doing it form terminal, I tried:
Backup:
cat /dev/mtd8 > firmware.bin
dd if=/dev/mtd8 of=/tmp/firmware.bin
Restore:
ssh: mtd write firmware.bin firmware
terminal: Open LuCi -> go to Flash/Backup Firmware -> Flash firmware -> select the firmware.bin file
The procedure endup with non bootable device.
Any idea how to know what command run in background when pressing the blue button save mtdblock in LuCi Flash/Backup firmware page?
I would suggest you to read openwrt firmware layout wiki before attempting to rewrite boot block using ssh terminal. I do not remember exactly, but wiki suggest to strip the boot sector from image. I think the LuCi does exactly that.
That varies hugely among devices. Needing to strip something from the flashed image is rare.
Flashing the mtdblock contents ia direct mtd is not really supported. It may have worked for the oldest devices with simple images and NOR flash, but does not quite work that way with the newer ubifs images for NAND flash.
You forgot to mention, which device you are talking about...
As you said, it bears repeating that this is for NOR devices only, it definitely will not work with NAND flash.
Either cat (1) or dd (2) should work to create an image. Of course you have to have the output file in /tmp since there is not room in flash for another copy of flash.
Then compare the file to the one you get from LuCI.
Installing the clone with sysupgrade is recommended instead of mtd, but make sure not to save settings.