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

DFU + SD + APP Programming Via External Programmer

Hi, I'm using the Cyclone FX programmer to program our custom boards with the NRF52840 chip, but after programming all the hex files, the application starts straightaway bypassing the bootloader.

This is my .cfg file:

; Automatically generated configuration file
; Silicon Manufacturer is ARM Based (All Manufacturers)
; Silicon Architecture is ARM Based (Kinetis, LPC, etc.)
;
:ALLOWOUTOFRANGE 1
:RESETDELAY 0
:DEVICE NordicSemi_nRF52_NRF52840-QIAA
:USESWD 1
:DEBUGFREQUENCY 5560
:SAPGUIVERSION 372E3435
:PROVIDEPOWER
:POWERVOLTAGE 3.0
:POWERDOWNDELAY 250
:POWERUPDELAY   250
:KEEPPOWERON 0
:NEWIMAGE
:DESCRIBEIMAGE ImageName_v1
CM  C:\PEMicro\cyclone\supportfiles\supportFiles_ARM\NordicSemi\nRF52\Nordic_nRF52840-QIAA_1x32x256k.arp
EM  ;Erase Module
BM  ;Blank Check Module
SS   \\Path\to\sdk\nRF5_SDK_15.3.0\components\softdevice\s140\hex\s140_nrf52_6.1.1_softdevice.hex
PR 1000 25fff
VR 1000 25fff
SS   P:\secret\project\location\application\_build\nrf52840_xxaa.hex
PR 26000 effff
VR 26000 effff
SS   P:\secret\project\location\bootloader\_build\bootloader_nrf52840_xxaa.hex
PR f0000 fe000
VR f0000 fe000
SS   P:\secret\project\location\bootloader\bootloader_settings.hex
PR ff000 fffff
VR ff000 fffff
RE  ;Reset
GO  ;Run

Bootloader linker file:

MEMORY 
{
  FLASH (rx) : ORIGIN = 0xF0000, LENGTH = 0xE000
  RAM (rwx) :  ORIGIN = 0x200057b8, LENGTH = 0x3a848
  bootloader_settings_page (r) : ORIGIN = 0x000FF000, LENGTH = 0x1000
  mbr_params_page (r) : ORIGIN = 0x000FE000, LENGTH = 0x1000
  uicr_mbr_params_page (r) : ORIGIN = 0x00000FFC, LENGTH = 0x4
  uicr_bootloader_start_address (r) : ORIGIN = 0x00000FF8, LENGTH = 0x4
}

Application linker file:

MEMORY 
{
  FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x65000
  RAM (rwx) :  ORIGIN = 0x20002708, LENGTH = 0x3d8f8
}

I suspect it has something to do with the settings file but I can't seem to figure it out. This is how I'm generating the settings file:

nrfutil settings generate --family NRF52840 --bl-settings-version 2 --bootloader-version 18 --application-version 1 bootloader_settings.hex

Everything works fine if programmed via nrfjprog.

Any advice would be very much appreciated!

A.

  • Hi, 

    Everything works fine if programmed via nrfjprog.

    I don't understand the problem. Do you mean the issue only happened while using the Cyclone FX programmer?

    -Amanda H.

  • Hi Amanda,

    The problem is that programming the binaries at the addresses defined in the .cfg file using the Cyclone FX programmer doesn't seem to execute the bootloader, instead, it jumps straightaway to the user app. Entering into bootloader mode via NRF_POWER->GPREGRET = 0xB1 doesn't work either.

    As I mentioned in the original post, I suspect it is something related to my settings.hex file (or lack of another config file) because if the same binaries are programmed using nrfjprog, everything works as expected (bootloader runs first, then jumps to the user app, and I can enter bootloader mode via NRF_POWER reg).

    I guess I can rephrase the question: 'Is there any config file/flag that I'm missing that is preventing the bootloader from running?" Why is the app being executed straightaway?

    Thanks.

    A.

  • Hi, 

    It could be that when the softdevice is programmed, the bootloader start address that is written to MBR, is overwritten.It will then don't jump to the bootloader at startup, because the MBR does not think there is a bootloader present. 

    A solution could be to merge all the hex-files, with mergehex, and then program the combined hex. Please see this post and this

    -Amanda H.

  • Amanda, thank you! your recommendation about merging the hex files worked like a charm.

    A recommendation for future reference in case anyone out there having the same issues; make sure that when you generate your bootloader settings file using the 'nrfutil settings generate' command, you specify the --application and --key-file flags, otherwise the bootloader will mark the flashed application as invalid and won't execute it.

    nrfutil settings generate --key-file private.key --application /path/to/application.hex ....other settings....

Related