No problem!
So it looks like a bootcount may be possible (limited to two bits). I would think this would be sufficient since the mender default is a bootlimit of 1.
They’re asking for an overview of how this would all work and what would be required to be added. I’ve outlined it to the best of my ability below and would appreciate any feedback you could give. I tried to make the flag names as generic as possible (ideally most of this could be used for users who just want a recovery partition to boot after bootlimit
number of failed boots).
The root partition, kernel, etc. would be selected via the recently added os_prefix
flag. Two folders would hold the necessary files for each root fs (the root partition being specified in the respective cmdline.txt files).
A 2-bit bootcount
would be added to wherever it lives and a method to read and reset it from user-space would be created.
Three new optional flags would be added to config.txt: upgrade_available
, bootlimit
and recovery_os_prefix
. (This is for the simplest and most generic setup.)
The os_prefix
and recovery_os_prefix
flags in config.txt would be managed from user-space by the mender client. bootlimit
would be set to 1.
During boot, the firmware would check bootcount
, bootlimit
and upgrade_available
to select the proper os_prefix
. (Please forgive the horrible psuedo code and formatting…)
if(bootcount<bootlimit && upgrade_available==0)
_ //Normal boot
_ boot();
elseif(bootcount<bootlimit && upgrade_available==1)
_ //Upgrade is pending, boot to it
_ os_prefix=recovery_os_prefix;
_ boot();
elseif(bootcount>=bootlimit && upgrade_available==1)
_ //Upgrade failed, boot normal os
_ boot();
elseif(bootcount>=bootlimit && upgrade_available==0)
_ //Normal boot failed, fall back to recovery
_ os_prefix=recovery_os_prefix;
_ boot();
Once the OS has booted, Mender would check bootcount
and upgrade_available
and act accordingly. If the boot was a success, bootcount
is set to 0. If this is the first successful boot after an update, clear upgrade_available
and swap os_prefix
and recovery_os_prefix
. If the boot is a failure, don’t change anything and reboot.
I think that about covers it, but it’s been a long day and I’m sure I missed something along the way. If you can sum this more elegantly, please feel free. Thanks for taking the time to look this over!