Simple EFI program allowing for safe OTA updates of Linux images using A/B-split booting.
EFI variable BOOTTOGGLE
is made accessible in Linux through efivarfs
interface, which is then set to "A" or
"B" to boot from an updated image in-place, while allowing fallback for failed updates. An init script is used
to set UPDATEFLAG
and BOOTCOUNT
to zero on successful boot.
Compiles on Linux using EDK. Couldn't get EDK working on macOS.
Boot parititon requires two startup scripts, boot_a.nsh
and boot_b.nsh
, which each boot separate versions
of your boot image.
- if
UPDATEFLAG
== 0:- boot
BOOTTOGGLE
- boot
- if
UPDATEFLAG
== 1:- if
BOOTCOUNT
== 0 (not yet attempted):BOOTCOUNT
= 1- boot
BOOTTOGGLE
- if
BOOTCOUNT
== 1 (boot from new image unsucessful):BOOTTOGGLE
= opposite scriptUPDATEFLAG
= 0BOOTCOUNT
= 0- boot modified
BOOTTOGGLE
- if
-
if
UPDATEFLAG
== 0:- do nothing
-
if
UPDATEFLAG
== 1 (boot must have been successful):UPDATEFLAG
= 0BOOTCOUNT
= 0
-
BOOTTOGGLE
is set during update