Using the nrf52 secure bootloader is a bit tricky. here is a set of directions to using the secure dfu bootloader.
1- git clone, or unzip this to nRF_SDK external folder
2- Run make in nRF5_SDK\external\micro-ecc\nrf52_armgcc\armgcc
3- install nrfutil
Installation instructions for linux:
pip install nrfutil
4- build the bootloader
nrfutil keys generate private.pem
nrfutil keys display --key pk --format code private.pem --out_file dfu_public_key.c
cd to nRF5_SDK\examples\dfu\bootloader_secure\pca10040\armgcc
-bootloader should be flashed in the device. On the nrf52 Development Kit LED1 and LED3 are on when the development kit is in DFU mode.
5- Now to flash your application you need to make a signed zip of your application firmware,
6- Flash the Application using the Nordic App:
-Move the app_dfu_package.zip file to your phone. (Make sure it is downloaded to your phone. The
Nordic app wont work if you are pulling the .zip package from a hosting application like Google Drive
-Download either nRF Connect or nRF Toolbox. (I prefer the Toolbox app because it has other useful
applications compiled in one app).
-Select DFU, select target device and select the .zip package. Flash the code.
6A- Or you can flash it from your computer using nrfutil via
How to merge your application with the bootloader so you can flash both the application and the bootloader at the same time over jtag, without having to program over the dfu.
1. create and view the settings.hex file.
2. combine the softdevice with the bootloader
3. add the application to it
4. Add the settings file to the Softdevice/bootloader/application hex
5. Flash your code.