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

Understanding DFU, DFU Trigger Library, and crypto keys for DFU

I have an application that I can install and run on the nRF52840 dongle. But to program the dongle, I need to press the reset button and use nRF Connect. So I am looking at how to do that without pressing the reset button. DFU appears to be the key along with the DFU Trigger Library, Somehow I add these to my application and I will be able to program the dongle without pressing any buttons (the dongle may be enclosed in a pretty package that prevents access to the reset button).

Since I know nothing about DFU and how it works, the tutorials have not been much help as they assume a level of knowledge I simply don't have. So I decided to look at the open bootloader example here \examples\dfu\open_bootloader in the SDK. I tried to build it and get the cant use debug public key error. Now it looks like I have to download a slew of applications and this project to generate a public key. I would like to avoid that headache and the need to learn how all those tools work, especially since they are command-line tools. I have plenty of nice GUI tools that can generate public-private key pairs.

If I generate my own keys instead of dealing with the instructions shown here https://github.com/NordicSemiconductor/pc-nrfutil/blob/master/README.md

can I use that public key instead? What do I do with my private key? What are the requirements on these keys?

Any info/tutorials on understanding DFU from the ground up would be appreciated. I apologize for my ignorance. I am not an embedded programmer - my only expertise is Bluetooth in this line of work. Once I get outside of that I am pretty lost!

By the way, how much overhead will this add to my application? It looks like it will be more than the application itself!

Parents
  • Hi,

    Somehow I add these to my application and I will be able to program the dongle without pressing any buttons

    Yes. That is a library for the application that makes it possible to trigger DFU mode via DFU.

    Since I know nothing about DFU and how it works, the tutorials have not been much help as they assume a level of knowledge I simply don't have. So I decided to look at the open bootloader example here \examples\dfu\open_bootloader in the SDK. I tried to build it and get the cant use debug public key error.

    If you just want to experiment to learn, then you can stick with the debug key. The problem with that is that you do not have the corresponding private key, so you can only use example upgrade images from the SDK. To use your own upgrade images, you must use your own key pair.

    Now it looks like I have to download a slew of applications and this project to generate a public key.

    You just need nrfutil. If you have python on your computer you install it easily using pip: "pip install nrfutil". You will anyway need nrfutil to generate upgrade images for the bootloader later (even the open bootloader use signing for the bootloader image itself). Also note that you cannot now update this from nRF Connect programmer, as that is hard coded with the private key that corresponds to the public key used in the bootloader the dongle ships with.

    If I generate my own keys instead of dealing with the instructions shown here https://github.com/NordicSemiconductor/pc-nrfutil/blob/master/README.md

    can I use that public key instead?

    As long as you generate valid key pairs and get it in a pem format for use by nrfutil and a raw key you can use in your bootloader it should work. I expect this will give you more work though, instead of just using nrfutil as instructed. You simply have to copy-paste two commands from the documentation, so there is no learning curve to speak of.

    What do I do with my private key?

    The private key is input to nrfutil to sign upgrade images. As you use the open bootloader it is only needed for bootloader upgrades.

    What are the requirements on these keys?

    It must be a secp256r1 key pair. 

    Any info/tutorials on understanding DFU from the ground up would be appreciated.

     The bootloader documentation in the SDK is quite extensive. There are also some tutorials out there, but hey are high level and typically focus on BLE.

    Note that you often do not need to have deep knowledge of the DFU implementation to use it in your product, as the SDK implementations are quote complete and well tested. You can mostly use them as is.

  • Sorry, but I have gotten no where. I just ditched everything with trying to understand the examples and hoped there would be clear documentation on how to take an existing nRF52840 dongle project and add the trigger library. No such luck. I posted again from that point of view.

  • Hi,

    There are not many exmaples in the SDK that use it, but you can refer to examples\connectivity\ble_connectivity\main.c. There you see it includes nrf_dfu_trigger_usb.h and calls nrf_dfu_trigger_usb_init() when built for pca10059 (nRF52840 dongle). You should also look at the project file under examples\connectivity\ble_connectivity\pca10059\ser_s140_usb_hci\ as well as the sdk_config.h for configuration (search for "TRIGGER").

Reply
  • Hi,

    There are not many exmaples in the SDK that use it, but you can refer to examples\connectivity\ble_connectivity\main.c. There you see it includes nrf_dfu_trigger_usb.h and calls nrf_dfu_trigger_usb_init() when built for pca10059 (nRF52840 dongle). You should also look at the project file under examples\connectivity\ble_connectivity\pca10059\ser_s140_usb_hci\ as well as the sdk_config.h for configuration (search for "TRIGGER").

Children
No Data
Related