DOWNLOAD · VISUALGDB
Arduino-ESP32 as an ESP-IDF component
VisualGDB's Arduino project wizard does not reliably produce a debuggable project with recent Arduino-ESP32 core versions. The alternative is to use the Arduino core as a component inside a plain ESP-IDF project. That works, but it needs a handful of changes that are easy to get wrong and tedious to repeat for every new project.
This script applies all of them to a freshly generated VisualGDB ESP-IDF project. It can be run more than once and keeps a .bak copy of every file it touches.
Tested with
- VisualGDB 6.1, ESP-IDF 6.1.0
- Arduino-ESP32 core 4.0.0-rc1
- ESP32 and ESP32-S3, wizard samples blink and hello_world
- Python 3 on the machine running the script
What it changes
- Adds
espressif/arduino-esp32tomain/idf_component.yml. - Adds
-Wno-error=missing-field-initializersbeforeproject(...)in the rootCMakeLists.txt, and-Wno-error=cppfor the Arduino component after it. Without these, warnings in the core break the build because of-Werror. - Sets
CONFIG_FREERTOS_HZ=1000and the two mbedTLS PSK options insdkconfigandsdkconfig.defaults. - Converts the generated
app_mainsource file from C to C++ and replaces it with a small Arduino skeleton. The original is kept as.bak. - Sets
UseRelativePathsOnlyin the.vgdbprojfile. This is the setting called Use file names only when setting breakpoints in Advanced GDB Settings — without it, Visual Studio crashes on startup of a debug session, because the source file list of an Arduino-based project is too large for the-file-list-exec-source-filesquery.
How to use it
- Create a new ESP-IDF project with the VisualGDB wizard and let the first configuration finish.
- Unload the project in Visual Studio, or close Visual Studio entirely, so it cannot overwrite its project file while the script runs.
- Copy the script into the project root, next to
sdkconfigand the.vgdbprojfile, then run it:
cd /d D:\path\to\project
python idf_arduino_setup_v1.py
A different folder can be passed as an argument instead. Reload the project afterwards and build it — the first build downloads the Arduino core and takes noticeably longer.
The script modifies files in your project folder. It writes a .bak copy of each one before the first change, but please use it on a fresh project rather than on work you care about. Provided as is, without any warranty. Feedback is welcome by mail.