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

Debugging from VSCode with Cortex DEBUG and NRF Connect for VSCode

Hi, Im trying to get the debugger working in VSCode using the new nrfConnect for VSCode, while following the Youtube series for nRF Connect in VSCode. Im using the following versions:

nRF52840DK
nRF-Connect-2021.8.579.vsix
nRF-Terminal-2021.8.13.vsix
kconfig-lang-2021.8.3.vsix
devicetree-2021.8.2.vsix

In addition, Ive downloaded nRF Connect V3.7 and nRF Connect SDK V1.6.1.

I added the following lines to path, which got me a little further:


Now I get the following errors in the VSCode Debug Console:

Please check OUTPUT tab (Adapter Output) for output from JLinkGDBServerCL.exe
Launching server: "JLinkGDBServerCL.exe" "-singlerun" "-if" "swd" "-port" "50000" "-swoport" "50001" "-telnetport" "50002" "-device" "nRF52840_xxAA" "-select" "usb=683067661"
Launching GDB: "e:\Programs\NordicSemiconductor\ncs\v1.6.1\toolchain\opt\bin\arm-none-eabi-gdb.exe" "-q" "--interpreter=mi2"
undefinede:\Programs\NordicSemiconductor\ncs\v1.6.1\toolchain\opt\bin\arm-none-eabi-gdb.exe: warning: Couldn't determine a path for the index cache directory.
Reading symbols from e:\Revolve\Software\nRF_Example\BlinkLed_To_BareMetal\build\zephyr\zephyr.hex...
(No debugging symbols found in e:\Revolve\Software\nRF_Example\BlinkLed_To_BareMetal\build\zephyr\zephyr.hex)
0x00000452 in ?? ()
Program stopped, probably due to a reset and/or halt issued by debugger
add symbol table from file "e:/Revolve/Software/nRF_Example/BlinkLed_To_BareMetal/build/zephyr/zephyr.elf"
(y or n) [answered Y; input not from terminal]
Reading symbols from e:/Revolve/Software/nRF_Example/BlinkLed_To_BareMetal/build/zephyr/zephyr.elf...
2
Resetting target


The last line in the output is "Starting target CPU..."

My CMakeLists.txt looks like this, most of this is just adding stuff to see if it works:
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(gpio_testing)

add_definitions(-g -v -v -DDEBUG)

add_compile_options(
  "-Wall" "-Wpedantic" "-Wextra" "-fexceptions"
  "$<$<CONFIG:DEBUG>:-O0;-g3;-ggdb>"
)

set(CMAKE_BUILD_TYPE Debug)

target_sources(app PRIVATE src/main.c
                           src/gpio/gpio.c)



What are the points Im missing to get debugger to work in VSCode?

Parents
  • It does not stop at the breakpoint at the top of main.c. Ive seen sometimes that I can pause it in cpuidle.s, but Ive never gotten to main.c

  • Hi,

    Where are you setting the breakpoints? Have you tried setting multiple breakpoints inside the main() function in main.c? Does the application still run, even if you are not able to debug?

    What launch configuration are you using? In the debug window, the launch configuration will be what you can select in the drop down menu next to "RUN AND DEBUG" at the top of the sidebar. You can open the launch file by clicking on the gear symbol next to the drop down menu.

    Best regards,

    Marte

  • When running the "Launch Build" configuration, from the Run and Debug tab (not the nRF Connect tab), I get the following in the Debug Console:

    Program
     received signal SIGTRAP, Trace/breakpoint trap.
    0xdeadbeee in ?? ()
    


    If I try to select the "Launch active build configuration" from the Run and Debug tab I get a message saying it cant find a task called "nRF Connect: Build active confugration", If I select debug anyway from here, I get no further than previous attemps

  • Hi ,

    I'd like to clarify a bit how the extension works wrt to debugging.

    When you hit the 'Debug' in the action tab the extension is creating a transient configuration for cortex-debug on the fly and starting a debug session with it. It is not using the launch configurations from launch.json file.

    The custom launch types come into play if you'd like to customize the debug parameters. You can add the configuration to the launch json as Marte shown and use it from the Debug and Run pane of vscode.

    The reason that "Launch active build configuration" doesn't work for you is that there is a dependency in the configuration. Just remove the following line:

              

    "preLaunchTask": "nRF Connect: Build active configuration"

    We've seen the 0xdeadbeee error before and we've been hunting to fix it. However, to make it easier for us I'd suggest to do the following:

    1. Remove the launch.json file
    2. Create a new build configuration for an application. Make sure to tick 'Enable debug' options what adds structures necessary for zephyr thread awareness. 
    3. Start a debug session using 'Debug' from Actions view in nRF Connect tab.

    Then let us know what happens.

    Kind regards,

    Wojtek
    VSCode Team

  • So, I deleted all the stuff in my nRF_Example (projects) folder. Created a new application with the blinky example. And pressed debug in the Actions Tab of the nRF Connect application in VS Code. This gives me the following buttons at the top:



    The board does not blink, I am not in a breakpoint.

    The LED for the JLink part is blinking.

    The Debug Console shows me this:



    The Terminal window is showing me this.

    Resuming connection to gdb server...
    SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected
    SEGGER J-Link GDB Server V7.54 Command Line Version
    
    JLinkARM.dll V7.54 (DLL compiled Sep  1 2021 10:46:27)
    
    Command line: -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device nRF52840_xxAA -select usb=683067661
    -----GDB Server start settings-----
    GDBInit file:                  none
    GDB Server Listening port:     50000
    SWO raw output listening port: 50001
    Terminal I/O port:             50002
    Accept remote connection:      localhost only
    Generate logfile:              off
    Verify download:               off
    Init regs on start:            off
    Silent mode:                   off
    Single run mode:               on
    Target connection timeout:     0 ms
    ------J-Link related settings------
    J-Link Host interface:         USB
    J-Link script:                 none
    J-Link settings file:          none
    ------Target related settings------
    Target device:                 nRF52840_xxAA
    Target interface:              SWD
    Target interface speed:        4000kHz
    Target endian:                 little
    
    Connecting to J-Link...
    J-Link is connected.
    Firmware: J-Link OB-SAM3U128-V2-NordicSemi compiled Feb  2 2021 16:47:20
    Hardware: V1.00
    S/N: 683067661
    Feature(s): RDI, FlashBP, FlashDL, JFlash, GDB
    Checking target voltage...
    Target voltage: 3.30 V
    Listening on TCP/IP port 50000
    Connecting to target...
    Connected to target
    Waiting for GDB connection...Connected to 127.0.0.1
    Reading all registers
    Read 4 bytes @ address 0x00001A3E (Data = 0x8811F380)
    Read 2 bytes @ address 0x00001A3E (Data = 0xF380)
    Received monitor command: halt
    Halting target CPU...
    ...Target halted (PC = 0x00001A3E)
    Received monitor command: reset
    Resetting target
    Downloading 16016 bytes @ address 0x00000000
    Downloading 8244 bytes @ address 0x00003E90
    Comparing flash   [....................] Done.
    Writing register (PC = 0x    1ac8)
    Received monitor command: reset
    Resetting target
    Read 4 bytes @ address 0x00001AC8 (Data = 0xF3802000)
    Read 2 bytes @ address 0x00001AC8 (Data = 0x2000)
    Reading 64 bytes @ address 0x00000000
    Read 4 bytes @ address 0x00000210 (Data = 0x468480E7)
    Read 4 bytes @ address 0x00000334 (Data = 0xFA00F201)
    Read 2 bytes @ address 0x00000038 (Data = 0x1861)
    Read 2 bytes @ address 0x000003F4 (Data = 0xB538)
    Setting breakpoint @ address 0x00000038, Size = 2, BPHandle = 0x0001
    Setting breakpoint @ address 0x000003F4, Size = 2, BPHandle = 0x0002
    Starting target CPU...

  • Not the last time I posted, but I just redid it with flashing first, and then debug. And the result is the same.

    No flashing LED from the nRF, no breakpoints, Debug Console stopping at "Resetting Target" and Terminal stopping at "Starting target CPU..."

Reply Children
Related