I guess you should look at mtd
rather than dd
. mtd
is the tool sysupgrade
uses to write the firmware
partition.
At the uboot level, only 4 partitions exist, uboot
, uboot_env
, factory
and firmware
, the last one covering the entire remaining space of the flash.
firmware
contains the uimage
, which consists of a header, the kernel, and the compressed (squashfs) rootfs. It's is the mtd kernel driver which only later creates the kernel
, rootfs
and rootfs_data
partitions on the fly, and also makes kernel
and rootfs
read-only (because these don't even align with erase blocks, you can see this in the output of dmesg
)
I guess you'll be able to write something arbitrary into firmware
using mtd
, but I doubt just a 1:1 copy of the uboot partition will do, because as far as I understand, uboot needs to find that uimage
header at the beginning of firmware
to instruct uboot what to do with the contents (decompress, load into ram, call,...). So you probably need to prefix your second copy of uboot with a suitable uimage
header such that it gets properly loaded and started.
Anyway, for such experiments, personally I'd try to do this from the uboot console, not from within linux, because the latter will work only one time (and then you'd need to recover via uboot http server or similar anyway).
[Update] If you have the openwrt sdk installed, you'll also have the mkimage
tool in ./staging_dir/host/bin/mkimage
which can generate uimage headers.