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

Flashing bootloader, softdevice and application issue

Hello.
I'm having an issue with nrfjprog that has been discussed in this forum several times but I can't manage to get it working. I'll link some of mentioned posts at the end of this post.

My goal: I'd like to have a powershell script in which I can flash the softdevice, the bootloader and the application. And the device runs the application and doesn't get stuck in the bootloader. I don't mind if to merge all the .hex files into one .hex file as long as it works.

My setup: I have a nrf52832 custom board without any buttons that I'd like to be able to update the application via dfu. I'm using sdk 17.0 (this is working, I followed Getting started with Nordic's Secure DFU bootloader, a step by step guide).
My application is based on the template example and my bootloader is the secure bootloader example.

Things I've tried (besides other devzone posts answers):
1. My first approach was to flash the softdevice, bootloader and application in this order. When I scan using nrfConnect I don't see my device name I just see DfuTarg. Which means the application is not running and it's stuck in the bootloader. Note: When I connect the device to nRFgo Studio I can see that the bootloader, softdevice and application are all flashed into the device but the application is not starting. If using nrfConnect I upload via dfu the same application it runs flawlessly.

2. The most common answer I've found in the forums is that I need to merge the bootloader .hex with a settings .hex. As far as I understood, the first thing I tried didn't work because the CRC checking and this settings .hex for the bootloader will make it work.

I've tried the following piece of code:

nrfutil settings generate --family NRF52 --application application.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 settings.hex

mergehex -m settings.hex bootloader.hex -o bootloader_w_settings.hex

nrfjprog.exe --eraseall
nrfjprog.exe --program bootloader_w_settings.hex --verify 


As far as I know, I need to be using --bl-settings-version 2 because my sdk version is 17.0. And --application-version and --bootloader-version are values for me to increase.

After running the script, verifying says it's ok. Powershell output:

Note: Generating a DFU settings page with backup page included.
This is only required for bootloaders from nRF5 SDK 15.1 and newer.
If you want to skip backup page generation, use --no-backup option.

Generated Bootloader DFU settings .hex file and stored it in: settings.hex

Bootloader DFU Settings:
* File:                     settings.hex
* Family:                   nRF52
* Start Address:            0x0007F000
* CRC:                      0x13EBFE1F
* Settings Version:         0x00000002 (2)
* App Version:              0x00000001 (1)
* Bootloader Version:       0x00000001 (1)
* Bank Layout:              0x00000000
* Current Bank:             0x00000000
* Application Size:         0x00010104 (65796 bytes)
* Application CRC:          0x335A336B
* Bank0 Bank Code:          0x00000001
* Softdevice Size:          0x00000000 (0 bytes)
* Boot Validation CRC:      0x9D257E79
* SD Boot Validation Type:  0x00000000 (0)
* App Boot Validation Type: 0x00000001 (1)

Parsing input hex files.
Merging files.
Storing merged file.
Erasing user available code and UICR flash areas.
Applying system reset.
Parsing hex file.
Reading flash area to program to guarantee it is erased.
Checking that the area to write is not protected.
Programing device.
Verifying programming.
Verified OK.


At this point I use nrfConnect to check if the bootloader is working and I'm unable to find the device. nRFgo Studio says the bootloader is flashed.

How can I make this work and reach my goal?
Is there any extra configuration to the bootloader or application that must be done for this to work?
Thanks.

Some of the devzone posts I've researched and couldn't make it work:
https://devzone.nordicsemi.com/f/nordic-q-a/10135/how-to-program-softdevice-and-firmware-with-new-nrfjprog
https://devzone.nordicsemi.com/f/nordic-q-a/24801/combining-bootloader-softdevice-and-application-in-single-hex
https://devzone.nordicsemi.com/f/nordic-q-a/27006/how-to-flash-the-softdevice-the-bootloader-and-the-application-at-once
https://devzone.nordicsemi.com/f/nordic-q-a/19502/flashing-sd-app-bl-sdk12-2/75758#75758
https://devzone.nordicsemi.com/f/nordic-q-a/46033/nrf51822-prepare-hex-file-for-mass-production-softdevice-application-bootloader-and-start-it-into-the-application
https://devzone.nordicsemi.com/f/nordic-q-a/53693/how-to-flash-application-after-dfu-bootloader
https://devzone.nordicsemi.com/f/nordic-q-a/51265/sdk-15-3-flash-application-does-not-run-after-flash-softdevice-and-bootloader-as-advised-on-devzone-topics
https://devzone.nordicsemi.com/f/nordic-q-a/50482/unable-to-flash-after-adding-bootloader
https://devzone.nordicsemi.com/f/nordic-q-a/58894/unable-to-merge-bootloader-softdevice-and-application
https://devzone.nordicsemi.com/f/nordic-q-a/57523/flash-the-softdevice-the-bootloader-bootloader-settings-and-the-application-at-once

Related