[U-Boot] [RFC] cmd: add bootslot command to select/boot slot based on boot counts

Sean Nyekjaer sean at geanix.com
Wed Dec 11 09:16:03 CET 2019



On 13/07/2018 14.34, Martin Hundebøll wrote:
> The existing bootcount feature is targeted systems with a primary, and a
> rescue boot setup, where the number of boot tries to the primary boot is
> tracked. If the number exceeds the limit, the alternative/rescue is
> booted.
> 
> This patch adds support for a more sophisticated setup, where more than
> two boot slots can exist, and the order of slots can be configured.
> 
> The 'bootcommand' command reads the configured slots (and their
> priority/order) from a configured environment variable ("bootslots" by
> default). For each conifgured slot, a remaining boot count is maintained
> in an evnironment variable ("bootcount_<slot>" by default). If the first
> boot slot has positive boot count, it is booted using the slot specific
> boot command ("bootcmd_<slot>" by default). Otherwise the next slot is
> checked.
> 
> An example environment when using the bootslot command with two slots
> ("a" and "b"):
> 
> bootslots=a b
> bootcount_a=3
> bootcount_b=3
> bootcmd_a=setenv bootargs $bootargs root=/dev/mmcblk0p1; booti $loadaddr
> bootcmd_b=setenv bootargs $bootargs root=/dev/mmcblk0p2; booti $loadaddr
> 
> Once linux is booted, it resets the bootcount variable for the booted
> slot using "fw_setenv":
> 
>> fw_setenv bootcount_a 3
> 
> When the non-booted slot is updated, the order is updated by setting the
> bootslots variable with "fw_setenv":
> 
>> fw_setenv bootslots=b a
> 
> Signed-off-by: Martin Hundebøll <martin at geanix.com>
> Tested-by: Sean Nyekjaer <sean.nyekjaer at prevas.dk>

We have used this for the past 1.5 years.
Will you post this as a patch?

/Sean


More information about the U-Boot mailing list