How to add standard bootloader and softdevice to custom project

Hi,

Using Windows 10 and SES

SEGGER Embedded Studio for ARM
Release 6.34a Build 2022083102.51023
Windows x64

Copyright 2014-2022 SEGGER Microcontroller GmbH
Copyright 1997-2022 Rowley Associates Ltd.

segger-as: version 2.11
segger-cc: version 14.2.1
segger-cc-ng: version 14.92.0
segger-ld: version 4.34.2
segger-rtl: version 4.18.0

GCC/BINUTILS: built using the GNU ARM Embedded Toolchain version 11.2-2022.02 source distribution

Clang/LLVM: built using the version 14.0.6 source distribution

Trying to run one of the Acconneer samples I get the errors below: 

service_handle = acc_service_create(envelope_configuration); returns a NULL handle, all up to this point looked fine...

The errors in the debug window shows:

"<error> app: sensor_protocol:Timeout waiting for event on sensor 1
<error> app: cpd_cbank_and_vana_calibration:Failed to get result for vana setting=0
<error> app: cpd_cbank_and_vana_calibration:Get Vana result failed
<error> app: sensor_manager:Calibration failure for sensor 1
<info> app: Could not create envelope service"

Segger Compiler

nRF5_SDK_15.3.0_59ac345

nRF52840DK as Debugger connected with 10pin cable to the XB122. 

The actual code preceding the error was:

acc_service_configuration_t envelope_configuration = acc_service_envelope_configuration_create();

if (envelope_configuration == NULL)
{
printf("Could not create envelope configuration\n");
success = false;
}

if (success)
{
acc_service_requested_start_set(envelope_configuration, range_start_m);
acc_service_requested_length_set(envelope_configuration, range_length_m);
acc_service_power_save_mode_set(envelope_configuration, SELECTED_POWER_SAVE_MODE);
acc_service_profile_set(envelope_configuration, SELECTED_SERVICE_PROILE);
acc_service_hw_accelerated_average_samples_set(envelope_configuration, HWAAS);
acc_service_envelope_downsampling_factor_set(envelope_configuration, DOWNSAMPLING_FACTOR);

service_handle = acc_service_create(envelope_configuration);

Now service_handle == NULL; with above errors thrown from the inner libraries.

After lots of up and down with Acconneer we are convinced something is going wrong with how the deployment package is built.  Looking at samples and reading documentation my attempt ended up as:

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

mergehex -m acc_bluetooth_beacon.hex settings.hex -o merged.hex

mergehex -m merged.hex s140_nrf52_6.1.1_softdevice.hex -o merged_output.hex

nrfutil pkg generate --hw-version 52 --application-version 1 --application merged_output.hex --sd-req 0xB6 --sd-id 0xB6 app_dfu_package.zip

output for all this looks like:

"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: 0xB5FA4D7C
* Settings Version: 0x00000001 (1)
* App Version: 0x00000001 (1)
* Bootloader Version: 0x00000002 (2)
* Bank Layout: 0x00000000
* Current Bank: 0x00000000
* Application Size: 0x00017358 (95064 bytes)
* Application CRC: 0x27AD3A4B
* Bank0 Bank Code: 0x00000001
* Softdevice Size: 0x00000000 (0 bytes)
* Boot Validation CRC: 0x00000000
* SD Boot Validation Type: 0x00000000 (0)
* App Boot Validation Type: 0x00000000 (0)

Parsing input files.
Merging file "acc_bluetooth_beacon.hex" into output.
Merging file "settings.hex" into output.
Storing merged file.
Parsing input files.
Merging file "merged.hex" into output.
Merging file "s140_nrf52_6.1.1_softdevice.hex" into output.
Storing merged file.

|===============================================================|
|## ## ### ######## ## ## #### ## ## ###### |
|## ## ## ## ## ## ## ### ## ## ### ## ## ## |
|## ## ## ## ## ## ## #### ## ## #### ## ## |
|## ## ## ## ## ######## ## ## ## ## ## ## ## ## ####|
|## ## ## ######### ## ## ## #### ## ## #### ## ## |
|## ## ## ## ## ## ## ## ### ## ## ### ## ## |
| ### ### ## ## ## ## ## ## #### ## ## ###### |
|===============================================================|
|You are not providing a signature key, which means the DFU |
|files will not be signed, and are vulnerable to tampering. |
|This is only compatible with a signature-less bootloader and is|
|not suitable for production environments. |
|===============================================================|

Zip created at app_dfu_package.zip"

So all seems successful, yet when I run the App, the device does not show up as available BLE.  If I connect the debugger it is seen to fail as showed above.  I know something is wrong with deployment as once this has been deployed I cannot see the device anymore via BLE to DFU again via Android.  I must now reset to factory before I can try again.

Can someone please assist with how to correctly package and deploy bootloader + softdevice + App

Thanks

Cheers

Andreas

  • Hi, 

    After lots of up and down with Acconneer we are convinced something is going wrong with how the deployment package is built. 

    Could you make sure the application can work without issue before starting DFU? 

    What SD version does this application work with?

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

    For nRF52840, you use --family NRF52840. See Combine application, bootloader and softdevice image - Bootloader setting

    nrfutil pkg generate --hw-version 52 --application-version 1 --application merged_output.hex --sd-req 0xB6 --sd-id 0xB6 app_dfu_package.zip

    Do you update SD? What is the SD version on the board to be replaced? Are you using open bootloader? The package seems doesn't sign with the key. 

    Are you using the bootloader from the SDK? Could you provide the log from the bootloader?   

    Regards,
    Amanda H.

  • Hi Amanda,

    It is a normal sample available for a few years, Acconneer claims it works.  How do I test it without DFU?  Do you mean running it in Segger Debugger?

    As far as I understand the SD needed with this version of the software and SDK is s140_nrf52_6.1.1_softdevice.hex

    I reset the hardware with the following:

    nrfjprog -f nrf52 --erasepage 0xFE000-0x100000
    nrfjprog -f nrf52 --program production_sw.hex --sectorerase --verify
    nrfjprog -f nrf52 --reset

    I assume this is the SD and bootloader combined?

    Where/how do I get the bootloader log for you?

    Thanks!

    Cheers

    Andreas

  • Hi, 

    AndreasLiebenberg said:
    How do I test it without DFU?  Do you mean running it in Segger Debugger?

    You can flash the app and SD to see it can run as the expected or not. Maybe check the log. Please confirm with Acconneer how to verify it. 

    AndreasLiebenberg said:
    I assume this is the SD and bootloader combined?

    What is the production_sw.hex?

    I would suggest take a look at this tutorial Getting started with Nordic's Secure DFU bootloader, a step by step guide.

    -Amanda H.

  • Hi Amanda,

    Thanks for the useful info, not sure if I am further, but this is what I see when follow instruction from your info:  (I must say, every piece of documentation gives different ways to do the same thing.  I am at 4th version now, but still not working)

    I changed my commands to build the .zip package to:

    nrfutil settings generate --family NRF52840 --application acc_bluetooth_beacon.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 bootloader_setting.hex

    Then I merge my App with the generated settings.hex with:

    mergehex -m acc_bluetooth_beacon.hex settings.hex -o merged.hex

    Then I merge the softdevice with:

    mergehex -m merged.hex s140_nrf52_6.1.1_softdevice.hex -o merged_output.hex

    Then I generate the .zip with:

    nrfutil pkg generate --hw-version 52 --application-version 0 --application merged_output.hex --sd-req 0xB6 --sd-id 0xB6 app_dfu_package.zip

    All seems successful, but deployment via Android nRF Toolbox fails on all steps after pressing start.

    If I try deployment vir nrfutil it fails with:

    ages\Python37\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 505, in __get_response
    get_dict_key(DfuTransport.RES_CODE, resp[2])))
    pc_ble_driver_py.exceptions.NordicSemiException: Response Code InsufficientResources

    What is alaso confusing is that the DFU settings generated is:

    Bootloader DFU Settings:
    * File: bootloader_setting.hex
    * Family: NRF52840
    * Start Address: 0x000FF000
    * CRC: 0x1744AB5F
    * Settings Version: 0x00000002 (2)
    * App Version: 0x00000000 (0)
    * Bootloader Version: 0x00000000 (0)
    * Bank Layout: 0x00000000
    * Current Bank: 0x00000000
    * Application Size: 0x0001D42C (119852 bytes)
    * Application CRC: 0xC0609A19
    * Bank0 Bank Code: 0x00000001
    * Softdevice Size: 0x00000000 (0 bytes)
    * Boot Validation CRC: 0xFA4AC3D7
    * SD Boot Validation Type: 0x00000000 (0)
    * App Boot Validation Type: 0x00000001 (1)

    Why would the Softdevice size be 0, do I have a sequence or still wrong command somewhere problem? 

    Thanks

    Cheers

    Andreas


     

  • Hi, 

    AndreasLiebenberg said:
    As far as I understand the SD needed with this version of the software and SDK is s140_nrf52_6.1.1_softdevice.hex
    AndreasLiebenberg said:

    mergehex -m merged.hex s140_nrf52_6.1.1_softdevice.hex -o merged_output.hex

    Then I generate the .zip with:

    nrfutil pkg generate --hw-version 52 --application-version 0 --application merged_output.hex --sd-req 0xB6 --sd-id 0xB6 app_dfu_package.zip

    Seem your app needs to work with s140_nrf52_6.1.1_softdevice, and you already have it on the board before updating the package. Then, it doesn't need to merge with SD and package it. 

    AndreasLiebenberg said:
    pc_ble_driver_py.exceptions.NordicSemiException: Response Code InsufficientResources

    Please provide the log from bootloader with debug version and nRF Toolbox. 

    AndreasLiebenberg said:
    pc_ble_driver_py.exceptions.NordicSemiException: Response Code InsufficientResources

    Response Code InsufficientResources indicate the space is not enough. You could try to just update the app if SD in the pacakge is the same as the one on the device. 

    AndreasLiebenberg said:
    Why would the Softdevice size be 0, do I have a sequence or still wrong command somewhere problem? 

    I think that because acc_bluetooth_beacon.hex doesn't include SD, but that result and flow is right since we generate setting for the app without SD. 

    -Amanda H.

Related