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

debugging softdevice applications with gdb

Hi Nordic,

Running a gdb session on nRF51, it is difficult to debug the code beyond the SoftDevice initialization. Then, I have to step through with (gdb)ni, but this is not convenient, and on top of that, system events don't seem to fire up.

I know this question has been raised many times, and I was working my way around it each time, but today, I am faced with stack overflow issues, and not being able to dump the RAM at specific breakpoints is a major pain.

Plus, it makes me look very bad, as my colleague, who is developing the master-side on iOS has no such kind of problem :)

I am aware that gdb is not officially supported by Nordic, so if there is a solution on Keil, just let me know.

Cheers,

appli_20151130.elf

Parents
  • Hi, It's not possible to single step while the softdevice is in use as you may know already. That is, you can do it to some extent as explained in this thread. What you can do is to set breakpoints and see if the are reached during program execution. E.g., place a breakpoint in app_error.c->app_error_handler() to see if any of the calls to the softdevice has returned an error code. You can also use trace to log debug data over UART or Segger RTT.

    Some suggestions if you suspect stack overflow:

    1. Allocate more stack and see if you still experience problems.
    2. Halt the cpu when you think the stack may have overflown and read the stack pointer (R13) value. Then check against your .map file from the build output and see if the SP is outside the allocated call stack range.
    3. "paint" the ram above the application region with a known pattern at startup, and let the application run for some time. Then halt cpu and read the RAM to determine the max. stack usage.
  • Indeed the softdevice was initialized with NRF_CLOCK_LFCLKSRC_XTAL_50_PPM. However, changing to other values doesn't make a difference. Breakpoints beyond softdevice_handler_init are not reached. Attached ELF for reference (compiled for a nRF51 board, GPIO are remapped). Which refdesign are you using ?

Reply Children
No Data
Related