nRF5 SDK v17.1.0
Buttonless DFU Template Application
This example requires one of the following SoftDevices: S112, S132, S140

Important: Before you run this example, make sure to program the SoftDevice.

Also, make sure to program the BLE Secure DFU Bootloader.

The Buttonless Secure DFU Service Template Application is an example that shows the functionality of running a Buttonless Device Firmware Update using the hardware delivered in the nRF5 Development Kit.

You can configure this template project to either support bonds or not. If the template project is configured to support bonds, the application will exchange bond information with the bootloader, guaranteeing that only bonded devices are allowed to perform DFU operations.

For more information on the Buttonless Secure DFU Service, see Buttonless Secure DFU Service.

Configuration

To enable or disable the support of bonds, modify the configuration parameters in the sdk_config file. For details on editing the SDK configurations, see SDK configuration header file.

sdk_config.h
#ifndef NRF_DFU_BLE_REQUIRES_BONDS
#define NRF_DFU_BLE_REQUIRES_BONDS 1
#endif

You can also use the following config parameters to customize the behavior of your application:

When the application starts, the Buttonless Secure DFU Service is initialized.

Note
This example requires a compatible bootloader to be present (currently, only the secure BLE bootloader). Otherwise, it will hang indefinitely during boot-up.
This application is not power optimized!
The application will stop advertising after 3 minutes and go to System Off mode. Push Button 1 to restart advertising.

nRF52810 limitations:

Due to limited flash size on nRF52810, the following restrictions apply when using this SoC.

Bootloader settings page

The bootloader settings page is required on the device so that it can boot the application. Among other information, this page contains the CRC value and length of the bootable application (if present). This CRC value is calculated on boot-up to verify that a valid application is present.

If there is no bootloader settings page present on the device, the bootloader creates a default version signifying that there is no application available to boot. In such case, the only option for the Secure DFU is to enter DFU mode during boot-up.

Programming a bootloader settings page with information about a bootable application is required for using Secure DFU compiled with bond support. The reason for this is that the Secure DFU bootloader has no functionality to create bonds with a client device and it relies on the main application on the device to do so.

For information on creating a valid bootloader settings page, see Generating bootloader settings.

Setup

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ble_peripheral\ble_app_buttonless_dfu

Testing

Testing is done by using a pre-generated hex file that contains the following

Note
The Debug version of the Secure DFU bootloader is compiled with a signature public key that only works with pre-compiled test-images for doing firmware upgrade bundled with this release.

The hex files available for testing have been compiled with or without bond support.

Note
When devices are bonded, Service Changed indications must be enabled, if available, before starting the DFU process. Otherwise, the client will fail after the update if the new app's GATT database has changed.

Test the Buttonless DFU Template Application with the nRF Toolbox app, which is available on both iOS (App Store) and Android (Google Play). You can also test the application with nRF Connect for Desktop by performing the following steps:

Testing Buttonless Secure DFU with bonds

This procedure assumes you are using nRF52832 but test images are also available for nRF52840. If you are working with nRF52840, make the following changes: substitute 'nrf52832' with 'nrf52840' and 's132' with 's140' in all paths.

  1. Use nrfjprog to program the following precompiled hex file:
    • examples\dfu\secure_dfu_test_images\ble\nrf52832\sd_s132_bootloader_buttonless_with_setting_page_dfu_secure_ble_debug_with_bonds.hex
  2. Reset the board and observe that the BSP_INDICATE_ADVERTISING state is indicated.
  3. Bond to the device using nRF Connect (it is advertising as 'Nordic_Buttonless'). Click the settings button, select "Security Settings", check "Perform bonding", and click "Apply".
  4. Observe that the BSP_INDICATE_CONNECTED state is indicated.
  5. Observe that the Secure DFU service is shown in the connected device. Expand the service and observe that the characteristic named Buttonless Secure DFU with bonds is present.
    buttonless_secure_dfu_with_bonds.png
    Buttonless Secure DFU with bonds
  6. Enable indications on Service Changed characteristic if it exists.
  7. Click the DFU icon to start the Device Firmware Upgrade process. This will open up a window where you can browse to and select a firmware upgrade package to program on the device.
  8. Pick a test image to program to the device, for example examples\dfu\secure_dfu_test_images\ble\nrf52832\softdevice_s132.zip. Click Start DFU.
  9. Observe the progress indication for the Device Firmware Upgrade.
  10. If the firmware upgrade is successful, the Device Firmware Upgrade window will close and the device will disconnect.
  11. Observe that the BSP_INDICATE_ADVERTISING state is indicated.

Testing Buttonless Secure DFU without bonds

  1. Use nrfjprog to program the precompiled hex file:
    • examples\dfu\secure_dfu_test_images\ble\nrf52832\sd_s132_bootloader_buttonless_with_setting_page_dfu_secure_ble_debug_without_bonds.hex
  2. Reset the board and observe that the BSP_INDICATE_ADVERTISING state is indicated.
  3. Connect to the device using nRF Connect (it is advertising as 'Nordic_Buttonless').
  4. Observe that the BSP_INDICATE_CONNECTED state is indicated.
  5. Observe that the Secure DFU service is shown in the connected device. Expand the service and observe that the characteristic named Buttonless Secure DFU without bonds is present.
    buttonless_secure_dfu_without_bonds.png
    Buttonless Secure DFU without bonds
  6. Click the DFU icon to start the Device Firmware Upgrade process. This will open up a window where you can browse to and select a firmware upgrade package to program on the device.
  7. Pick a test image to program to the device, for example examples\dfu\secure_dfu_test_images\ble\nrf52832\softdevice_s132.zip. Click Start DFU.
  8. Observe the progress indication for the Device Firmware Upgrade.
  9. If the firmware upgrade is successful, the Device Firmware Upgrade window will close and the device will disconnect.
  10. Observe that the BSP_INDICATE_ADVERTISING state is indicated.

Documentation feedback | Developer Zone | Subscribe | Updated