This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

HOWTO: Flash bootloader settings for DFU using SES at debug time

Hi All,

Posting this here after a lot of searching and troubleshooting. There have been a lot of similar posts but none actually seems to go into how to implement this in a friction-free way.

This is a guide for allowing the *automatic* JLink debugging of applications within Segger Embedded Studio when a DFU bootloader is installed on the device. In my case, this is based around an NRF52840 (custom PCB with SWD breakout), BLE DFU (Buttonless), SDK 15, S140 6.0.0 SoftDevice and using the following examples:

- Application: examples\ble_peripheral\ble_app_buttonless_dfu

- Bootloader: examples\dfu\secure_bootloader

Now, first recommendation is to go through the manual installation process outlined here: https://devzone.nordicsemi.com/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader to familiarise yourself with the setup but basically:

1. Flash the SoftDevice

2. Build the bootloader and flash to the NRF52 using SES (the example project file provided by Nordic should work out of the box)

3. Install nRF Connect on a smartphone

4. Connect to the Dfutag (or whatever it's called..) device

5. Copy the ble_app_buttonless_dfu_without_bonds_s140.zip file from examples\dfu\secure_dfu_test_images\ble\nrf52840 to your phone

6. User nRF Connect to flash that to the device

7. You should have a new device showing up in scans called "Nordic_Buttonless" - victory! You should also see the DFU service listed on this device to allow you to upload different images

Now, if you're anything like me and absolutely hopeless without a debug console and would like to be able to upload new versions of the app and attach to them from within SES without needing to copy the images using a phone and Bluetooth. The process to get this working (after at least following steps 1 and 2 of the previous process) is:

1. Install Python version 2.7 (3.x doesn't work with nrfutil) ensuring you set it to add itself to your path (not required but I'm not going to go into finding paths in this guide - too much hassle)

2. Open a command prompt and run 'pip install nrfutil' 

3. Ensure nrfutil runs and get its install path by using 'where nrfutil'. You should get back something like: 'C:\Python27\Scripts\nrfutil.exe'

4. Open the application project in Segger Embedded Studio (again, we're using the ble_app_buttonless_dfu example - YMMV with other projects)

5. Right click on Project 'ble_app_buttonless_dfu........' -> 'Edit Options'

6. Under 'User Build Step' -> 'Post Build Command' add the following line:

  C:\Python27\Scripts\nrfutil.exe settings generate --family NRF52840 --application $(ProjectDir)\Output\$(Configuration)\Exe\$(ProjectName).hex  --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex

7. Under 'Debug' -> 'Loader' set Additional Load File[1] to:

  settings.hex

8. Build and debug the project and marvel at the main breakpoint being hit!

This is a really rough guide and there are probably a lot of mistakes in there but hopefully it'll help set someone on the path to getting their own case up and running.

Parents
  • example I've tried to use had SoftDevice as "Additional Load File[0]" which was overwriting custom bootloader, but that gave me an idea how to make it finally work. From secure DFU example, flash components are supposed to be flashed in following order:
      1. SoftDevice

      2. Secure bootloader

      3. Application

    With"Additional Load File[0]" pointed to SoftDevice, pointing 'Additional Load File[1]' to custom bootloader hex file and 'Additional Load File[2]' to settings.hex, made sure that custom bootloader is in place and debugging session goes as expected.

Reply
  • example I've tried to use had SoftDevice as "Additional Load File[0]" which was overwriting custom bootloader, but that gave me an idea how to make it finally work. From secure DFU example, flash components are supposed to be flashed in following order:
      1. SoftDevice

      2. Secure bootloader

      3. Application

    With"Additional Load File[0]" pointed to SoftDevice, pointing 'Additional Load File[1]' to custom bootloader hex file and 'Additional Load File[2]' to settings.hex, made sure that custom bootloader is in place and debugging session goes as expected.

Children
No Data
Related