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

Program only works in SES and not standalone

Hi, I'm using blinky from the SDK12 as an example here with a nordic nrf51 DK (pca10028, onboard nrf51422) which I am using as a programmer with a custom board (with a nrf51822_XXAA). I can flash, verify etc fine, and it runs whilst in SEGGER embedded studio (using Compile and Run). However, if I try and debug the program with the debugger or run it stand alone via the J-Link commander, it enters a HardFault and jumps to 0xFFFFFEFE indefinitely.

I presume this is something to do with the entry point as if I change "Start from Entry Point Symbol" from the default no, to yes within debug project options, the debugger then works (however standlone still has the same issue). I've tried adding the bootloader options, softdevices, moving the flash around and I still haven't got any further. Any ideas?

Preprocessor Definitions:

NRF51
NRF51822
BOARD_PCA10028
NO_VTOR_CONFIG

Linker Section Placement Macros:

FLASH_START=0x1F000
SRAM_START=0x20002000
  (Linker Section Placement file from latest SEGGER embedded studio tutorial)

Linker Section Placement Segments:

FLASH RX 0x00000000 0x00040000
SRAM RWX 0x20000000 0x00004000
  • Nevermind fixed it

    Here's how I fixed it (mostly):

    Flashed the soft device using nrfGo, this tells you the start address of your program. image description

    Use this address in your Linker Section Placement Macros (SRAM was found on page 39 of the nrf51822 DK user guide 1.3 - www.nordicsemi.com/.../95790481): eg:

    FLASH_START=0x1b000
    SRAM_START=0x20002000
    

    Also update your Section Placement Segments to reflect the same start addresses (the sizes were also taken from the above document, I presume these can be changed):

    FLASH RX 0x1b000 0x20000
    SRAM RWX 0x20002000 0x2000
    

    Now, we need to make Segger embedded studio to output a hex file we can program seperately, still in the linker options, change "Additional Output Format" to "hex". This will be ouputted in Output/{Build Configuration}/Exe/[name].hex. For example, mine ended up being examples\peripheral\blinky\pca10028\s130\arm5_no_packs\Output\nrf51822_XXAA\Exe\blinky_pca10028_s130.hex

    Now go back to nrfGo, and flash the program application. Voila! Your program should now be working, and accross restarts/power cycles of your board!

    However, this setup still doesn't work with my bigger BLE project, has similar issues that mean it always ends up with a HardFault. Still debugging this one!

Related