Debug from vscode with jtag

eskibrew
Posts: 8
Joined: Fri Jul 02, 2021 2:31 pm

Debug from vscode with jtag

Postby eskibrew » Sat Jul 02, 2022 9:49 pm

I have my ESP32-EBV board connected to ESPROG board via JTAG. I can run openocd server as follows:
openocd -f board/esp32-wrover-kit-3.3v.cfg
and that works fine.

If I create a .gdbinit file with the contents:

Code: Select all

target remote :3333
set remote hardware-watchpoint-limit 2
mon reset halt
flushregs
thb app_main
c
and then run "xtensa-esp32-elf-gdb -x .gdbinit build/test.elf"
it will correctly debug - it stops at app_main and then I can enter "continue" to run the program and use CTRL-C to break execution.

All fine so far!

If I try to launch a debug session from within vscode instead, I cannot get the same behaviour. It will not stop upon entry to app_main and once running, the pause button will not break execution. I can set a breakpoint before execution and that does hit and pause execution but I cannot then change the breakpoint. It seems there is a problem with the vscode extension but what can I do?

Using this launch.json file:

Code: Select all

{
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "ESP32 OpenOCD Debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/test.elf",
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "/home/user/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                { "text": "target remote :3333" },
                { "text": "set remote hardware-watchpoint-limit 2" },
                { "text": "mon reset halt" },
                { "text": "flushregs" },
                { "text": "thb app_main" },
                { "text": "c" }
            ],
            "logging": {
                "trace": true,
                "traceResponse": true,
                "engineLogging": true
            },
        },
    ]
}
I get the message:

Code: Select all

Unable to start debugging. Unexpected GDB output from command "-interpreter-exec console "C"". Unexpected ResultClass from MIDebugger. Expected 'done' but received 'running'
So I remove the { "text": "c" } line and then it runs. I can set a breakpoint and it will stop. I can then single step.
If I hit continue, I can no longer pause the execution.

Any suggestions?

eskibrew
Posts: 8
Joined: Fri Jul 02, 2021 2:31 pm

Re: Debug from vscode with jtag

Postby eskibrew » Wed Jul 06, 2022 1:40 pm

I changed to use the espidf esp-debug-adapter instead.
This seemed to work better but it was not reliable so I have now switched to platformio instead and that seems robust.

Who is online

Users browsing this forum: DrMickeyLauer, mikecarlos and 114 guests