1. Firmware update over the air profile
1.1. Overview
The firmware update over the air (FUOTA) service provides the possibility to receive a 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 the new BLE Application in a Free Area – Download slot
- update/download a 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 |
---|
There are 4 regions with fixed size and address, not modified along the firmware update.
- One region (page 0 and 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.
- The Download slot is used only to store the application update to be applied.
- The Keyword_User is used to ensure the firmware update has been fully received.
- The Keyword_User is placed at the end of the binary. It shall be defined with a magic value (0x94448A29) 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. The linker file can be used to ensure the Keyword_User is placed at the end of the binary.
One advantage of this solution is that it does not need any post-script, in addition to the standard build process.
This mechanism only ensures that the expected amount of bytes is written in the flash. It does not protect against data that may not be properly written in the flash.
1.2. Implementation
The firmware update over the air (FUOTA) profile is intended to demonstrate the multiple capabilities of the STM32WBA Bluetooth® LE solution. It acts as:
- GAP Central & GATT Server (Router Service) device to be connected and controlled by an smartphone.
- GAP Peripheral & GATT Client device to control end device (P2P FUOTA Server, HR FUOTA Server).
The FUOTA service is a Generic Attribute Profile (GATT) based on the low-energy profile defined by STMicroelectronics with proprietary UUIDs(128 bits), including three characteristics.
The Heart Rate FUOTA and Peer to Peer FUOTA projects provided within the STM32CubeWBA MCU Package[1] are described below.
Overall application diagram |
---|
The table below describes the structure of the FUOTA service:
Bluetooth® LE FUOTA service specification | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
The FUOTA service is composed of three characteristics:
FUOTA service - Base Address characteristic | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Base Address characteristic, to be used by the smartphone or web bluetooth application to:
|
FUOTA service - Confirmation characteristic | ||||||
---|---|---|---|---|---|---|
Confirmation characteristic, to be used by the smartphone or web bluetooth application to inform about:
|
FUOTA Service - Raw Data characteristic | ||||||
---|---|---|---|---|---|---|
Raw Data characteristic, to be used by the smartphone or web bluetooth application to transfer the file. |
1.3. Implementation example
Example of flow diagram between STM32WBAs & ST BLE Toolbox smartphone application. |
---|
1.4. Advertising data
At start up, application with FUOTA starts fast advertising (80ms/100ms).
Data advertised are composed as follow:
Heart Rate FUOTA Advertising packet | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Manufacturer data are encoded following STMicroelectronics BlueST SDK v2, as described below:
STMicroelectronics Manufacturer Advertising data | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2. Requirements
2.1. Software and system requirements
The following list contains the required software as well as the required minimum IDE version:
- IAR Embedded Workbench for ARM (EWARM) toolchain V9.20.1, plus a patch available in WBA Firmware Package: STM32Cube_FW_WBA_Vx.x.x/Utilities/PC_Software/EWARMv8_STM32WBAx_V1.2.zip
- RealView Microcontroller Development Kit (MDK-ARM) toolchain V5.37, plus a patch available in WBA Firmware package: STM32Cube_FW_WBA_Vx.x.x/Utilities/PC_Software/Keil.STM32WBAx_DFP.1.0.0.zip
- STM32CubeIDE toolchain V1.12.0 [2].
The required programmer software is listed below:
- STM32CubeProgrammer[3] : To flash the board with an already generated binary
2.2. Hardware requirements
NUCLEO-WBA5 [4] is required to install the application.
Hardware platform illustration |
---|
|
2.3. Collector applications compatibility
The STM32CubeWBA FUOTA projects (Heart Rate FUOTA and P2P FUOTA) are compatible with the following remote interfaces:
3. STM32WBA FUOTA example description
3.1. Project directory
The FUOTA Service embedded in the "BLE_HeartRate_ota" and the "BLE_p2pServer_ota" applications and the "Application Install Manager" are available by downloading STM32CubeWBA MCU Package[5].
Refer to How to Build a Bluetooth® LE project wiki page for project directory information.
3.2. Project description
3.2.1. Structure
Software project structure with the most important parts:
Application Install Manager project structure |
---|
Heart Rate FUOTA project structure |
---|
WARNING: Do not modify the files in Middlewares folder |
3.2.2. Applications Role
3.2.2.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.
3.2.2.2. User Application
This is a single binary implementing both the user and the FUOTA application.
The FUOTA application is responsible for downloading the firmware update in the Download slot.
This binary (including both the User and the FUOTA application) can be updated with FUOTA.
3.2.2.3. Flow
FUOTA Flow Diagram between Application Install Manager and FUOTA User Application |
---|
FUOTA Steps |
---|
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 reboots the device to install it.
3.2.3. Application initialization
The different steps of the application initialization are described below:
FUOTA project initialization |
---|
3.2.4. GAP and GATT initialization and interaction
and The Bluetooth LE FUOTA application initialization is done within app_ble.c
- Initialize the BLE stack - initialize the device as peripheral - configure and start advertising: ADV parameters, local name, UUID - APP_BLE_init()
- Call the services controller initialization SVCCTL_Init() - svc_ctl.c
- Manage the GAP event - SVCCTL_App_Notification()
- HCI_LE_CONNECTION_COMPLETE - provides information of the connection interval, slave latency, supervision timeout
- HCI_LE_CONNECTION_UPDATE_COMPLETE- provides the new information of the connection
- HCI_DISCONNECTION_COMPLETE - informs the application about the link disconnection and the reason
The Services management is done by the service controller, svc_ctl.c
- Initialize the number of registered handler - SVCCTL_SvcInit()
- Manage events - SVCCTL_UserEvtRx()- from the BLE Host Stack and redirect them to the gap event handler - SVCCTL_App_Notification
The application level of the FUOTA is done with ota_app.c':
- Initialization of the services:
- FUOTA Service - OTA_Init() - ota.c
- Initialization of the context of the application
- Erase the Download Slot
- Receive notification from the FUOTA Service - OTA_Notification()
The FUOTA Service ota.c manages the specification of the service:
- Service Init - OTA_Init()
- Register FUOTA Event Handle to Service Controller - SVCCTL_RegisterSvcHandler(OTA_EventHandler);
- Initialize Service UUID – add FUOTA as Primary services
- Initialize Base Address characteristic
- Initialize Confirmation characteristic
- Initialize Raw Data characteristic
- Manage the GATT event from BLE Stack - OTA_EventHandler()'
- ACI_GATT_WRITE_PERMIT_REQ_VSEVT_CODE
- Reception of a Write Command: Raw Data Characterictic Value
- Send an aci_gatt_write_response() with an OK or KO status.
- Reception of a Write Command: Raw Data Characterictic Value
- ACI_GATT_ATTRIBUTE_MODIFIED_VSEVT_CODE
- Reception of an attribute modification - Confirmation Characteristics Description Value : ENABLE or DISABLE Indication
- Notify application of the Confirmation Indication - OTA_Notification(OTA_CONF_INDICATE_ENABLED_EVT/OTA_CONF_INDICATE_DISABLED_EVT)
- Reception of an attribute modification - Base Address Characteristics Value
- Notify application of the Base Address Modification- OTA_Notification(OTA_BASE_ADR_WRITE_NO_RESP_EVT)
- Reception of an attribute modification - Raw Data Characteristics Value
- Notify application of the Raw Data Modification- OTA_Notification(OTA_RAW_DATA_WRITE_NO_RESP_EVT)
- Reception of an attribute modification - Confirmation Characteristics Description Value : ENABLE or DISABLE Indication
- ACI_GATT_WRITE_PERMIT_REQ_VSEVT_CODE
FUOTA software module interaction |
---|
4. Collector applications
4.1. Android ST BLE Toolbox
Android ST BLE Toolbox – How to | |||
---|---|---|---|
Android ST BLE Toolbox – How to | |||
---|---|---|---|
4.2. Web Bluetooth
From the Web bluetooth interface Home Page, click on Web Bluetooth WBA to access the dedicated WBA web application.
The documentation for the various ST Web Bluetooth applications is available at this same address.
5. References