Link Search Menu Expand Document

Custom Bootloader Integration

This is the most lightweight bootloader integration we support, as it only requires switch_part_command script to fully enable the Thistle Update Client on your platform. This script is required to instruct the bootloader to boot the “other” partition upon the next reboot cycle. Let’s have a look at a real life example.

Example

The device we want to integrate in this case is a WiFi router, running an existing bootloader (uboot). It is not desired to replace the current bootloader setup, as it is already in place and it can support the functionalities required by the Thistle Update Client.

To integrate with this platform the switch_part_command script is required. Here it only represents a single line of bash, to instruct the bootloader to boot partition 1 or 2 depending on what is currently used.

$ cat switch_part_command.sh
(fw_printenv -n boot_part | grep -q 1) && fw_setenv boot_part 2 || fw_setenv boot_part 1

We then put the device-path of this script in the configuration, and this platform is now fully usable with the Thistle Update Client !

$ cat config.json
{
    ...
    "bootloader": "Custom",
    "part_a": "/dev/mtdblock11",
    "part_b": "/dev/mtdblock13",
    "switch_part_command": "/root/determine_boot_part_script.sh"
}

Note: it is recommended to check the bootloader settings to ensure that it will fallback after repeated failed boot sequences.