Hello all, First off There is no valid documentation on how to properly configure PlatformIO and Visual Studio Code to properly debug any ESP32 chip.
I have setup a simple Hello world project in Platformio using Visual Studio Code.
Here is the program:
#include <Arduino.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Hello World!");
delay(1000);
}
Here is my Platformio.ini file
[env:esp32s3usbotg]
platform = espressif32
board = esp32s3usbotg
framework = arduino
debug_port = /dev/ttyACM1
debug_tool = esp-builtin
;debug_server = localhost:3333
upload_port = /dev/ttyACM0
build_flags = -v
debug_init_break = tbreak loop
build_type = debug
;lib_deps = arduino-libraries/WiFi@^1.2.7
monitor_speed = 9600
monitor_port = /dev/ttyUSB0
Here is my launch.json file:
"version": "0.2.0",
"configurations": [
{
"name": "ESP32-S3 Debug",
"type": "cppdbg",
"request": "launch",
"program": "/home/binshift/Code/helloworld/.pio/build/esp32s3usbotg/firmware.elf",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "PlatformIO: Build",
"miDebuggerPath": "/home/binshift/.espressif/tools/xtensa-esp-elf-gdb/12.1_20231023/xtensa-esp-elf-gdb/bin/xtensa-esp32s3-elf-gdb",
"miDebuggerArgs": "--interpreter=mi2",
"miDebuggerServerAddress": "127.0.0.1:3333"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "/home/binshift/Code/helloworld/.pio/build/esp32s3usbotg/firmware.elf",
"projectEnvName": "esp32s3usbotg",
"toolchainBinDir": "/home/binshift/.platformio/packages/toolchain-xtensa-esp32s3/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
}
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "/home/binshift/Code/helloworld/.pio/build/esp32s3usbotg/firmware.elf",
"projectEnvName": "esp32s3usbotg",
"toolchainBinDir": "/home/binshift/.platformio/packages/toolchain-xtensa-esp32s3/bin",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (without uploading)",
"executable": "/home/binshift/Code/helloworld/.pio/build/esp32s3usbotg/firmware.elf",
"projectEnvName": "esp32s3usbotg",
"toolchainBinDir": "/home/binshift/.platformio/packages/toolchain-xtensa-esp32s3/bin",
"internalConsoleOptions": "openOnSessionStart",
"loadMode": "manual"
}
I have tried to debug using PIO Debug:
I get the error:
ndefinedOpen On-Chip Debugger v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001
Info : esp_usb_jtag: capabilities descriptor set to 0x2000
adapter speed: 40000 kHz
Warn : Transport "jtag" was already selected
adapter speed: 5000 kHz
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : esp_usb_jtag: serial (F4:12:FA:CE:ED:C4)
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 5000 kHz
Info : JTAG tap: esp32s3.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32s3.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : starting gdb server for esp32s3.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
Reading symbols from /home/binshift/Code/helloworld/.pio/build/esp32s3usbotg/firmware.elf...
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = esp-builtin
PlatformIO: Initializing remote target...
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Ignoring packet error, continuing...
I was told by the CLion support staff that this error is related to not using xtensa-esp32s3-elf-gdb
I am also testing this same code using CLion with Platformio.
As indicated above I then created the launch.jsom for xtensa-esp32s3-elf-gdb
for both PlatformIo in Visual Studio Code and Clion.
I get the following error:
Unable to start debugging . Unexpected GDB output from command "-targer-select remote 127.0.0.1:3333". 127.0.0.1:3333: Connection timed out
I am not the first person to complain about not getting the debugger to work and I have yet to see any given resolution on a working solution.
The Arduino IDE team has been working on their debugger for over two years without a solution either.
It would be nice to have a workable debugger solution.
Thanks