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

  • In the post: devzone.nordicsemi.com/.../how-to-flash-the-softdevice-the-bootloader-and-the-application-at-once

    • nrfjprog --eraseall --programs softdevice.hex --program application.hex bootloader.hex --verify --reset


      The command is NOT working, cannot have multiple --program a1.hex --program a2.hex
      --programs is typo in the above command, I believe.

      ==========================================================================
      Generated application settings for bootloader, but cannot add into mergehex.

      >mergehex -m softdevice.hex bootloader.hex app.hex settings.hex -o app_out.hex
      Parsing input hex files.
      ERROR: An invalid argument was provided. Use --help for a list of valid
      ERROR: arguments.

      ==========================================================================
      >mergehex -m softdevice.hex bootloader.hex app.hex -o app_out.hex
      merged without error, BUT flashed into the device, and it doesn't launch the application.

      So what is correct command to program multiple files at once, or what is correct mergehex command to merge settings.hex into bootloader?

      Thank you,

      David

  • 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

Related