ESP32c3 debugging

I’m not sure if debugging this board is possible without an ESP-PROG but I’m hoping it can be. I have one of these esp32c3 variants Lolin_c3_mini. C3 mini — WEMOS documentation
It has the d+ and d- pins routed to the USB. When plugging this board into the computer I get two USB JTAG/serial debug devices in device manager.
I’m getting an error with GDB and it wants me to open the source config file but I’m not sure what I’m supposed to put in there. All the documentation I could find is for the ESP PROG or JLINK adapters for the esp32.

Reading symbols from c:.pio\build\esp32c3\firmware.elf…

PlatformIO Unified Debugger → Redirecting...

PlatformIO: debug_tool = custom <— not sure if this is correct, probably not

PlatformIO: Initializing remote target…

.pioinit:13: Error in sourced command file:

:3333: (undocumented errno 138).

Is it even possible to debug straight from the d+d- pins of the C3? I thought I read it was but cannot find that information any more.

I don’t know what to enter in the platformio.ini or launch.json to get it going, not sure if it would be the same as ESP-PROG but I’m thinking not.

Any help at all would be greatly appreciated.

There’s an issue about this at ESP32-C3-DevKitM-1 Debug Support Missing · Issue #651 · platformio/platform-espressif32 · GitHub.

Thank you very much for that info. I’ll keep an eye for any updates to that issue.

Can you do me a favor? When you see that JTAG interface of the ESP32C3, and you open a CLI and execute

pio pkg exec -p tool-openocd-esp32 -c "openocd -f board/esp32c3-builtin.cfg"

what does that output?

(If it says pio pkg is not a command, execute pio upgrade)

Hi.
Here is my listed devices, after connecting the C3 and placing into DFU

Then, after entering the command you mentioned.

This is my platformio.ini

The upstream platform didn’t have the lolin_c3_mini variant for pin information so I just added it from the latest release on GH.

Let me know if there’s anything else I can do to help with this, would really like to get it working.

That’s weird. Can you do pio upgrade --dev and try again?

The upgrade --dev worked
image

Here’s the output from the initial cmd you asked about

Should I be installing the libusb from the Zadig utility?

Oh yes if you can load WinUSB or libusb-win32 drivers for that JTAG interface with Zaidg and see if it cahnges, that would be good.

There’s two interfaces 0 and 2. Should I update both or just one.
Currently
Interface 2 is showing WINUSB (v10.0.19041.1)
Interface 0 is showing usbser (v1.0.0.0)

Hm I think that is the JTAG interface and the other the serial interface, but it already as WinUSB loaded :confused: Try libusb-win32 there.

Here’s device manager now
image

result

Hm nope, still no OpenOCD connection. But now also both interface 0 and 2 are libusb-win32. Does the serial port still exist? Have you tried loading WinUSB drivers?

Nope, I accidently updated the winusb to libusb. I’ll put interface 0 back

It’s uploading again now,
image

Ran the cmd again and it’s the same as the last one jtag_caps descriptor error

This is the device instance path of interface 2 if it helps
USB\VID_303A&PID_1001&MI_02\6&EDDE93&0&0002

Hardware ID’s of USB/JTAG/serial debug unit (Interface 2)
USB\VID_303A&PID_1001&REV_0101&MI_02
USB\VID_303A&PID_1001&MI_02

Hm, well if it’s not accepting WinUSB or LibUSB then I don’t know :confused: Maybe try download the binary releases straight from Releases · espressif/openocd-esp32 · GitHub and execute the

bin\openocd.exe -s share\openocd\scripts -f board/esp32c3-builtin.cfg

command.

C:\openocd-esp32\bin>openocd.exe -s share\openocd\scripts -f board/esp32c3-builtin.cfg
Open On-Chip Debugger v0.11.0-esp32-20211220 (2021-12-20-15:43)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
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
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: libusb_get_string_descriptor_ascii() failed with -5

Doesn’t look good

You can try rightclick → uninstall driver to get back to default drivers + replug device.

I installed the libusbK (v3.1.0.0) driver and got this result in OpenOCD.
On interface 2
Is this better?

C:\openocd-esp32\bin>openocd.exe -s share\openocd\scripts -f board/esp32c3-builtin.cfg
Open On-Chip Debugger v0.11.0-esp32-20211220 (2021-12-20-15:43)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
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
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : esp_usb_jtag: Device found. Base speed 40000KHz, div range 1 to 255
Info : clock speed 40000 kHz
Info : JTAG tap: esp32c3.cpu tap/device found: 0x00005c25 (mfg: 0x612 (Espressif Systems), part: 0x0005, ver: 0x0)
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40101104
Info : starting gdb server for esp32c3 on 3333
Info : Listening on port 3333 for gdb connections