STM32WBA Bluetooth® LE – Firmware Update Over The Air

Revision as of 11:08, 9 February 2023 by Registered User

1. Introduction

The Firmware Update Over The Air (FUOTA) is a GATT service used to upgrade a new application while the current one is running.
​ It acts as a GATT Server to be controlled by a GATT Client remote device.​
It is always coupled with a User Application and a dedicated Install Manager Application.

STM32WBA FUOTA


2. Overview

The Firmware Update Over The Air service provides the possibility to receive new application to be installed while the current application is running.
It requires to add the FUOTA Service & Characteristics to the current application.
​ The FUOTA Application allows to:​

  • Download new BLE Application in a Free Area – Download slot​
  • Update/Download new User Configuration file​
  • Jump to the Application Install Manager​

The Application Install Manager allows to:​

  • Replace the BLE Application to be used after reboot​
  • Download user data in any place in the CM33 user flash​

GATT Server memory mapping example:

STM32WBA FUOTA Application Memory Mapping


3. GATT Server Memory mapping description

For the follwing GATT Server memory mapping example:

STM32WBA FUOTA Application Memory Mapping

There are 4 regions with fixed size and address, not modified along firmware update:​

  • One region (page 0 to page 1) that contains the Application Install Manager. This region shall be at the boot address of the CPU out of power on. The Application Install Manager is a full binary with its own vector table.​
  • One region that contains the NVM and User Configuration Data. The address is fixed and can be placed anywhere in the mapping. It is possible to split the NVM from the User Data into several regions at different location in the memory.​
  • 1 Active Slot (from page 2) and 1 Download Slot. They have same size and are placed anywhere in the memory. The Active slot contains the Application (User + OTA) binary whereas the Download slot is used only to store the application update to be applied.​

4. FUOTA Server - Services Structure

FUOTA Server is exported as a Service​ with the following Characteristics with 128 bits UUID:

  • Base Address characteristic:
    ​Used by the Client Application to:
    • Provide Address to store the new application​, an 8K bytes page offset
    • Inform which sectors to erase​
    • Inform the start of the Data Raw transfer (File)​
    • Inform the End of the File Transfer ​
  • Confirmation Characteristic:​
    Used by the Server Application to inform Client device:​
    • it is ready to receive the new binary application​
    • New file is fully received.​
  • Raw Data Characteristic:​
    Used by the Client Application for the File transfer


5. Applications Role

5.1. Application Install Manager

It is responsible to install the firmware update from the Download Slot to the Active Slot when fully received.
When there is no firmware update to be installed, it shall jump on the reset vector of the Application. It cannot be updated with FUOTA​.

5.2. User Application

This is a single binary implementing both the user and FUOTA application.
The FUOTA application is responsible to download the firmware update in the Download slot.
This binary (including both the User and FUOTA application) can be updated with FUOTA​.

5.3. NVM and User Data

It contains the NVM and User Data that need to be kept along with firmware update.​
It could be possible to update the User Data section with the FUOTA mechanism.​

5.4. Keyword User

This Keyword_User is used to ensure the firmware update has been fully received.
This Keyword_User is placed at the end of the binary. It shall be defined with a magic value that cannot be found anywhere else in the firmware. A variable containing the address of the Keyword_User is placed just after the vector table at a fixed address. This variable is initialized with the address of the Keyword_User. This address is defined at link time and the linker file can be used to ensure the Keyword_User is placed at the end of the binary.​
The advantage of this solution is that it does not need any post-script in addition to the standard build process. In another hand, it does not protect versus data that are not properly written in the flash. This mechanism only ensures that the expected amount of byte has been written in flash.​

5.5. Flow

900PXpx

Alternatively, it could be possible to run in parallel both the User Service and the OTA Service.
In that case, it is possible to download a new firmware update while the User service keeps running.
Once the firmware download is completed, the application shall reboot the device to install it.​

6. FUOTA Application Service and Characteristics


7. FUOTA Application Characteristics Specification