How/where is the config saved during sysupgrade?

I am trying to learn more about the sysupgrade process in the hopes of perhaps improving or modifying it for my platform (MT7622). One thing I'm a little confused about is exactly where the designated configuration files get stashed during a sysupgrade.

As far as I can tell, they are listed in /tmp/sysupgrade.conffiles and archived in /tmp/sysupgrade.tgz. But what happens to them after that? I understand that there is a script /lib/preinit/80_mount_root that looks for the file in /sysupgrade.tgz. What is the filesystem for / at that point?

It's really just where that file goes in between sysupgrade being called and rebooting that I don't know. I assume it does't stay in /tmp because that's a /tmpfs which will not persist across reboots. Is there a "more persistent" filesystem that's created in RAM to store the configuration in, that persists across reboots but not hard power cycles? Is it stored on the actual persistent storage (SPI NOR flash in the MT7622's case)?

The config backup storage strategy varies a bit, depending on the router's flash type and partition structure. Generally it is stored as a (raw) file to flash, and then read and destroyed at reboot, so that it does not affect the next reboot

Typical ways are

  • Store it after the flashed firmware on flash, where it is then found when the end of the sysupgrade file is searched. (Old nor flash systems)
  • Store it into a new UBI partition that is then used as the new rootfs_data (nand flash with ubi)
  • Use an extra partition for it. E.g. with mvebu dualboot routers, there is unused OEM syscfg partition which gets hijacked for storing the file.

You need to look into /lib/upgrade contents, both from base-files and from target/subtarget.

3 Likes

I've been digging around in there, but the thing I can't find is the platform_copy_config() for the MT7622. Under the buildroot, if I look in /target/linux/mediatek/m7622 there don't seem to be any files that provide a definition for this. Doing a global search reveals a few, but I don't understand how it ends up on my device unless there's some fallback scheme for finding it.

Quick question about this detail:

This is still on the persistent flash, right? Not in RAM?

I think this is how config gets placed in the NAND flash based mt7622

Thanks for finding that! I was still looking. I just realised it's the MT7628, not the MT7622. (However did I make that mistake.) The former is NOR based, not NAND, so I think it uses the default_do_upgrade() in common.sh (this seems to be what the scripts in target/mediatek without the subtarget dir suggest?). This has been most illuminating, thank you.

The logic goes:
global base-files added with target base-files + subtarget base-files.

There aren't any target or subtarget files for those targets where the global logic works.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.