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

How to flash application after dfu bootloader

Hi Team Nordic,

I know this question has been answered in several threads but the responses seem quite old now. I am using nrf52840 and SDK 15.3.0 and I want to flash the application using nrfjprog command after I flash the bootloader but as soon as I flash the bootloader, it enters in the update mode (DFUTarg). What should be the best way now to do so? 

I have seen responses to change the bootloader settings page in order to skip the CRC and validation steps. But in SDK version I am using, I think its already implemented in the config file:

Do I still need to change the bootloader settings page, if yes then can you please explain a little on the procedure to edit the bootloader settings page as I am only aware on how to generate one. 

// <q> NRF_BL_APP_CRC_CHECK_SKIPPED_ON_GPREGRET2 - Skip integrity check of the application when bit 1 (0-indexed) is set in the GPREGRET2 register.

#ifndef NRF_BL_APP_CRC_CHECK_SKIPPED_ON_GPREGRET2
#define NRF_BL_APP_CRC_CHECK_SKIPPED_ON_GPREGRET2 1
#endif

// <q> NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET - Skip integrity check of the application when waking up from the System Off state.

#ifndef NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET
#define NRF_BL_APP_CRC_CHECK_SKIPPED_ON_SYSTEMOFF_RESET 1
#endif

// </h>

#ifndef NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN
#define NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN 18
#endif

// </e>

// <q> NRF_BL_DFU_ENTER_METHOD_PINRESET - Enter DFU mode on pin reset.

#ifndef NRF_BL_DFU_ENTER_METHOD_PINRESET
#define NRF_BL_DFU_ENTER_METHOD_PINRESET 0
#endif

// <q> NRF_BL_DFU_ENTER_METHOD_GPREGRET - Enter DFU mode when bit 1 (0-indexed) is set in the NRF_POWER_GPREGRET register.

#ifndef NRF_BL_DFU_ENTER_METHOD_GPREGRET
#define NRF_BL_DFU_ENTER_METHOD_GPREGRET 1
#endif

// <q> NRF_BL_DFU_ENTER_METHOD_BUTTONLESS - Enter DFU mode when the Boolean enter_buttonless_dfu in DFU settings is true.

#ifndef NRF_BL_DFU_ENTER_METHOD_BUTTONLESS
#define NRF_BL_DFU_ENTER_METHOD_BUTTONLESS 0
#endif

Thanks,

Arshdeep

Parents Reply Children
  • So you have all the hex files, i.e.  SoftDevice, Bootloader , Application and the settings page, and you want to flash these to the nRF device using a programmer? 

    Can you elaborate on what you mean by unable to flash the application? You should be able to program the nRF device regardless if there is code running on the device or not. The debugger will halt the cpu and then flash the 

    The bootloader and the bootloader settings hex should be merged together using mergehex from the nRF Commandline Tools. If you're using the bootloader unaltered from SDK v15.3.0, then I would recommend merging the bootloader with the SoftDevice hex as well. Then use nrfjprog to flash the combined SD_BL_Settings.hex and then flash the application.

    Best regards

    Bjørn

  • Hi,

    So to elaborate: 

    First of all, I have all the hex files with me i.e Softdevice, bootloader, application and settings

    Second, I have merged the bootloader and settings hex file to make my_bootloader.hex

    Now, I start programming the nrfdevice with the softdevice (nrfjprog.exe --program s140_nrf52_6.0.0_softdevice.hex --verify)

    Then I program the merged bootloader and settings hex (nrfjprog.exe --program my_bootloader.hex --verify -r)

    After this command my nrf device goes directly into DFUTarg mode. and hence I am unable to program the application.hex using the nrfjprog command .

    How do I prevent this ? I want to program all the hex files using nrfjprog. Will it help if I share my bootloader project ?

    Thanks,

  • You should be able to flash application to the nRF device even though the bootloader is running. What happens when you flash the application after flashing the bootloader, i.e. nrfjprog --program application.hex --verify -r? Please post the output from nrfjprog if there are any errors. 

Related