ESP32: Arduino.h not found for debug build with esp prog

I am trying to get the esp prog debugger working with a WEMOS D1 Mini with an ESP32.

I connected everything following these instructions.

I am able to build and upload, both via the esp prog/JTAG as well as USB.

However, once I am trying to start a debug session I get the following error message:

Starting build...
C:/Users/alexa/.platformio/packages/toolchain-xtensa-esp32/bin/xtensa-esp32-elf-gcc.exe -fdiagnostics-color=always -g "C:\Users\alexa\Documents\PlatformIO\Projects\ESP32 BLE Gateway\src\main.cpp" -o "C:\Users\alexa\Documents\PlatformIO\Projects\ESP32 BLE Gateway\src\main.exe" -mlongcalls 
C:\Users\alexa\Documents\PlatformIO\Projects\ESP32 BLE Gateway\src\main.cpp:1:10: fatal error: Arduino.h: No such file or directory
 #include <Arduino.h>
          ^~~~~~~~~~~
compilation terminated.

Build finished with error(s).

This is my platformio.ini:

[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
lib_deps = https://github.com/arduino-libraries/ArduinoBLE.git

monitor_speed = 115200

debug_tool = esp-prog
debug_init_break = tbreak setup
upload_protocol = esp-prog

I tried already deleting the .platformio\packages\framework-arduinoespressif32\cores\esp32 folder as awell as the cache but it did not help.

Any ideas why the debug build is not working?

Nah. You’re pressing the wrong debug button, probably the one located in the upper right corner of the VSCode window. That one goes to a different build system and not via PlatformIO at all.

You need to use the PlatformIO provided debug task “PIO Debug” in the debugging sidebar (left bug and play icon, then again the play icon).

1 Like

Thank you very much! As I did some debugging with other boards before, I did not consider there was a different way to start the debugger.