nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Application IoT DFU

The Application IoT DFU exposes a common API for the following tasks:

  • transfering the new firmware to flash memory using IoT File
  • validating the configuration as well as checksum for each block of the firmware
  • triggering a swap procedure by entering the bootloader context

Currently the following operations are allowed:

  • application update
  • application with SoftDevice update
  • bootloader update

Creating the firmware packages is described in Create DFU images.

Creating a merged binary of the application and SoftDevice has to be in the correct order. The SoftDevice must be first and then the application with word size alignment between.

Initialization

Application initialization of the IoT DFU requires a call to the iot_dfu_init function with a parameter for the application callback.

Through this callback, the user is notified of either an error in the IoT DFU procedure or success (if writing to the flash went well). The second event has been created to allow data flow control in the upper layers (such as TFTP) and waits for the flash operation to finish.

Note
The IoT DFU module does not hold any state, meaning the application must ensure that only one firmware is written concurrently.

Writing the new firmware

The IoT DFU module uses IoT File to perform a write operation to flash memory. The module is the owner of the correct file abstraction and the application may request a handle for it by calling the iot_dfu_file_create function.

The sequence chart below presents an example of writing new firmware to the flash memory.

msc_iot_dfu_write
Figure 1. Write procedure

Validation

After the new firmware is written to flash memory, a validation procedure might be called. It includes two verification actions:

  • Validates that the correct firmware parts are included (for example, it checks if the SoftDevice was written with the application).
  • Validates the checksum of each firmware block.

The information about the downloaded firmware has to be passed using the Firmware Description structure.

Applying the new firmware

The last operation of Application IoT DFU is to apply the correct settings for the bootloader and perform a software reset after which the bootloader context will swap firmware according to the given settings.

The sequence chart below presents the last operation of IoT DFU that involves validation and applying the new image.

msc_iot_dfu_apply
Figure 2. Apply procedure