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

Flashing using nrfjprog

HI everyone,

I am currently facing an issue when using nrfjprog to flash my nrf52832-based custom board using nrfjprog.

Here is the steps I followed:

- Creating application hex by merging my app and s132 softdevice (mergehex)

- Creating the bootloader hex file (I adapted example code of secure bootloader with BLE for PCA10040 devkit)

- Creating bootloader settings using "nrfutil settings generate" command, with --bl-settings-version 2 (I am using sdk15.3)

- Merging bootloader (mergehex), settings and app together and proceed with the flashing with the following command:

nrfjprog --reset --program merged_app.hex --family NRF52 --chiperase --verify

In this case my app does not start.

If I first flash my program with Segger embedded studio and flash again (using nrfjprog and --sectoranduicrerase option) with my app + softdevice only (without bootloader & settings) then everything works fine.

Is there an issue if settings are generated with the app merged with softdevice?

Or am I missing something in bootloader configuration?

Thanks in advance for your help

Parents
  • Hi Remi, 

    Please try to test the bootloader setting without doing merge hex. 

    Please first flash the softdevice and the bootloader. Verify that the bootloader is running. 

    Then flash the application and the bootloader setting (don't do reset in between) and then reset, check if the bootloader is still running or it's the application. 

    If the chip doesn't show any activity, please check the log. If there isn't good information in the log, please debug the bootloader, it's like normal application. 

    You can test with very simple application that blinks LED for example. 

    Please include all commands you use to generate bootloader testing and to program the hex files. 

Reply
  • Hi Remi, 

    Please try to test the bootloader setting without doing merge hex. 

    Please first flash the softdevice and the bootloader. Verify that the bootloader is running. 

    Then flash the application and the bootloader setting (don't do reset in between) and then reset, check if the bootloader is still running or it's the application. 

    If the chip doesn't show any activity, please check the log. If there isn't good information in the log, please debug the bootloader, it's like normal application. 

    You can test with very simple application that blinks LED for example. 

    Please include all commands you use to generate bootloader testing and to program the hex files. 

Children
  • Hi,

    Thank you for your feedback.

    When proceeding in this order:

    nrfjprog --eraseall
    nrfjprog -f NRF52 --program s132_nrf52_6.1.1_softdevice.hex      //S132 softdevice
    nrfjprog -f NRF52 --program secure_bootloader_ble_s132.hex      //Bootloader

    without using mergehex, then bootloader is working, but only after a reset:

    nrfjprog -f NRF52 --reset

    Then I flash my app with:

    nrfjprog -f NRF52 --program myapp.hex

    Then the bootloader settings:

    nrfjprog -f NRF52 --program bootloader_setting.hex

    Here I get the error "the area to flash is not erased"

    Does that mean the settings memory area is overlapping the one of the app, softdevice or bootloader?

    Maybe the issue comes from here

    My bootloader settings is generate through:

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

  • I just got my app start by flashing bootloader settings before my app.

    So here are the steps which seems to work for me so far:

    -Erase chip

    -Program SoftDevice

    -Program Bootloader

    -Program Settings

    -Program App

    -Reset Chip

    I will do more testings to make sure everything is reliable this way.

    Does that mean I will not be able to use mergehex?

  • When you reset the SD+BL the BL will write to the bootloader setting section, this cause the write to bootloader_setting.hex fail due to "the area to flash is not erased" 
    You can do "nrfjprog -f NRF52 --program bootloader_setting.hex --sectorerase" to fix this. 

    I'm not sure why the solution using mergehex doesn't work. One thing you can try to check why it doesn't work is to do a "nrfjprog --readcode" to get a hex dump and use notepad++ to compare the 2 hex files, the merged hex and the hex dump. In theory they should be the same. 

Related