How sysupgrade works

Is there any page which explains how sysupgrade downloads the firmware file to which partition
and how it replaces the partition and makes it active ?

Basically would like to understand how sysupgrade manipulates with the partitions.


It’s primarily a set of relatively readable shell scripts. The details vary by device, memory, and image type. Your device’s scripts are typically under /lib/upgrade/ as I recall. Others can be seen in the source.

“Make it active” is sort of a MBR thing. On an embedded device typically the boot loader loads the kernel from a pre-defined location in flash to RAM, puts the command line (and perhaps DTB and other info) into RAM, puts references to those into the CPU’s registers and jumps to the entry point of the kernel. The kernel typically has the information on how to interpret the flash

Depends on the device (and on the bootloader and then on OpenWrt on DTS/mach selctions).

Most devices just have a fixed partitioning scheme, and the bootloader just loads the bytes and passes control to kernel, like jeff says.

If you are talking about dual-boot devices like some Linksys routers, the bootloader also has its own variables (stored in flash), which describe which of the two possible kernels should be loaded.

(partition table itself is usually fixed and just defined at the compile time and stored in DTS or in mtd (in some old systems) or ... )

If you want definitive help from somebody, please specify clearly which device you are talking about (and edit also the thread title to contain that device clearly)