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

dfu+app build process

Hi,

      I am developing an application on an nrf52840 based custom board that includes a dfu bootloader. Currently this bootloader is the example secure one. This will be tweaked to fit our needs over time. From this post: https://devzone.nordicsemi.com/f/nordic-q-a/33879/download-and-debug-application-using-ses-while-bootloader-present, I understand that the process to get a copy of the bootloader and my application onto the soc is:

  1. compile my app
  2. generate the bootloader settings using nrfutil
  3. merge the settings and the bootloader hex using merge hex
  4. flash the result to the soc using nrfprog
  5. compile my app and flash to the soc.

This is fiddly in the standard change, debug, change... development process. I am using SES. Is there a way to configure SES to automate this process?

many thanks in advance

Cheers Paul

  • HI Paul, 

    you can generate the settings page as a 'User Build Step' -> 'Post Build Command' and then automatically load the settings file when debugging, see

    https://devzone.nordicsemi.com/f/nordic-q-a/34212/howto-flash-bootloader-settings-for-dfu-using-ses-at-debug-time

    Best regards
    Bjørn

  • Thanks Bjorn. Some notes on what I have done:

    1) installing nrfutil is non trivial. There is at least one package without a revision dependency: protobuf that required a higher revision than was already installed on my box. The error was: TypeError: __init__() got an unexpected keyword argument 'syntax'. I upgraded from protobuf 2.6 to 3.6 and that fixed it. The install correctly identified that the six package needed upgrading.

    2) installing nrfutil has a dependency on the wheel package that isn't caught. Error: Running setup.py bdist_wheel for nrfutil ... error ... Failed building wheel for nrfutil

    3) I wrote the following bash script to do the fiddling and called it in the post build command: right click on project in the project items pane | options | User build step in left pane and then post-build command.

    #!/bin/bash
    
    BOOTDIR="/home/paulc/dev/2flex_nrf52/bootloader"
    LOADERFILE="secure_bootloader_ble_s140_pca10056.hex"
    LOADERLOC="../sdk/examples/dfu/secure_bootloader/pca10056_ble/ses/Output/Release/Exe/${LOADERFILE}"
    APPLOC="/home/paulc/dev/2flex_nrf52/Output/Debug/Exe/2flex_nrf52.hex"
    SETTINGSFILE="bootloader_setting.hexca"
    FLASHFILE="payload.hex"
    NRFUTIL="/usr/local/bin/nrfutil"
    MERGEHEX="/home/paulc/dev/2flex_nrf52/mergehex/mergehex"
    NRFJPROG="/home/paulc/dev/2flex_nrf52/nrfjprog/nrfjprog"
    
    pushd ${BOOTDIR}
    cp ${LOADERLOC} .
    echo "Generating the bootloader settings"
    ${NRFUTIL} settings generate --family NRF52840 --application ${APPLOC} --application-version 0 --bootloader-version 0 --bl-settings-version 1 ${SETTINGSFILE} --no-backup
    echo "merging with the bootloader"
    ${MERGEHEX} --merge ${LOADERFILE} ${SETTINGSFILE} --output ${FLASHFILE}
    echo "programming the bootloader onto the chip"
    ${NRFJPROG} -f NRF52 --program ${FLASHFILE} --chiperase
    popd
    4)

    Again many thanks

    Paul

  • Hi Paul, 

    Thanks for the feedback regarding nrfutil's dependencies. Will report this internally. 

    Best regards

    Bjørn

  • Just for completeness, there is also a post linker build step that can also be used and may be better in some situations.

Related