Reputation: 31
When I attempt to establish a debugging connection between the ESP-IDF extension in Visual Studio Code and my Xiao ESP32-C3. I'm able to compile and flash the device. The code runs normally. When I attempt to start a debugging session, this appears in the output:
C:\Users\XXX\.espressif\tools\openocd-esp32\v0.12.0-esp32-20241016\openocd-esp32\bin\openocd.exe
Info : only one transport option; autoselecting 'jtag'
Info : esp_usb_jtag: VID set to 0x303a and PID to 0x1001 Info : esp_usb_jtag: capabilities descriptor set to 0x2000
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
❌ Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND Error: esp_usb_jtag: could not find or open device! C:\Users\XXX\.espressif\tools\openocd-esp32\v0.12.0-esp32-20241016\openocd-esp32\share\openocd\scripts/target/esp_common.cfg:9: Error: at file "C:\Users\XXX\.espressif\tools\openocd-esp32\v0.12.0-esp32-20241016\openocd-esp32\share\openocd\scripts/target/esp_common.cfg", line 9 Error: [esp32c3] Unsupported DTM version: -1 Error: [esp32c3] Could not identify target type.
As you can see, I'm running on Windows. Here are some more details about the environment:
Windows 11
Visual Studio Code with the ESP-IDF extension 1.9.0.
ESP-IDF version 5.4.0
OpenOCD-ESP v0.12.0
ESP32-C3 chip (via built-in USB-JTAG).
It was easy to find people with the similar issues. Most don't have resolutions, this recent post on Stack Overflow.
Espressif provides good documentation. Here are the main resources I used:
Bottom Line: The OpenOCD server is unable to connect to the JTAG adapter built into the ESP32-C3 on my system. The few people that I found who solved this issue did it by correcting a problem with the USB driver. Using a generic Windows USB driver works. Many used a tool called Zadig.
Here's what I've done:
Confirmed that the ESP32-C3 really has built-in JTAG adapter.
Reviewed the USB configuration using Zadig and Windows Device Manager. The USB driver installed when the the ESP32-C3 was first plugged in is called "USB JTAG/serial debug unit (Interface 2)" and seems correct and up-to-date. It is WINUSB (v10.0.26100.1150). Based on others who have this running, this is the correct "generic" driver. The version is actually a bit newer than these posters used successfully.
According to the Espressif doc, Windows users that get this error should make sure they're using an ESP-IDF version greater than 2.8. I'm using 5.4.
I reviewed the Xaio ESP32-C3 schematic to confirm that the chip's built-in JTAG is actually wired to the D+/D- pins on the USB port. It is. There should be no need to solder another USB port to the JTAG pads on the bottom of the board or use a separate JTAG adapter.
The recent post on Stack Overflow that I linked above is very curious. He is using both Platform IO and VS Code on Windows and experiencing the same issue. He used Zadig to install a libwdi USB driver. Changing drivers got him connected to the board, but showed some new problems. He then updated Platform IO, which updated OpenOCD to version 2.12. This got everything working. Then he rolled the USB driver back and went back to OpenOCD 11 and everything still worked. I'm not sure what to make of this. The libwdi USB driver he used doesn't appear in my Zadig tool (and others who got this working say the winusb.sys works best). I'm currently using OpenOCD 12.0, which is newer than his original and slightly older than his upgraded.
This is a new board, so I presume the eFuse that tells the ESP32-C3 not to use the built-in JTAG is still there. I can't find a way to confirm this.
I'm out of ideas.
Upvotes: 1
Views: 124
Reputation: 31
I got it working by doing what other's did to fix this: Downgrading the Microsoft LibUSB driver from 10.xxx to 6.xxx using Zadig. OpenOCD is now able to connect to the ESP32-C3 and read JTAG data.
I don't know why it works and that makes me uncomfortable. There could be a bug in OpenOCD or perhaps LibUSB lost functionality.
I was resistant to this fix for a couple reasons. In general, newer driver versions do everything their predecessors did with fewer bugs. I've also had serious problems show up after Windows updates in systems running old, version-mismatched drivers.
Upvotes: 2