MindMake.COM

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.

idf_arduino_setup_v1.py → PYTHON 3 · 13 KB · VERSION 1

Tested with

What it changes

  1. Adds espressif/arduino-esp32 to main/idf_component.yml.
  2. Adds -Wno-error=missing-field-initializers before project(...) in the root CMakeLists.txt, and -Wno-error=cpp for the Arduino component after it. Without these, warnings in the core break the build because of -Werror.
  3. Sets CONFIG_FREERTOS_HZ=1000 and the two mbedTLS PSK options in sdkconfig and sdkconfig.defaults.
  4. Converts the generated app_main source file from C to C++ and replaces it with a small Arduino skeleton. The original is kept as .bak.
  5. Sets UseRelativePathsOnly in the .vgdbproj file. 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-files query.

How to use it

  1. Create a new ESP-IDF project with the VisualGDB wizard and let the first configuration finish.
  2. Unload the project in Visual Studio, or close Visual Studio entirely, so it cannot overwrite its project file while the script runs.
  3. Copy the script into the project root, next to sdkconfig and the .vgdbproj file, 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.