Skip to main content
The Thistle Update Client fully supports A/B full filesystem updates. We abstracted the interaction with different bootloader through 2 simple scripts - one is used to tell the bootloader to attempt a boot on the newly updated partition, and another one to confirm that the boot was successful (latch-in update).

Update Client Integration

In order for the Update Client to integrate with the full filesystem update, it is required to configure the two partitions that will be used in the context of A/B update. In addition, 2 scripts are needed. One script will be used to switch the root filesystem partition to the newly updated one upon reboot. The other script will be used to lock-in the update once the device has booted successfully.
{
  ...
  "part_a": "/dev/mmcblk0p2",
  "part_b": "/dev/mmcblk0p3",
  "switch_part_command": "/opt/switch-part-update.sh",
  "lock_part_command": "/opt/lock-update.sh",
}

Raspberry Pi Example

The Raspberry Pi bootloader supports A/B updates through the use of the “try_cmdline” parameter in the kernel command line. Here is an example of the 2 scripts used to integrate with the Raspberry Pi bootloader. Note that these two scripts need to be executable. This first script switches the root filesystem partition to the other one once the update is applied. It also reboots the device to apply the change.
#!/bin/bash
TARGET_PART=$1
cd /boot/firmware

# amend cmdline to switch root partition
sudo cp cmdline.txt try_cmdline.txt
sudo sed -i "s|root=[^ ]*|root=${TARGET_PART}|" try_cmdline.txt

# set set try_cmdline in tryboot.txt config
sudo cp config.txt tryboot.txt
if grep -q "^cmdline=" tryboot.txt; then
  sudo sed -i 's/^cmdline=.*/cmdline=try_cmdline.txt/' tryboot.txt
else
  echo "cmdline=try_cmdline.txt" >> tryboot.txt
fi

sudo reboot "0 tryboot"
The second script confirms that the boot was successful by copying back the original command line file.
#!/bin/bash
cd /boot/firmware
sudo rm tryboot.txt
sudo cp try_cmdline.txt cmdline.txt
exit 0
These scripts are all it takes to integrate the Thistle Update Client with the Raspberry Pi bootloader for A/B full filesystem updates!

Need Help?

If you need assistance with bootloader integration or have questions about your specific setup, please don’t hesitate to reach out in our discord channel - we would be more than happy to hear about your bootloader setup and help with integration!