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

How to load an application with bootloader (NRF82540)

Hi,

I loaded bootloader, SoftDevice, and Application using nRFConnect - Programmer. But it doesn't launch the application. It fails at

nrf_bootloader_fw_activate()
with s_dfu_settings.bank_1 = 0;

How do I combine all three, and load with nRFConnnect - Programmer?

Thanks,

David

Parents
  • Hello David,

    You can either merge the .hex files and program them in one go using "nrfjprog --program app_out.hex", or you can program it in 3 rounds:

    nrfjprog --program softdevice.hex --verify && nrfjprog --program bootloader.hex --verify && nrfjprog --program app.hex --verify

    However, the bootloader will not accept an application that isn't signed. There are two ways of signing the application:

    1: Update the application via DFU. Whenever you do this, you must create a DFU image using nrfutil and the private key that you used to generate the public key that is programmed into the bootloader.

    2: You can generate bootloader settings and flash these. To generate bootloader settings, you can use the command "nrfutil settings generate". These settings will generate a hex file that you must program like the other ones, either by merging them into your app_out.hex (NB: I believe mergehex only accepts 3 input files in one go, so you must split it up in two operations). NB: If you reset the device before programming the bootloader settings, you must add --sectorerase because the bootloader will generate a set of bootloader settings if it starts and no settings are present.

    If you have all 4 hex files, SD (SoftDevice), BL (Bootloader), BL-Settings (Bootloader-settings) and APP (Application), you can program them either via nrfjprog or nRF Connect - Programmer.

    Best regards,

    Edvin

  • Hi Edvin,

    I programmed with 4 files: SD, BL, BL-Settings, and APP. But the application doesn't run.

    BUT, I have to comment out the following lines of the code in the secure bootloader project:

        //  ret_val = nrf_bootloader_init(dfu_observer);
        //  APP_ERROR_CHECK(ret_val);

    To get application running.

    The project I am testing: secure_bootloader and ble_peripheral/ble_app_beacon

    I don't know it is not program properly or it is something in the nrf_bootloader_init(dfu_observer);

    Thank you,

    David

  • You shouldn't comment out nrf_bootloader_init(), because then the DFU will not work. Can you show me the command you used to generate your bootloader settings?

  • Hi Edvin,

    I know nrf_bootloader)init() is needed.

    Here is the command for bl_settings hex and output of the command: (from ble_app_beacon)

    ..\ble_app_beacon\..\Exe > nrfutil settings generate --family NRF52840 --application xapp
    .hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 xsettings1.hex

    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: xsettings1.hex

    Bootloader DFU Settings:
    * File:                     xsettings1.hex
    * Family:                   NRF52840
    * Start Address:            0x000FF000
    * CRC:                      0xB454210E
    * Settings Version:         0x00000001 (1)
    * App Version:              0x00000001 (1)
    * Bootloader Version:       0x00000001 (1)
    * Bank Layout:              0x00000000
    * Current Bank:             0x00000000
    * Application Size:         0x000051F4 (20980 bytes)
    * Application CRC:          0x099FCDD3
    * 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)

    I also tried bl_settings as version 2: ( all versions as 2)

    Bootloader DFU Settings:
    * File:                     xsettings2.hex
    * Family:                   NRF52840
    * Start Address:            0x000FF000
    * CRC:                      0x8677B04B
    * Settings Version:         0x00000002 (2)
    * App Version:              0x00000002 (2)
    * Bootloader Version:       0x00000002 (2)
    * Bank Layout:              0x00000000
    * Current Bank:             0x00000000
    * Application Size:         0x000051F4 (20980 bytes)
    * Application CRC:          0x099FCDD3
    * Bank0 Bank Code:          0x00000001
    * Softdevice Size:          0x00000000 (0 bytes)
    * Boot Validation CRC:      0x0678BEE3
    * SD Boot Validation Type:  0x00000000 (0)
    * App Boot Validation Type: 0x00000001 (1)

    Thank you,

    David

  • What SDK are you using? I just assume that you have a set of public and private keys, where you used the public key in your bootloader project, right?

    If so, you must add the command "--key-file private.key" when you generate your settings:

    ..\ble_app_beacon\..\Exe > nrfutil settings generate --family NRF52840 --application xapp
    .hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 --key-file private.key xsettings1.hex

    This is the signature that you use to tell your bootloader that the FW is actually coming from you. "private.key" should be the name you used when you generated the private key:

    nrfutil keys generate private.key
    or
    nrfutil keys generate private.pem

    Best regards,

    Edvin

  • I added private.key into the bl_settings, but some how it sill not running:

    c:\_Projects\_Sources\AssetTracking\Drill\nRF5_SDK_15.3.0_59ac345\examples\ble_peripheral\ble_app_beac
    on\pca10056\s140\ses\Output\Release\Exe>nrfutil settings generate --family NRF52840 --application xapp
    .hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 --key-file private.key xse
    ttingsx.hex

    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: xsettingsx.hex

    Bootloader DFU Settings:
    * File:                     xsettingsx.hex
    * Family:                   NRF52840
    * Start Address:            0x000FF000
    * CRC:                      0xB454210E
    * Settings Version:         0x00000001 (1)
    * App Version:              0x00000001 (1)
    * Bootloader Version:       0x00000001 (1)
    * Bank Layout:              0x00000000
    * Current Bank:             0x00000000
    * Application Size:         0x000051F4 (20980 bytes)
    * Application CRC:          0x099FCDD3
    * 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)

    Other thing may related:

    When I compiled beacon project, I added uECC.c into Library as source, the uECC.c is compiled without error. I didn't not uECC as a compiled static library. But for some reason, With or without uECC.c or uECC.a static library, the beacon project is compiled anyway. I was wandering where is how uECC is used or its function is called? Will that be a problem is the validation of firmware code?

    David

Reply
  • I added private.key into the bl_settings, but some how it sill not running:

    c:\_Projects\_Sources\AssetTracking\Drill\nRF5_SDK_15.3.0_59ac345\examples\ble_peripheral\ble_app_beac
    on\pca10056\s140\ses\Output\Release\Exe>nrfutil settings generate --family NRF52840 --application xapp
    .hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 --key-file private.key xse
    ttingsx.hex

    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: xsettingsx.hex

    Bootloader DFU Settings:
    * File:                     xsettingsx.hex
    * Family:                   NRF52840
    * Start Address:            0x000FF000
    * CRC:                      0xB454210E
    * Settings Version:         0x00000001 (1)
    * App Version:              0x00000001 (1)
    * Bootloader Version:       0x00000001 (1)
    * Bank Layout:              0x00000000
    * Current Bank:             0x00000000
    * Application Size:         0x000051F4 (20980 bytes)
    * Application CRC:          0x099FCDD3
    * 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)

    Other thing may related:

    When I compiled beacon project, I added uECC.c into Library as source, the uECC.c is compiled without error. I didn't not uECC as a compiled static library. But for some reason, With or without uECC.c or uECC.a static library, the beacon project is compiled anyway. I was wandering where is how uECC is used or its function is called? Will that be a problem is the validation of firmware code?

    David

Children
No Data
Related