Fast Updates of User Code on nrf51822 with bluz

Bluetooth LE is not a fast wireless protocol, transfer speeds are usually measured in single-digit to low tens of kilobytes per second. This is generally not an issue unless large amounts of data need to be sent over the link, which is usually not the case for most applications. However, when Over the Air updates are done, this can lead to large files being sent down, which can lead to long wait times for new code to be loaded.

Bluz, an open source development kit for the nrf51822, elminates the need for downloading the entire firmware file every time by splitting the firmware into multiple pieces, mainly the system firmware and the user app. The system firmware contains all the management of the BLE system, peripherals, and system components. In the case of bluz, this is then exposed to the user app through the Wiring API, the same language and API that Arduino uses.

The system firmware, which is largely static and only updated a few times a year, is stored in a separate section of flash from the user app. The user app is much smaller as it only contains the code required for the specific application, and is dynamically linked to the system firmware at runtime. Any of the individual sections of the firmware, from the bootloader to the user app, can be updated independently of eachother.

image description

A dependency mechanism is used to ensure the system firmware and user apps remain in sync. After the bootloader checks the system, it hands off control to the system firmware which inspects the dependencies of the user app. If they are a match, the system boots normally and the user app runs. If they are not a match, the user app will not be run and the system enters Safe Mode. This allows the system to function as normal, and it can receive new user apps or system firmware images until the dependency issues are resolved.

This architecture allows the user app to stay very small in size, as low as only a few kilobytes large. OTA updates of the user app on bluz can therefore be done in seconds, allowing users to quickly iterate, test, and use the product. When working with central devices other than smartphones, where there may be restrictions on connection interval timing or number of packets per connection interval that can lead to even lower throughput rates, this can lead to significant time savings when updating only the user application portion of the code.

As bluz is fully open source, this stack and architecture can be adapted to any board running the nrf51822. For more information, you can visit the bluz website.