Blog Datasheets Home About me Clients My work Services Contact

G2Labs Grzegorz Grzęda

Over-the-Air (OTA) firmware updates using the nRF52

December 17, 2023

Over-the-Air (OTA) Firmware Updates using the nRF52

Firmware updates are a critical aspect of a connected device’s lifecycle. Over-the-Air (OTA) updates allow you to update the firmware of a device remotely, without requiring physical access. This is especially valuable in scenarios where devices are deployed in the field or in inaccessible locations. In this article, we will explore how to implement OTA firmware updates on the Nordic Semiconductor nRF52 series using the nRF Connect SDK.

nRF Connect SDK and the nRF52 Series

The nRF Connect SDK is an open-source software development kit (SDK) provided by Nordic Semiconductor. It facilitates the development of applications for Nordic’s nRF52 series of Bluetooth Low Energy (BLE) System-on-Chips (SoCs). The nRF52 series is widely used in various IoT applications, making it an ideal platform for OTA firmware updates.

OTA Update Process Overview

Before diving into the implementation details, let’s understand the high-level OTA update process. It typically involves the following key steps:

  1. Image Generation: Generate a firmware image to be transmitted over the air. This image should be compatible with the device’s bootloader.

  2. Transmission: Establish a secure communication channel between the device and the firmware update server. Transmit the firmware image securely over the air.

  3. Verification: Verify the integrity and authenticity of the firmware image using cryptographic techniques.

  4. Reboot and Update: Install the new firmware image on the device. This step often involves a bootloader that is responsible for flashing the new firmware.

Generating an OTA Firmware Image

To facilitate OTA updates, the nRF52 series devices usually utilize a dual-bank memory layout. This layout allows for seamless switching between two firmware banks, enabling safe and reliable firmware updates. The nRF Connect SDK provides tools to generate OTA-compatible firmware images.

Here’s an example of generating an OTA firmware image using the nrfutil command-line utility:

1
nrfutil pkg generate --hw-version <hardware_version> --sd-req <softdevice_requirements> --application <firmware_hex_file> --application-version <firmware_version> <output_zip_file>

In this command, the <hardware_version> should match the hardware version of the target device, <softdevice_requirements> specifies the SoftDevice version required by the firmware, <firmware_hex_file> is the compiled firmware in HEX format, <firmware_version> indicates the firmware version, and <output_zip_file> is the name of the output ZIP file that contains the OTA firmware image.

Establishing a Secure Communication Channel

Securing the communication channel between the device and the firmware update server is of utmost importance. The OTA update process should use secure protocols like TLS and authenticate the server using certificates. Nordic Semiconductor’s nRF Connect SDK provides an example application called mcumgr that demonstrates secure firmware updates.

The mcumgr example application combines the file and fwupd samples in the nRF Connect SDK. It provides a web server that hosts the firmware and allows OTA updates via HTTPS.

Verifying Firmware Image Integrity and Authenticity

To ensure the integrity and authenticity of the firmware image, cryptographic techniques like digital signatures and hash algorithms are commonly used. The nRF Connect SDK provides cryptographic libraries like mbed TLS that facilitate secure OTA updates.

You can create digital signatures for the firmware image and verify them on the device using cryptographic algorithms like ECDSA. Additionally, you can calculate hashes of the received firmware image and compare them against the expected values to detect tampering.

Reboot and Firmware Update

After verifying the integrity and authenticity, the device should install the new firmware image. This step usually involves a bootloader that can flash the new firmware onto the device. Nordic Semiconductor provides a bootloader library, called nRF DFU (Device Firmware Update).

The bootloader library allows for seamless switching between firmware banks during the update process. It provides functions to initiate firmware updates, handle image verification, and install the new firmware.

Conclusion

OTA firmware updates are an essential feature for connected devices, enabling developers to fix bugs, add new features, and improve security without requiring physical access. In this article, we explored the process of implementing OTA firmware updates using the nRF52 series and the nRF Connect SDK.

We covered the image generation process, establishment of a secure communication channel, verification of firmware image integrity and authenticity, and the reboot and firmware update process. By leveraging the tools and examples provided by Nordic Semiconductor, you can implement robust and secure OTA firmware updates for your nRF52-based applications.

Remember to carefully plan and test your OTA update process to ensure a smooth and reliable experience for your users. Happy coding!

Note: The code snippets in this blog post are written in a shell-like syntax and may require adaptation based on your specific toolchain and development environment.


➡️ Introduction to the nRF52 SoftDevice: architecture and concept


⬅️ Developing custom BLE profiles with the nRF52


Go back to Posts.