STM32WB Bluetooth® LE – fast firmware update over the air (FUOTA)

1. STM32WB - fast firmware update over the air (FUOTA)

This section gives a description on how to improve the data throughput while updating the STM32WB application or wireless stack thanks to the wireless STM32WB Bluetooth® LE protocol. The application note listed below describes the current implementation of BLE_Ota application:

  • AN5247 Over-the-air application and wireless firmware update for STM32WB Series microcontrollers

The BLE_Ota application is available by downloading STM32CubeWB[1] release

Project BLE_Ota - P-NUCLEO-WB55.Nucleo
Connectivity BLE OTa project structure.png

1.1. Limitation with current implementation

  • The OTA RAW data characteristic is limited to 20 bytes.
  • Thus, transmitted ATT packet data length is limited.

The following figure is an air capture of the OTA RAW data characteristic sent by the Android smartphone application ST BLE Sensor.

ATT Write - 20 bytes
Connectivity OTA Raw data characteristic - 20 bytes.png

1.2. How to increase the data throughput

  • By increasing the size of the OTA RAW data characteristic to 248, this is done with CubeWB 1.12.0 release.
//otas_stm.h
#define OTAS_STM_RAW_DATA_SIZE    (248)    
//otas_stm.c                                           
#define OTA_RAW_DATA_CHAR_SIZE    OTAS_STM_RAW_DATA_SIZE     

 /**
   *  Add Raw Data Characteristic
   */
  aci_gatt_add_char(OTAS_Context.OTAS_SvcHdle,
                    OTA_UUID_LENGTH,
                    (Char_UUID_t *)OTA_RAW_DATA_CHAR_UUID,
                    OTA_RAW_DATA_CHAR_SIZE,
                    CHAR_PROP_WRITE_WITHOUT_RESP,
                    ATTR_PERMISSION_NONE,
                    GATT_NOTIFY_ATTRIBUTE_WRITE | GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP,
                    10,
                    1,
                    &(OTAS_Context.OTAS_Raw_Data_CharHdle));
  • By increasing the size of ATT maximum transmission unit (MTU) which is the maximum length of an ATT packet.
//app_conf.h
/**
 * Maximum supported ATT_MTU size
 * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1"
 */
#define CFG_BLE_MAX_ATT_MTU             (251)
  • By managing with GATT client remote application the negotiation of the ATT MTU to increase the data payload for the transmitted packets.
ATT MTU Exchange
Connectivity ATT MTU Exchange.png

1.3. GATT client - Android - ST BLE sensor v4.12.0

The Android ST BLE Sensor application version v4.12.0 is available on Google Play[2]

This version supports the fast FUOTA by requesting the maximum ATT MTU and by maximizing the payload of the OTA RAW data characteristic.

ST BLE Sensor fast FUOTA procedure
Connectivity ST BLE Sensor 4.12.0 fast OTA.png

Most Android smartphone request a connection interval around 45 ms which is enough for the Bluetooth® LE OTA application to receive the packets and write the data to the flash.

Fast FUOTA connection interval - Ellisys Air Trace
Connectivity Fast OTA Connection Interval and Frames.png

The packet size is maximized to 248 bytes for the ATT packet OTA RAW characteristics.

Fast FUOTA ATT Packet - Ellisys Air Trace
Connectivity Fast OTA Frame.png

Therefore, few seconds are necessary to update the P2P server application (32.1KB).

Fast FUOTA file transfer - Ellisys Air Trace
Connectivity Fast OTA file transfer.png

1.4. References