ESP32 Debugg with VSCode

temuko
Posts: 8
Joined: Sun Oct 15, 2023 10:55 am
Location: Europe, Spain

ESP32 Debugg with VSCode

Postby temuko » Sun Jan 07, 2024 10:00 pm

Hello!

I recently bought an ESP-Prog and am attempting to debug a project in VSCode. I'm using an ESP32 Dev kit along with the Espressif ESP-Prog. Unfortunately, I'm unable to make it work. When I execute OpenOCD, it seems to work properly, but when I click the run button to debug, the tools appear, but I can't debug the project. The OpenOCD and debug console traces show the following:

Code: Select all

OPENOCD:
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi tdo_sample_edge falling"
Info : clock speed 20000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : starting gdb server for esp32.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Info : [esp32.cpu0] Target halted, PC=0x40084826, debug_reason=00000000
Info : [esp32.cpu0] Reset cause (1) - (Power on reset)
Info : Set GDB target to 'esp32.cpu0'
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target halted, PC=0x40084826, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
Info : accepting 'gdb' connection on tcp/3333
Warn : No symbols for FreeRTOS!
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 45 KB
Info : Flash mapping 1: 0x20020 -> 0x400d0020, 98 KB
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : Auto-detected flash bank 'esp32.cpu0.flash' size 4096 KB
Info : Using flash bank 'esp32.cpu0.flash' size 4096 KB
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 45 KB
Info : Flash mapping 1: 0x20020 -> 0x400d0020, 98 KB
Info : Using flash bank 'esp32.cpu0.irom' size 100 KB
Info : [esp32.cpu0] Target halted, PC=0x400BE636, debug_reason=00000001
Info : Flash mapping 0: 0x10020 -> 0x3f400020, 45 KB
Info : Flash mapping 1: 0x20020 -> 0x400d0020, 98 KB
Info : Using flash bank 'esp32.cpu0.drom' size 48 KB
Info : New GDB Connection: 1, Target esp32.cpu0, state: halted
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : [esp32.cpu0] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Debug controller was reset.
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x500000CF, debug_reason=00000000
Info : [esp32.cpu1] Debug controller was reset.
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target halted, PC=0x500000CF, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
Info : [esp32.cpu0] Reset cause (3) - (Software core reset)
Info : [esp32.cpu1] Target halted, PC=0x500000CF, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
Info : [esp32.cpu1] requesting target halt and executing a soft reset
Info : [esp32.cpu0] Core was reset.
Info : [esp32.cpu0] Target halted, PC=0x40000400, debug_reason=00000000
Info : [esp32.cpu1] Core was reset.
Info : [esp32.cpu1] Target halted, PC=0x40000400, debug_reason=00000000
Info : [esp32.cpu1] Reset cause (14) - (CPU1 reset by CPU0)
Info : [esp32.cpu0] Reset cause (3) - (Software core reset)
Info : Detected FreeRTOS version: (10.4.3)
Info : [esp32.cpu0] Target halted, PC=0x40084826, debug_reason=00000000
Info : Set GDB target to 'esp32.cpu0'
Info : [esp32.cpu1] Target halted, PC=0x40084826, debug_reason=00000000
Info : [esp32.cpu1] Target halted, PC=0x40084826, debug_reason=00000000
Info : Set GDB target to 'esp32.cpu1'

DEBUG OUTPUT:

=thread-group-added,id="i1"
GNU gdb (esp-gdb) 12.1_20221002
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=xtensa-esp-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
[New Thread 1073413712]
[New Thread 1073413024]
[New Thread 1073412272]
[New Thread 1073412616]
[New Thread 1073410900]
I'm not sure if I'm doing something incorrectly or if I need to add something more to the config. This is the launch.json that I'm using:

Code: Select all

{
	// Use IntelliSense to learn about possible attributes.
	// Hover to view descriptions of existing attributes.
	// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
	"version": "0.2.0",
	"configurations": [
		{
			"name": "ESP-Prog Debug",
			"type": "cppdbg",
			"request": "launch",
			"program": "${workspaceFolder}/build/continuous_read.elf",
			"cwd": "${workspaceFolder}/build",
			"miDebuggerPath": "/home/xae/.espressif/tools/xtensa-esp-elf-gdb/12.1_20221002/xtensa-esp-elf-gdb/bin/xtensa-esp32-elf-gdb",
			//"debugServerArgs": "-f interface/ftdi/esp32_devkitj_v1.cfg -f target/esp32.cfg -c \"esp32.cpu1 configure -rtos FreeRTOS\"",
			"setupCommands": [
				
					{"text":"target remote 127.0.0.1:3333"},
					{"text":"set remote hardware-watchpoint-limit 2"},
					{"text":"monitor reset halt"},
					{"text":"flushregs"}
			]
		}
	]
}
I'm running VSCode on Arch Linux. Any guidance or assistance would be greatly appreciated!
Thanks

joseMiguel
Posts: 22
Joined: Sun Oct 25, 2020 11:43 pm

Re: ESP32 Debugg with VSCode

Postby joseMiguel » Tue Jan 09, 2024 8:07 am

Hello Temuko,

could you insert before "miDebuggerPath": the "MIMode" instruction

"MIMode": "gdb",
"miDebuggerPath": "your path to gdb",

Could you add the tasks.json file in your answer to verify it. How openocd is called

Hope it will help you

José Michel
José Michel

temuko
Posts: 8
Joined: Sun Oct 15, 2023 10:55 am
Location: Europe, Spain

Re: ESP32 Debugg with VSCode

Postby temuko » Wed Jan 10, 2024 7:09 pm

Thanks!
The MIMode solved the problem. Anyways, I was opening the OpenOCD manual in the terminal.
-sudo openocd -f board/esp32-wrover-kit-3.3v.cfg
I will now write the tasks.json since I know it is working. Thanks a lot!

Who is online

Users browsing this forum: No registered users and 19 guests