nRF Connect blinky sample hard to debug

My setup:

Mac OS 11.5.2

Vs Code 1.60.2

nRF Connect SDK 1.7.0

nRF52840DK

Using the tutorial videos provided I went through the process of creating the basic blinky sample. I can build, erase and flash and the code appears to work.

When I click on the Debug button bottom left from the nRF Connect pane, the debugger stops in a file called fatal.c sometimes, and at other times stops in reset.S or cpu_idle.S. 

However, if I then click the stop button (small red square in debugger controller), and then the Run and Debug button that appears afterwards, it sometimes works just fine and I can step through the source code.

If I try the samples/bluetooth/peripheral_lbs application, it debugs directly from the nRF Connect pane without difficulty and breaks at the beginning of the main function.

Parents Reply Children
  • Where do you see that? Under Building an application, step 2 is selecting the Debug features, but the application is not built until later in the process. 

    Your intro video here: https://www.youtube.com/watch?v=MGsZJpdLtco&list=PLx_tBuQ_KSqEt7NK-H7Lu78lT2OijwIMl&index=5&t=39s at 0:22 shows two lines to add to the proj.cnf file to enable debugging. When I try what the video suggests, it appears to have no actual affect on anything, and the "Enable debug options" on the Generate Configuration screen on the page you mention above does not appear to add any debug options to the configuration file.

    So again, what does the "Enable debug options" checkbox actually do? Also, since this is a "Generate configuration" screen, does it only generate a proj.cnf file, or are there other configuration files it affects?

  • Hi, 

    Enable debug options adds CONFIG_DEBUG_OPTIMIZATIONS=y and CONFIG_OPENOCD_SUPPORT=y to the build command line. It does not modify any project files. These options set -Og optimization level and add thread info structures required for debugger thread awareness, respectively. 

    Generate configuration does not generate prj.conf file. It generates a CMake build system. Please refer to NCS/Zephyr documentation for details on the build process.

    We recommend to leave it unchecked for blinky due to a bug in the build system and debug server that is causing the debugger to halt on stray debug symbols.

    -Amanda

Related