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

Debugging with nRF52810 with OpenOCD and STLinkV2

I've been trying to get debugging working with the STLinkV2. I'm not able to step into code whatsoever, when I pause execution it appears t PC is at:

Info : halted: PC: 0xfffffffe

I don't believe the code is executing correctly because this program doesn't flash an LED:

#include "mdk/nrf.h"
#include "system_nrf.h"
#include "hal/nrf_gpio.h"

int main(int argc, char *argv[])
{
    int pin = 6;
    nrf_gpio_pin_dir_set(pin, NRF_GPIO_PIN_DIR_OUTPUT);
    //
    while(true)
    {
        volatile int delay = 1000000;
        while(delay--);
        //
        nrf_gpio_pin_toggle(pin);
    }
    return 0;
}

I'm using the following cfg script:

source [find interface/stlink.cfg]
transport select hla_swd
source [find target/nrf52.cfg]

The linker script regions are configured as follows:

MEMORY
{
  FLASH (rx) : ORIGIN = 0x0,        LENGTH = 0x30000
  RAM (rwx) :  ORIGIN = 0x20000000, LENGTH = 0x6000
}

For completeness the log i'm getting with from openOCD is:

Open On-Chip Debugger 0.10.0 (2019-10-29) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1000 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.216316
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 50000 for gdb connections
Info : accepting 'gdb' connection on tcp/50000
Info : nRF52810-QFAA(build code: B0) 192kB Flash
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Info : Flash write discontinued at 0x000082a0, next section at 0x000182a0
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg/nrf52.cfg to disable it
Warn : using fast async flash loader. This is currently supported
Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg/nrf52.cfg to disable it
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc

Parents
  • Hi,

    I can try to help you with this, but please note that we don't have official support for openOCD so we don't have as much experience with it as we do with j-link.

    The register values are wrong, but I'm not sure if it's because of  a FW issue are an issue with the Debugger configuration. To narrow it down I suggest to try loading one of the pre-compiled hex files from the SDK and see if you get the same register readouts. 

    Here's a pre-compiled version of our blinky example (\examples\peripheral\blinky\hex) which you can try:

    blinky_pca10040e.hex

    Make sure to use the 'pca10040e' configuration when testing SDK examples. These have the correct linker settings to run on nRF52810. See Developing for nRF52810 for more details.

Reply
  • Hi,

    I can try to help you with this, but please note that we don't have official support for openOCD so we don't have as much experience with it as we do with j-link.

    The register values are wrong, but I'm not sure if it's because of  a FW issue are an issue with the Debugger configuration. To narrow it down I suggest to try loading one of the pre-compiled hex files from the SDK and see if you get the same register readouts. 

    Here's a pre-compiled version of our blinky example (\examples\peripheral\blinky\hex) which you can try:

    blinky_pca10040e.hex

    Make sure to use the 'pca10040e' configuration when testing SDK examples. These have the correct linker settings to run on nRF52810. See Developing for nRF52810 for more details.

Children
No Data
Related