Secure OTA DFU#
This page shows how to securely upgrade Bluetooth application OTA (over-the-air) using signed+encrypted upgrade files. The process is tested with Bluetooth SDK v3.2.2.
The Gecko Bootloader is a common bootloader for all Silicon Labs protocol stacks. It can load applications from different sources (internal flash, external flash, UART, SPI, over-the-air) using different protocols (XMODEM, BGAPI, EZSP SPI, Bluetooth, and so on.). It can be configured in a number of ways and its capabilities depend on the current configuration. This document shows how you can use it for loading a new application into the device sent over a Bluetooth connection.
The Gecko Bootloader has three security features:
Authenticated (signed) upgrade file
Encrypted upgrade file
Upgrade files are in a custom GBL (Gecko Bootloader) format. An authenticated upgrade file means that an electronic signature is attached to the GBL file. The signature is produced with a public-private key pair. The public key is stored in the device, while the private key is kept secret by the manufacturer. The signature ensures that the upgrade file is from a trusted source.
An encrypted upgrade file means that the content of the GBL file is encrypted to protect against eavesdroppers.
Secure Boot means that a signature is attached to the firmware image (.s37) before it is packed into upgrade file formal (.gbl). Note that this differs from an authenticated upgrade file, as authenticated upgrade file means that a signature is attached to the upgrade file after the image was packed into GBL format. A signed image file (secure boot) ensures that the image was not modified since last boot and that it is from a trusted source. This is checked at every boot. Upgrade file authentication is only checked while upgrading.
The following content shows how to use these security features.
Over-The-Air Device Firmware Upgrade (OTA DFU) means that the device firmware can be updated via a Bluetooth connection.
To enable Bluetooth OTA update, the target device must be programmed with an appropriate Gecko Bootloader configuration and additionally with any Bluetooth application that supports OTA.
A Bluetooth application developed with Silicon Labs Bluetooth SDK comprises two parts.
Since Bluetooth SDK v2.7 the two parts are as follows:
The Apploader (provided as precompiled binary code), referred to as Apploader from now on.
The Bluetooth stack (provided as precompiled library) + user application, referred to as Application from now on.
The OTA functionality is built into the Apploader code. If the device is restarted in DFU mode, the Apploader is started instead of the user application. This makes it possible to perform OTA update without any involvement from the user application.
The only requirement for the user application is for a way to trigger a reboot into DFU mode. Reboot into DFU mode can be triggered in a variety of ways. It is up to the application developer to decide which is most applicable. Most of the example applications provided in the Bluetooth SDK already have OTA support built into the code (using the OTA DFU software component). In these examples, the DFU mode is triggered through the Silicon Labs OTA service that is included as part of the application’s GATT database (contributed by the OTA DFU software component). To restart the device in OTA mode, the following API is used:
sl_bt_system_reset(2) is used.
The following processes are OTA DFU:
Partial OTA: In this case, only the user application is upgraded. This process is done in two steps as follows:
The device is restarted in OTA mode, and the Apploader is started.
The Apploader overwrites the old Application code with the new one.
Full OTA: In this case, the Apploader code and application are upgraded. Because the running code cannot overwrite itself, this process is done in four steps as follows:
The device is restarted in OTA mode and the Apploader is started.
The new Apploader code is uploaded into Slot0. This process is handled by the Apploader. Note that on 256 kB devices, Slot0 is in the user application area, which means that the Application is overwritten.
On reset, the bootloader copies the new Apploader code over the old one (extracting the binary from the stored GBL files).
The new Apploader overwrites the old Application code with the new one.
For more details regarding OTA DFU using the Apploader, see AN1086: Using the Gecko Bootloader with the Silicon Labs Bluetooth® Applications.
Create and Build the Bootloader#
Create the Bootloader Project#
Gecko Bootloader is included in the Gecko SDK Suite. A number of predefined configurations are available to help customers easily create new Bootloader projects for different purposes. Different bootloader configurations are recommended for different devices:
For 256 kB devices, use Bluetooth in-place OTA DFU Bootloader configuration.
For 512 kB devices, use Internal Storage Bootloader (single image on 512kB device).
For 1024 kB devices, use Internal Storage Bootloader (single image on 1MB device).
You can also use an SPI Flash Storage Bootloader (single image) if you have an SPI flash connected to the device. However, in this case it is better to implement an application level OTA DFU, see Uploading Firmware Images Using OTA DFU.
To create a new bootloader project:
Open Simplicity Studio and select your device in the Devices or Debug Adapters tab.
Check the Preferred SDK under General Information in the OVERVIEW tab.
Click EXAMPLE PROJECTS & DEMOS tab, and select Bootloader under Technology Type section.
Select the appropriate Gecko Bootloader application type for your device (e.g., Internal Storage Bootloader), click FINISH.
Add Security Features#
After the bootloader project is created, the Application Builder automatically opens up. To add security features, do the following:
Open the Plugins tab.
Click on Bootloader Core.
On the right side tick the checkboxes:
Require signed firmware upgrade files.
Require encrypted firmware upgrade files.
Enable secure boot.
Click Generate in the upper right corner.