Adding DFU over BLE to my application

Hello! I want to know how to properly add secure DFU over BLE to my application. I have an application already working and tested developed in nrf5 sdk 17.1.0 using SES. It has BLE functionality so it uses the Softdevice, now I want to add DFU suppport to it as a last feature and I was trying the examples demonstrated in this tutorial:   nRF5 SDK v17.1.0 Secure DFU Hands-on Tutorial  and it worked wonders, but there are some things I don't really understand and some requirements I want to implement:

1) In the example, the secure bootloader and the application were on separate projects, how do I add bootloader to my current app project? As in, having all of the code in a single project and not having to merge the hex files like the tutorial mentioned, also doing it all in SES and not having to use the nrf connect programmer.

2) What are all the options for entering DFU mode during application runtime, like I want to be able to say press a button or send a command via BLE characteristic and put the device in DFU mode

3) How do I change the settings of the bootloader phase, like the Advertising name, adding a GPIO to exit the DFU in case it was entered unexpectedly/on accident, etc and what other options do I have I'd lke to know

  • "1) In the example, the secure bootloader and the application were on separate projects, how do I add bootloader to my current app project? As in, having all of the code in a single project and not having to merge the hex files like the tutorial mentioned, also doing it all in SES and not having to use the nrf connect programmer."

    I don't think you should do that, the bootloader is responsible for updating the applications and validating the updates and more.

    "2) What are all the options for entering DFU mode during application runtime, like I want to be able to say press a button or send a command via BLE characteristic and put the device in DFU mode."

    There are multiple ways of entering DFU mode, using a Button, Pinreset, GPREGRET registers and Buttonless. See docs

    "3) How do I change the settings of the bootloader phase, like the Advertising name, adding a GPIO to exit the DFU in case it was entered unexpectedly/on accident, etc and what other options do I have I'd lke to know"

    With buttonless DFU Service you can use DFU_OP_SET_ADV_NAME to set the adv name in DFU mode.
    Exiting the DFU mode with a GPIO, could be done with the reset pin, or add a GPIO interrupt in the bootloader code and reset there. I've never had to use a reset button for dfu, only cycling the power.

  • I agree with everything already suggested. In addition, I would like to make you aware of this guide. It is old, but still very relevant for the nRF5 SDK bootloader.

    You say that you want to stay clear of nRF Connect for Desktop -> programmer. I can understand that. I suggest you look unto using nRF Command Line Tools for working with bootloadr. It is a simple command line tool used to program .hex files to the nRF. You can easily script this as well. In addition, I believe you can add "post build commands/scripts" in SES, that can generate the DFU images, sign the application, generate bootloader settings or whatever you like.

    Best regards,

    Edvin

Related