Seeed Studio ESP32-3C debugging requires esp-prog?

Looking for an expert to clarify something - the documentation states

Seeed Studio XIAO ESP32C3 does not have on-board debug probe and IS NOT READY for debugging. You will need to use/buy one of external probe listed below.

However the chip has on-chip JTAG and the serial pins are directly connected to the USB port. Is this a chip issue or a board issue or a PlatformIO support for this board issue?

thanks

That’s weird because the TRM states on page 742:

30 USBSerial/JTAG Controller (USB_SERIAL_JTAG)

The ESP32-C3 contains an USB Serial/JTAG Controller. This unit can be used to program the SoC’s flash, read program output, as well as attach a debugger to the running program. All of these are possible for any computer with a USB host (’host’ in the rest of this text) without any active external components.

There is also a tutorial available:

I don’t understand why Seeed would blow the JTAG fuse, it makes no sense.

Here is the error message when I try to upload and run the debugger. NOTE I am using default esp-tool for upload, not debugger. My first thing to confirm is that platformIO integrated debugging should work without esp-prog (ie, everything I see says on-chip JTAG should work…). Or maybe I’m missing something - but the debug build and download work fine…

Reading symbols from /home/tony/ESPprojects/ESP32c-Switch/.pio/build/seeed_xiao_esp32c3/firmware.elf…
PlatformIO Unified Debugger → Redirecting...
PlatformIO: debug_tool = cmsis-dap
PlatformIO: Initializing remote target…
Open On-Chip Debugger v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
adapter speed: 5000 kHz

Info : tcl server disabled
Info : telnet server disabled
Error: unable to find a matching CMSIS-DAP device

Error: Unsupported xlen: -1
Error: Unknown target arch!
.pioinit:11: Error in sourced command file:
Remote communication error. Target disconnected.: Connection reset by peer.

Thanks for finding this! I’m going to try to set the platformio settings per the example - I assumed that the board type setting would make these automatic but who knows? I’ll come back with what I find.

Debugging the ESP-C3 via USB works perfectly.
It takes about 30 seconds for the debugging process to start.

Here is a short recording of my debugging session (recorded a few minutes ago):

main.cpp

#include <Arduino.h>

int i=0;

void setup() {
    Serial.begin(115200);
    Serial.println("Hello World");
}

void loop() {
    Serial.println(i++);
    delay(1000);
}

platformio.ini

[env:esp32-c3-devkitm-1]
platform = espressif32
board = esp32-c3-devkitm-1
framework = arduino
monitor_speed = 115200
build_flags = 
  -DARDUINO_USB_CDC_ON_BOOT=1
  -DARDUINO_USB_MODE=1
debug_tool = esp-builtin
debug_init_break = break setup

Note:

Used platform: pioarduino (Arduino 3.0.7 @ esp-idf 5.1.4)
but platform = espressif32 @ 6.9.0 also works fine

Used board: ESP32-C3 SuperMini

Progress but still errors. I explicitly added these items to the platformio.ini file per the tutorial.

debug_tool = esp-builtin
debug_init_break = break setup
debug_server =
$PLATFORMIO_CORE_DIR/packages/tool-openocd-esp32/bin/openocd
-f
$PLATFORMIO_CORE_DIR/packages/tool-openocd-esp32/share/openocd/scripts/board/esp32c3-builtin.cfg

The good news is that it’s connecting.
First time - got an error about protection - per tutorial I hit the reset button and restarted the debugging. Now I always get these errors. What are the USB build flags you are using? I’ll add those and see if it makes a difference.

They won’t make any difference for debugging.

This is just to route the output of Serial.println to the USB Serial (HWCDC).
Without them there won’t be any output on my serial interface because I use the esp32-c3-devkitm-1 in my platformio.ini.

Why do you use this? Do you really need it?
Please show the complete content of your platformio.ini.
Use preformatted-text when posting logs or code.

Which errors exactly?
I can’t see the messages on yous screen

LOL. Nope you can’t, the paste didn’t paste. Changing the build flags forced a complete rebuild so I can start from scratch. I’ll try to paste properly, thank you for your help.

First off - the platform server list in platformio.ini is directly in the tutorial you sent me so I just cloned it. It seems to me that by specifying the board type explicitly I should not need any of these things, but here we are :-).

Here is the error output (hope I paste this correctly)… From the first run. After this per the tutorial I press reset on the board and try to reattach. Similar result.

Reading symbols from /home/tony/ESPprojects/ESP32c-Switch/.pio/build/seeed_xiao_esp32c3/firmware.elf...
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = esp-builtin
PlatformIO: Initializing remote target...
Open 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
Warn : Transport "jtag" was already selected
adapter speed: 5000 kHz

Info : tcl server disabled
Info : telnet server disabled
Info : esp_usb_jtag: serial (64:E8:33:86:10:88)
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 5000 kHz
Error: libusb_bulk_write error: LIBUSB_ERROR_IO
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Error: libusb_bulk_write error: LIBUSB_ERROR_IO
Error: missing data from bitq interface
Error: failed jtag scan: -104
Error: Unsupported DTM version: 8
Warn : target esp32c3 examination failed
Info : starting gdb server for esp32c3 on pipe
Info : accepting 'gdb' connection from pipe
Error: Target not examined yet
Error executing event gdb-attach on target esp32c3:

Warn : No symbols for FreeRTOS!
Error: Target not halted
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response

Here is my platformio.ini incl my build flags for wifi (which is blowing up inside WiFi.begin with an unhandled exception, which is what started this mess…)

[env:seeed_xiao_esp32c3]
platform = espressif32
board = seeed_xiao_esp32c3
framework = arduino
monitor_speed = 115200
upload_speed = 115200
build_type = debug
debug_tool = esp-builtin
debug_init_break = break setup
debug_server = 
   $PLATFORMIO_CORE_DIR/packages/tool-openocd-esp32/bin/openocd
   -f
   $PLATFORMIO_CORE_DIR/packages/tool-openocd-esp32/share/openocd/scripts/board/esp32c3-builtin.cfg
build_flags =
        '-DWIFI="WIFI"'
        '-DMYSSID="theCollective"'
        '-DMYPASSWD="xxxxxxxxx"'
        -DARDUINO_USB_CDC_ON_BOOT=1
        -DARDUINO_USB_MODE=1

Please try this platformio.ini

[env:seeed_xiao_esp32c3]
platform = espressif32 @6.9.0
board = seeed_xiao_esp32c3
framework = arduino
monitor_speed = 115200
debug_tool = esp-builtin
debug_init_break = break setup
build_flags =
  '-DWIFI="WIFI"'
  '-DMYSSID="theCollective"'
  '-DMYPASSWD="xxxxxxxxx"'

It still failed. So I got another board - and it’s entering debug. Bizarre. There must be some sort of defect on that chip - but the program is running with my print statements, it just wouldnt go into debug.

Can you tell me what the “@6.9.0” version of the framework is or point me to some references now that I’m about to start debugging the original wifi problem I hit…

Thanks for the help!!!

tony

please see

Oh - the platformIO document that says this board only will work with an external JTAG - not sure who owns that. I think I found an errata somewhere that implied the first spin of the chip had a JTAG problem - maybe(?) , and maybe one of my boards has one of those??? IDK but just my luck :slight_smile:

Interesting… the 2nd board is now in the same state as the first board. I started a debug session stepping over “serial.begin” and I got an error “duplicate breakpoint” and when I forced break it seems to be in an endless loop - tried to restart the debug session and now this board is dumping the same errors as the first one - the error dump looks the same. Very strange. Any ideas appreciated as I start banging away on this…

Unfortunately this does not contain a link to the document you mention and
Do you mean this one?
https://docs.platformio.org/en/latest/boards/espressif32/seeed_xiao_esp32c3.html

You will always find an ‘edit on GitHub button’ at the top right of the documents where you can improve and correct documents.

Please provide more precise information.
Do you mean this one ?

.pioinit:11: Error in sourced command file:
Remote communication error. Target disconnected.: Connection reset by peer

Just a suggestion, I recently acquired an esp32c3 dev board and installed the esp32-idf plugin to vscode which contained a custom openocd for the esp32c3 jtag which I can confirm works although I’m still in the process of finding memory dump and manipulation functions which I’m sure are there somewhere. So possibly the actual answer is to install the esp32-idf sdk.

This is not a good idea, as it is known that this will lead to incompatibilities that can only be solved by removing the ESP-IDF plugin.

This has already happened many times - see various entries here in the forum.

sorry my bad, I installed platformIO for the ch32v003 and used the vscode esp32-IDF plugin for the development of the esp32C3. I wasn’t aware of the incompatibility with arduino

Unfortunately I had to stop my session and didn’t capture the dump. However, saw the LIBUSB errors etc - it looked like it was the same relative fail mode.

I was using a RPi5 to do a “quick” wifi test, which is blowing up somewhere in the wifi module of the arduino framework and was trying to do a quick debug traceback to see where - nothing has been “quick” so far ;-). Now I think I also need to figure out if the arduino framework will work for for wifi on this board. I am also now wondering if the Pi5 is not fast enough to run the debug or has enough memory to do the debugging, so I’m going to find another computer to try this on again… I’ll post back when I have time to make more progress on it.

thanks for the help so far, really appreciate it.

tony