nRF5 SDK  v12.2.0
Choose documentation:
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Device Firmware Update process

Two devices are required to perform a Device Firmware Update: the DFU target and the DFU controller. The DFU target is the device that is updated with a new firmware image, which can contain a new application, SoftDevice, bootloader, or a combination of SoftDevice and bootloader. The DFU controller is the device that transfers the image. For example, the DFU controller can be a mobile phone running an app, or an nRF5 Development Kit in conjunction with nrfutil.

The DFU target is the device that runs the DFU bootloader. If the bootloader puts the device in DFU mode, the bootloader expects a Device Firmware Update. The DFU controller can then initiate the transfer of a firmware image, which is received and validated by the DFU bootloader. If the image is valid, the device resets and copies the image to replace the existing firmware. Depending on the type of image, it might replace the application, the SoftDevice, or even the current bootloader that is receiving the update. See Dual-bank and single-bank updates for detailed information about where the image is stored and how it is copied.

As DFU controller, use the nrfutil tool (version 1.5.0 or later) or Nordic's mobile apps. The bootloader modules can be used to implement the DFU target. The following flow chart shows the required steps for a firmware update, which must be implemented in the bootloader of the DFU target:

bootloader_process.svg
Process flow on the DFU target

The events and procedures for the firmware update process are agnostic of the transport protocol that is in use. Therefore, it is possible to perform a firmware update using any transport protocol (see DFU transport). The DFU controller can trigger the events by sending a corresponding message on the DFU transport.

Bootloader settings

The current state of the DFU process is stored in the bootloader settings page, which is located on the last page of the available flash storage (see Memory layout).

The information in the settings page is used to determine the correct action after a reset of the device:

  • If a firmware image has been transferred, it must be validated and copied.
  • If an application is installed, its CRC-32 is stored in the settings page. If the stored CRC-32 corresponds to the actual application, the application must be started. Otherwise, the application has been tampered with, and the device must start in DFU mode.
  • If no application is installed or if there is no settings page, the device must start in DFU mode.

The bootloader settings page can also be used to store information that should be maintained through the update process, for example, firmware version numbers.