How Sysupgrade Flashes the image

Hi All,

Im working on making dual boot support for my Gateway. I'm successful in creating the slave partition and in making bootloader changes to load the image first time to Primary and next time to Slave partition respectively.

However, when I do upgrade the FW using sysupgrade utility it always goes to the Primary partition of the flash.
How sysupgrade flashes the image?
Can we modify the source to load into different partition (primary and slave ) for every upgrade?

Sysupgrade is essentially a series of scripts performing the required tasks to verify, dissect and write an image onto flash. Take a look at /lib/upgrade/ to see what target specific tasks are performed. In there, you likely need to add some conditions using something like uboot-envtools to read a variable containing the active partition to use, then select the destination mtd based on that.

1 Like

Thanks! Will try to modify/ add additional flag to write into respective partition

# Flash firmware to MTD partition
# $(1): path to image
# $(2): (optional) pipe command to extract firmware, e.g. dd bs=n skip=m
# $(2): (optional) pipe command to extract firmware, e.g. dd bs=n skip=m
default_do_upgrade() {
        if [ "$SAVE_CONFIG" -eq 1 ]; then
                get_image "$1" "$2" | mtd $MTD_CONFIG_ARGS -j "$CONF_TAR" write - "${PART_NAME:-image}"
                get_image "$1" "$2" | mtd write - "${PART_NAME:-image}"

You can also declare platform_do_upgrade() which will get called instead of default_do_upgrade() if it exists. This way you do not need to modify the system files.

Another possibility is to simply export PART_NAME=destination_mtd_name in some suitable place of

1 Like