Device Firmware Update

Device Firmware Update.


This event indicates that the device booted in DFU mode and is now ready to receive commands related to device firmware upgrade (DFU).
This event indicates that an error, which prevents the device from booting, has occurred in bootloader.


void sl_bt_dfu_reset (uint8_t dfu)
sl_status_t sl_bt_dfu_flash_set_address (uint32_t address)
sl_status_t sl_bt_dfu_flash_upload (size_t data_len, const uint8_t *data)
sl_status_t sl_bt_dfu_flash_upload_finish ()

Detailed Description

Device Firmware Update.

These commands and events are related to controlling firmware updates over the configured host interface and are available only when the device is booted in DFU mode. DFU process:

  1. Boot device to DFU mode with sl_bt_dfu_reset command
  2. Wait for sl_bt_evt_dfu_boot event
  3. Send command sl_bt_dfu_flash_set_address command to start the firmware update
  4. Upload the firmware with sl_bt_dfu_flash_upload commands until all data is uploaded
  5. Send sl_bt_dfu_flash_upload_finish command when all data is uploaded
  6. Finalize DFU firmware update with sl_bt_dfu_reset command

DFU mode is using the UART baudrate set in bootloader.

Function Documentation

◆ sl_bt_dfu_reset()

void sl_bt_dfu_reset ( uint8_t  dfu)

Reset the system. The command does not have a response but it triggers one of the boot events (normal reset or boot to DFU mode) after re-boot.

[in]dfuEnum sl_bt_system_boot_mode_t. Boot mode. Values:
  • sl_bt_system_boot_mode_normal (0x0): Boot to normal mode
  • sl_bt_system_boot_mode_uart_dfu (0x1): Boot to UART DFU mode
  • sl_bt_system_boot_mode_ota_dfu (0x2): Boot to OTA DFU mode


◆ sl_bt_dfu_flash_set_address()

sl_status_t sl_bt_dfu_flash_set_address ( uint32_t  address)

After re-booting the local device in DFU mode, this command defines the starting address on the flash where the new firmware will be written.

[in]addressThe offset in the flash where the new firmware is uploaded to. Always use the value 0x00000000.
SL_STATUS_OK if successful. Error code otherwise.

◆ sl_bt_dfu_flash_upload()

sl_status_t sl_bt_dfu_flash_upload ( size_t  data_len,
const uint8_t *  data 

Upload the whole firmware image file into the Bluetooth device. The passed data length must be a multiple of 4 bytes. Because the BGAPI command payload size is limited, multiple commands need to be issued one after the other until the whole .bin firmware image file is uploaded to the device. After each command, the next address of the flash sector in memory to write to is automatically updated by the bootloader.

[in]data_lenArray length
[in]dataAn array of data which will be written onto the flash.
SL_STATUS_OK if successful. Error code otherwise.

◆ sl_bt_dfu_flash_upload_finish()

sl_status_t sl_bt_dfu_flash_upload_finish ( )

Inform the device that the DFU file is fully uploaded. To return the device back to normal mode, issue the command sl_bt_dfu_reset.

SL_STATUS_OK if successful. Error code otherwise.