Building/Debugging on a Board that isn't officially supported/listed in PlatformIO

Hi, first time using ESP32, VS Code, PlatformIO, IDF… but I have debugged an STM32 with Cube IDE (Eclipse?) and OpenOCD/GDB.

The board* isn’t listed when I create a New Project, so I’m not sure if it’s building an appropriate image for my board, or a debugger setup issue (ini, launch tasks, etc) , or maybe if I’m missing some install/setup (compiler flags, OpenOCD/GDB). My PlatformIO.ini looks like :

platform = espressif32
;board = lolin_c3_mini
;board_build.partitions = no_ota.csv
;build_flags = -D BLE_IDE build_type = debug
framework = espidf
debug_tool = esp-builtin
debug_load_mode = manual
debug_init_break = break setup <–tbreak setup?
debug_speed = 500 monitor_speed = 115200
Any suggestions or pointers to a sample IDF project that may work in compiling/debugging on this board?

If you have a framework = espidf application, your entry point is main(), not setup(), that’s for Arduino.

What’s the curent error message when you try to debug?

It successfully builds, but when I try debugging it starts an endless loop of compiling over and over, and a dialog-box says, Waiting for prelaunchtask ‘Pre-Debug’…

I’ve changed the debug_init_break = tbreak app_main , and the environment and target to:
[env:esp32-c3-devkitm-1]
board = esp32-c3-devkitm-1 ;<-- Closest to the ESP32-C3-C3FH4-RGB Board??

I’ve also verified that Device Manager lists: USB JTAG/Serial debug unit and USB Serial Device (COM19)

Looking at the Build terminal, I see a warning, but not sure if this is why it’s endless looping during the debug launch

Reading CMake configuration...
Warning! Flash memory size mismatch detected. Expected 4MB, found 2MB!
Please select a proper value in your `sdkconfig.defaults` or via the `menuconfig` target!
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Linking .pio\build\esp32-c3-devkitm-1\firmware.elf
Retrieving maximum program size .pio\build\esp32-c3-devkitm-1\firmware.elf
Checking size .pio\build\esp32-c3-devkitm-1\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.7% (used 8720 bytes from 327680 bytes)
Flash: [==        ]  16.6% (used 173760 bytes from 1048576 bytes)
======================= [SUCCESS] Took 11.70 seconds ======================= *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task in folder Test: C:\Users\enlit\.platformio\penv\Scripts\platformio.exe run --environment esp32-c3-devkitm-1 

Processing esp32-c3-devkitm-1 (platform: espressif32; board: esp32-c3-devkitm-1; framework: espidf)
----------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-c3-devkitm-1.html
PLATFORM: Espressif 32 (6.9.0) > Espressif ESP32-C3-DevKitM-1
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-builtin) External (cmsis-dap, esp-bridge, esp-builtin, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-espidf @ 3.50301.0 (5.3.1)
 - tool-cmake @ 3.16.4
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-idf @ 1.0.1
 - tool-mconf @ 1.4060000.20190628 (406.0.0)
 - tool-ninja @ 1.9.0
 - tool-openocd-esp32 @ 2.1100.20220706 (11.0)
 - tool-riscv32-esp-elf-gdb @ 11.2.0+20220823
 - tool-xtensa-esp-elf-gdb @ 11.2.0+20230208
 - toolchain-esp32ulp @ 1.23800.240113 (2.38.0)
 - toolchain-riscv32-esp @ 13.2.0+20240530
Reading CMake configuration...
Warning! Flash memory size mismatch detected. Expected 4MB, found 2MB!
Please select a proper value in your `sdkconfig.defaults` or via the `menuconfig` target!
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio\build\esp32-c3-devkitm-1\firmware.elf
Checking size .pio\build\esp32-c3-devkitm-1\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   2.7% (used 8720 bytes from 327680 bytes)
Flash: [==        ]  16.6% (used 173760 bytes from 1048576 bytes)
======================= [SUCCESS] Took 11.27 seconds ======================= *  Terminal will be reused by tasks, press any key to close it. 

When debugging, it should only recompile the firmware in debug mode once, that is, until you make a modification to the firmware code again. Since the framework is ESP-IDF, compiling it will take extremely long.

You can gain some speed ups if you compile your regular project in

build_type = debug

(platformio.ini addition), too. Then, there should not be so much time difference between a successful “Build” and debug starting up.

I would also recommend to remove or deactivate the CMake extension. It’s in the way of the PlatformIO extension when defining tasks, intellisense etc.

Thanks, I changed the build_type, removed the cmake extension, and it seems to get further.

Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND
Error: esp_usb_jtag: could not find or open device!
Error: Unsupported xlen: -1
Error: Unknown target arch!
.pioinit:11: Error in sourced command file:
Remote communication error.  Target disconnected.: No error.

Also, not sure when, but at some point I started getting warning from the i2c file in IDF… a file I’m not using nor did anything I changed. In any case it refused to build successfully until I added this:
build_flags = -Wno-maybe-uninitialized

Can you load libusb or WinUSB drivers for the “USB JTAG/Serial” device so that OpenOCD can actually access it?

https://zadig.akeo.ie/

Zadig shows Interface 0 as using ‘usbser’ and Interface 2 as using WINUSB (v 10.0.19041.1). The version that Zadig can downgrade to is v6.1.7600.16385.

image

Then try install libusb drivers for it.