Thistle Uboot
The Thistle-Uboot is a customized uboot script designed to help you getting started with uboot A/B tested boot on your platform. This is recommended if no bootloader is present on your system, and if you know uboot is usable on your platform.
Definition
The proposed boot routine runs a uboot script at boot time, and counts the amount of time a partition has been attempted. This boot-related information is then stored on the first partition detected by uboot (typically a boot partition).
Here is an extract of the main function executed by the thistle-uboot boot script. The full source of the script is also available. We can see that targeted partition is attempted 3 times before falling back to the default partition.
# switch boot cmd if boot count exceeds limit
if itest.b *${boot_counter} -ge 3; then
echo "! boot limit exceeded, fallback"
# swap boot dest
if itest.b *${booting} -eq 0x0a; then
mw.b ${booting} 0x0b
else
mw.b ${booting} 0x0a
fi
mw.b ${dirty_boot} 0x0f
fi
Implementation
The Thistle-Uboot script requires to have a uboot-compliant system, and two equally-sized partitions available for installing the coming rootfs updates. A boot partition is also required to store the information related to the boot sequence.
If your system is using a simple partition table with a FAT32 boot partition and two subsequent root partitions, you can use the precompiled scripts provided below. Note that these scripts are platform and boot-partition filesystem dependent.
If your partition table is different, integration work is probably required around our boot script, so that you specify your boot commands as well as kernel parameters, etc…
Once modifications are performed, uboot requires that bootscripts are compiled with their mkimage
tool.
$ mkimage -A arm64 -O linux -T script -d src/template/uboot-dualboot.scr
The bootscript should then be reachable by uboot, typically by putting it in the boot partition with the name boot.scr
.
Interaction with the update client
Once executed, the bootscript will create a file on the boot partition to keep count of the booted partitions.
The Thistle Update Client when configured with Thistle-Uboot
as a bootloader will then be able to operate on this file to control the behavior of the bootloader. This file will also be used to trigger boot-partition swap upon rootfs updates.