espressif / idf-installer

ESP IDF Windows Installer
https://dl.espressif.com/dl/esp-idf/
101 stars 21 forks source link

ESP32-C3 LIBUSB error (openocd, probe.rs) (IDFGH-7149) #133

Closed TheButlah closed 1 year ago

TheButlah commented 2 years ago

Environment

Problem Description

I cannot open the built-in USB interface with LIBUSB, no matter whether I use the espressif provided drivers, default windows, or zadig drivers (I tried every combo).

Expected Behavior

I can use libusb's open function on the device. This would allow me to use probe.rs.

Actual Behavior

Depending on which drivers I use (WinUSB, libusbk, usbser, espressif), I get any of the following errors: LIBUSB_ERROR_NOT_FOUND LIBUSB_ERROR_ACCESS

I may have also gotten these, but I'm not sure: LIBUSB_ERROR_NOT_FOUND LIBUSB_ERROR_NOT_SUPPORTED

The strangest part was that when I unchecked "Ignore Hubs or Composite Parents" in Zadig, and made the composite parent use WinUSB, I actually successfully opened the device with libusb, which meant that the probe.rs debugger worked! The issue with this approach was that it removed the two USBCDC interfaces and now it was only a WinUSB interface, which meant no COM port. So I was unable to flash the device at all anymore (at least using the UART setting in esp-idf vscode).

Steps to reproduce

Have a board using the built-in JTAG/Serial over USB (aka no UART chip, just uses D+ D- pins on esp32c3 directly)

Try using either openocd (which uses libusb), probe.rs debugger (uses libusb), or maybe manually try opening the device with libusb.

Code to reproduce this issue

cargo.toml should use probe-rs = "0.12.0"

fn main() {
    // Get a list of all available debug probes.
    let probes = probe_rs::Probe::list_all();
    println!("{probes:?}");

    // Use the first probe found.
    let probe = probes[0].open().unwrap();
}

Debug Logs

[ESP JTAG (VID: 303a, PID: 1001, EspJtag)]
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ProbeCouldNotBeCreated(Rusb(NotFound))', probe\src\main.rs:7:34
stack backtrace:
   0:     0x7ff7a678ae8f - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ff7a678ae8f - std::backtrace_rs::backtrace::trace_unsynchronized        
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff7a678ae8f - std::sys_common::backtrace::_print_fmt
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\sys_common\backtrace.rs:67
   3:     0x7ff7a678ae8f - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\sys_common\backtrace.rs:46
   4:     0x7ff7a679fffa - core::fmt::write
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\core\src\fmt\mod.rs:1168
   5:     0x7ff7a6788078 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\io\mod.rs:1660
   6:     0x7ff7a678d18b - std::sys_common::backtrace::_print
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\sys_common\backtrace.rs:49
   7:     0x7ff7a678d18b - std::sys_common::backtrace::print
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\sys_common\backtrace.rs:36
   8:     0x7ff7a678d18b - std::panicking::default_hook::closure$1
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:211
   9:     0x7ff7a678cc84 - std::panicking::default_hook
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:228
  10:     0x7ff7a678d68c - std::panicking::rust_panic_with_hook
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:606
  11:     0x7ff7a678d54b - std::panicking::begin_panic_handler::closure$0
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:502
  12:     0x7ff7a678b7d7 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure$0,never$>
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\sys_common\backtrace.rs:139
  13:     0x7ff7a678d249 - std::panicking::begin_panic_handler
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:498
  14:     0x7ff7a67c6c10 - core::panicking::panic_fmt
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\core\src\panicking.rs:116
  15:     0x7ff7a67c6d23 - core::result::unwrap_failed
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\core\src\result.rs:1690
  16:     0x7ff7a663174d - enum$<core::result::Result<probe_rs::probe::Probe,enum$<probe_rs::probe::DebugProbeError> > >::unwrap<probe_rs::probe::Probe,enum$<probe_rs::probe::DebugProbeError> >
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\library\core\src\result.rs:1018
  17:     0x7ff7a66310d0 - probe::main
                               at D:\Ryan\Programming\esp32c3_experiments\probe\src\main.rs:7
  18:     0x7ff7a663156b - core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\library\core\src\ops\function.rs:227
  19:     0x7ff7a663164b - std::sys_common::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\library\std\src\sys_common\backtrace.rs:123
  20:     0x7ff7a6631441 - std::rt::lang_start::closure$0<tuple$<> >
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\library\std\src\rt.rs:145
  21:     0x7ff7a678a6ef - core::ops::function::impls::impl$2::call_once
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\library\core\src\ops\function.rs:259
  22:     0x7ff7a678a6ef - std::panicking::try::do_call
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:406
  23:     0x7ff7a678a6ef - std::panicking::try
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:370
  24:     0x7ff7a678a6ef - std::panic::catch_unwind
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panic.rs:133
  25:     0x7ff7a678a6ef - std::rt::lang_start_internal::closure$2
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\rt.rs:128
  26:     0x7ff7a678a6ef - std::panicking::try::do_call
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:406
  27:     0x7ff7a678a6ef - std::panicking::try
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:370
  28:     0x7ff7a678a6ef - std::panic::catch_unwind
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panic.rs:133
  29:     0x7ff7a678a6ef - std::rt::lang_start_internal
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\rt.rs:128
  30:     0x7ff7a663140f - std::rt::lang_start<tuple$<> >
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\library\std\src\rt.rs:144
  31:     0x7ff7a6631136 - main
  32:     0x7ff7a67c5160 - invoke_main
                               at d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  33:     0x7ff7a67c5160 - __scrt_common_main_seh
                               at d:\a01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  34:     0x7ffaaf427034 - BaseThreadInitThunk
  35:     0x7ffaaf562651 - RtlUserThreadStart

See also

My conversation on the probe-rs Matrix group where I debugged probe.rs and determined that it was a driver issue with libusb.

My conversation on the esp-rs matrix group where I troubleshooted the espressif provided drivers.

TheButlah commented 2 years ago

Here is the error from openocd when I try to start it:

debug_level: 2

adapter speed: 20000 kHz

WARNING: boards/esp32-wrover.cfg is deprecated, and may be removed in a future release.
         If your board is ESP32-WROVER-KIT, use board/esp32-wrover-kit-1.8v.cfg instead.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
❌ Error: no device found
❌ Error: unable to open ftdi device with vid 0403, pid 6010, description '*', serial '*' at bus location '*'
❌ Error: no device found
❌ Error: unable to open ftdi device with vid 0403, pid 6014, description '*', serial '*' at bus location '*'

Assertion failed!

Program: D:\Ryan\.espressif\tools\openocd-esp32\v0.11.0-esp32-20211220\openocd-esp32\bin\openocd.exe
File: ../src/jtag/core.c, Line 343

Expression: jtag_trst == 0
[Stopped] : OpenOCD Server
dobairoland commented 2 years ago

Hi. Have you used the Windows tool installer (https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/windows-setup.html#esp-idf-tools-installer)? It should be able to install all the necessary drivers. But before that, please remove all of the drivers you installed earlier.

As for openocd, you used the wrong cfg file. It should be board/esp32c3-builtin.cfg.

More information: https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/api-guides/jtag-debugging/index.html

igrr commented 2 years ago

Is it okay if I move this issue into openocd-esp32 repository? Given that both openocd-esp32 and probe.rs fail, this is likely a hardware issue, and esp-idf codebase is likely not yet involved.

TheButlah commented 2 years ago

sure, feel free to move it @igrr. @dobairoland, yes, I tried with every combination of esp windows installer, idf-env, and all four zadig driver options. I also made sure to uninstall drivers too when I tried new options. I tried every possible permutation for at least 3 hours :)

erhankur commented 2 years ago

@TheButlah Did you try with the correct cfg file as Roland mentioned. board/esp32c3-builtin.cfg

TheButlah commented 2 years ago

The issue is that libusb_open did not work, this is not specifically an openocd issue as it occurs in probe-rs as well, and when using libusb directly. I think it's a driver level issue I believe.

Would the board/esp32c3-builtin.cfg have anything to do with that?

igrr commented 2 years ago

It may help, since the device OpenOCD will be trying to open (VID/PID) is specified in the config file. The one you have been using is for an FT2233H based board, so VID/PID pair is different.

TheButlah commented 2 years ago

Trying to test openocd using the cfg file y'all suggested. I click "open esp-idf terminal" in the vscode extension, and the type openocd. I get:

PS D:\Ryan\Programming\esp32c3_experiments\espidf_example> openocd
Open On-Chip Debugger  v0.11.0-esp32-20211220 (2021-12-20-15:43)      
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:26: Error: Can't find openocd.cfg
in procedure 'script' 
at file "embedded:startup.tcl", line 26
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Error: Debug Adapter has to be specified, see "adapter driver" command
embedded:startup.tcl:26: Error:        
in procedure 'script' 
at file "embedded:startup.tcl", line 26

I'm also not sure how to use the cfg file. I was using libusb directly in the original issue I filed, and launched openocd through vscode.

TheButlah commented 2 years ago

I see two hardware devices that belong to my board: image image

This is what openocd gives when trying to start it through the vscode button on the toolbar. Note that it is different from the first error message I posted. I may have set the wrong board target at that time, but this time I can confirm that it is targeting the ESP32-C3, and the flash type is JTAG:

Open On-Chip Debugger  v0.11.0-esp32-20211220 (2021-12-20-15:43)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

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_open() failed❌  with LIBUSB_ERROR_NOT_SUPPORTED
Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND
❌ Error: esp_usb_jtag: could not find or open device!

[Stopped] : OpenOCD Server

I installed all the components except the IDE itself through this installer (aka I am running espressif's drivers).

Note that the VID and PIDs match the ids found in windows device manager.

TheButlah commented 2 years ago

Probe-rs also fails with LIBUSB_ERROR_NOT_FOUND. You can see the following when it tried to call libusb_open on the given device descriptor (note that device descriptor values are in decimal not hex, whereas debug printout is hex. The PID and VID are equivalent.):

DeviceDescriptor { bLength: 18, bDescriptorType: 1, bcdUSB: 512, bDeviceClass: 239, bDeviceSubClass: 2, bDeviceProtocol: 1, bMaxPacketSize: 64, idVendor: 12346, idProduct: 4097, bcdDevice: 257, iManufacturer: 1, iProduct: 2, iSerialNumber: 3, bNumConfigurations: 1 }
 DEBUG probe_rs::probe::espusbjtag::protocol > Failed to read serial number of device 303a:1001 : Entity not found
TheButlah commented 2 years ago

WHAT??? It magically fixed itself somehow.

Now, openocd attaches, and also the device still has a COM port, and also probe-rs via libusb attaches. How???

Here is what I did: I went back to messing with zadig drivers. First I tried replacing the usbser driver (the image I posted with the hardware ID ending in MI_00, it was listed as a COM device) with WinUSB via zadig. I tried testing it out with probe-rs - no dice, it still gave a LIBUSB_ERROR_NOT_FOUND. So I reverted the MI_00 device to the usbser driver inside of zadig - this is what it was using originally.

Next I tried installing winusb on the other device (the second image, listed as MI_02). Didn't work. I tried libusbK too. Didn't work, this time crashing the program with an access violation. So I went into device manager and uninstalled it, like this: image This reverted the driver to the espressif one: image Its important to note that to the absolute best of my knowledge, this device was already using the espressif driver. And yet, for some reason, it started working. I can start openocd, and the example probe-rs code runs. I can also still flash the device, because there is still the COM device listed too.

OpenOCD:

Open On-Chip Debugger  v0.11.0-esp32-20211220 (2021-12-20-15:43)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
debug_level: 2

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_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
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

Probe-rs:

 DEBUG probe_rs::probe::cmsisdap::tools > Searching for CMSIS-DAP probes using libusb
 DEBUG probe_rs::probe::cmsisdap::tools > Found 0 CMSIS-DAP probes using libusb, searching HID
 DEBUG probe_rs::probe::cmsisdap::tools > Found 0 CMSIS-DAP probes total
 DEBUG jaylink                          > libusb 1.0.24.11584
 DEBUG jaylink                          > libusb has capability API: true       
 DEBUG jaylink                          > libusb has HID access: true
 DEBUG jaylink                          > libusb has hotplug support: false     
 DEBUG jaylink                          > libusb can detach kernel driver: false
DeviceDescriptor { bLength: 18, bDescriptorType: 1, bcdUSB: 512, bDeviceClass: 239, bDeviceSubClass: 2, bDeviceProtocol: 1, bMaxPacketSize: 64, idVendor: 12346, idProduct: 4097, bcdDevice: 257, iManufacturer: 1, iProduct: 2, iSerialNumber: 3, bNumConfigurations: 1 }
[ESP JTAG (VID: 303a, PID: 1001, Serial: 84:F7:03:33:50:60, EspJtag)]
 TRACE probe_rs::probe::cmsisdap::tools > Attempting to open device matching 303a:1001:84:F7:03:33:50:60
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 002 Device 002: ID 0b05:18f3
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 001 Device 001: ID 046d:085e
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 002 Device 000: ID 1022:149c
 TRACE probe_rs::probe::cmsisdap::tools > Error opening: NotSupported
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 003 Device 002: ID 1532:0086
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 001 Device 005: ID 0bda:5418
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 001 Device 000: ID 1022:149c
 TRACE probe_rs::probe::cmsisdap::tools > Error opening: NotSupported
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 003 Device 003: ID 2109:2815
 TRACE probe_rs::probe::cmsisdap::tools > Error opening: NotSupported
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 001 Device 006: ID 303a:1001
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 003 Device 001: ID 2109:0815
 TRACE probe_rs::probe::cmsisdap::tools > Error opening: NotSupported
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 002 Device 001: ID 8087:0025
 TRACE probe_rs::probe::cmsisdap::tools > Error opening: NotSupported
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 003 Device 000: ID 1022:149c
 TRACE probe_rs::probe::cmsisdap::tools > Error opening: NotSupported
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 001 Device 002: ID 0bda:0411
 TRACE probe_rs::probe::cmsisdap::tools > Error opening: NotSupported
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 001 Device 003: ID 0bda:5411
 TRACE probe_rs::probe::cmsisdap::tools > Error opening: NotSupported
 TRACE probe_rs::probe::cmsisdap::tools > Trying device Bus 001 Device 004: ID 1209:2201
 DEBUG probe_rs::probe::cmsisdap::tools > Attempting to open 303a:1001 in CMSIS-DAP v1 mode
 DEBUG probe_rs::probe::stlink::usb_interface > Acquired libusb context.
 DEBUG probe_rs::probe::espusbjtag::protocol  > Acquired libusb context.
 DEBUG probe_rs::probe::espusbjtag::protocol  > Aquired handle for probe
 DEBUG probe_rs::probe::espusbjtag::protocol  > Active config descriptor: ConfigDescriptor { bLength: 9, bDescriptorType: 2, wTotalLength: 98, bNumInterfaces: 3, bConfigurationValue: 1, iConfiguration: 0, bmAttributes: 192, bMaxPower: 250, extra: Some([8, 11, 0, 2, 2, 2, 0, 0]) }
 DEBUG probe_rs::probe::espusbjtag::protocol  > Device descriptor: DeviceDescriptor { bLength: 18, bDescriptorType: 1, bcdUSB: 512, bDeviceClass: 239, bDeviceSubClass: 2, bDeviceProtocol: 1, bMaxPacketSize: 64, idVendor: 12346, idProduct: 4097, bcdDevice: 257, iManufacturer: 1, iProduct: 2, iSerialNumber: 3, bNumConfigurations: 1 }
 TRACE probe_rs::probe::espusbjtag::protocol  > Interface 0
 TRACE probe_rs::probe::espusbjtag::protocol  > Interface 1
 TRACE probe_rs::probe::espusbjtag::protocol  > Interface 2
 TRACE probe_rs::probe::espusbjtag::protocol  > Endpoint 2: 2
 TRACE probe_rs::probe::espusbjtag::protocol  > Endpoint 3: 131
 DEBUG probe_rs::probe::espusbjtag::protocol  > Claiming interface 2 with IN EP 131 and OUT EP 2.
 DEBUG probe_rs::probe::espusbjtag::protocol  > [1, 10, 1, 8, 64, 31, 1, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
 DEBUG probe_rs::probe::espusbjtag::protocol  > Protocol version: 1
 DEBUG probe_rs::probe::espusbjtag::protocol  > Succesfully attached to ESP USB JTAG.
TheButlah commented 2 years ago

I've gone ahead and uninstalled all the espressif drivers, to test if the issue is the use of the default windows ones. As expected, the default usbser driver + default windows-provided WinUSB fails.

To clarify, this is what I mean by the default windows WinUSB: image

This causes openocd and probe-rs to fail in the previously discussed ways, since libusb cannot open the device.

The problem then is that when I try to install the espressif drivers, it doesn't actually replace the windows one. I use the windows installer, and have everything unselected except drivers, since the rest of esp-idf is still installed: image image Installation almost instantly finishes, and yet, the windows driver remains, not the espressif one.

How do I get the espressif driver for device with VID: 303A, PID: 1001, MI_02 (does that mean interface 2?). This is the second device, from this message.

TheButlah commented 2 years ago

OK, I can install the WinUSB driver through zadig, instead of espressif's installer. This is an acceptable workaround. For those coming across this in the future, be sure that your drivers look like this:

Device 1: USB Serial image This device will remain as the default windows usbser driver, we shouldn't change it.

Device 2: Regular USB image note that if it shows its signed by espressif instead of libwdi, thats fine, it means the espressif installer worked and you don't need zadig.

This second device is the one that needs to be installed with Zadig. I used WinUSB as the driver. Be sure you select "install driver" instead of "install WCID driver" in the dropdown. It should look like this: image

TheButlah commented 2 years ago

@igrr I think this confirms that the issue is actually with the espressif driver installer, in some cases it doesn't overwrite the windows default driver with the libwdi one.

I would probably transfer back to esp-idf

georgik commented 2 years ago

@TheButlah Thank you for reporting the problem. We will investigate it little bit further.

There are few important things to keep in mind when dealing with Windows drivers.

If the driver is still not applied correctly, please use SysProgs USB Tools to switch/rollback the driver: https://visualgdb.com/UsbDriverTool/

After each change make sure to unplug and plug the device. In some cases it might be necessary to reboot the computer (often in case of pending system updates)

The logic for deploying the driver is written in Rust: https://github.com/espressif/idf-env/blob/main/src/driver.rs#L117

 unsafe {
        // https://docs.microsoft.com/en-us/windows/win32/api/setupapi/nf-setupapi-setupcopyoeminfw
        let result = winapi::um::setupapi::SetupCopyOEMInfW(

We welcome any suggestion for the improvement. Probably detection of incorrect driver might help to resolve the situation.

Ooyekunle commented 2 years ago

@igrr or anyone. Could you please help with this openocd issue I have been having.

Development Kit: ESP32-C3 mini Devkit REV 3?
Module or chip used: ESP32-C3 mini
Debug Adapter: Built in
OpenOCD version: Current master branch
Operating System: Windows
Using an IDE?: VS code
ESP-IDF version: current master branch

Launching the openocd server from the vs code icon at the base of the ID

I have just been running into this issue whenever I try to debug using openocd. It's so frustrating.

Open On-Chip Debugger v0.11.0-esp32-20211220 (2021-12-20-15:43) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html debug_level: 2

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: esp_usb_jtag: could not find or open device!

Ooyekunle commented 2 years ago

---------------------------------------------- ESP-IDF Extension for Visual Studio Code report --------------------------------------------- OS win32 x64 10.0.22000 System environment variable IDF_PYTHON_ENV_PATH undefined System environment variable PATH C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Common Files\Pulse Secure\VC142.CRT\X64\;C:\Program Files (x86)\Common Files\Pulse Secure\VC142.CRT\X86\;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X64\;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X86\;C:\MinGW\bin;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Users\leksy\AppData\Local\Microsoft\WindowsApps;C:\Users\leksy\AppData\Local\Programs\Microsoft VS Code\bin;C:\MinGW\bin; System environment variable PYTHON undefined Visual Studio Code version 1.67.2 Visual Studio Code language en Visual Studio Code shell C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe ESP-IDF Extension version 1.4.0 ---------------------------------------------------- Extension configuration settings ------------------------------------------------------ ESP-ADF Path (idf.espAdfPath) ${env:ADF_PATH} ESP-IDF Path (idf.espIdfPath) C:\Users\leksy\esp\esp-idf ESP-MDF Path (idf.espMdfPath) ${env:MDF_PATH} Custom extra paths (idf.customExtraPaths) C:\Espressif\tools\xtensa-esp32-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32-elf\bin;C:\Espressif\tools\xtensa-esp32s2-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32s2-elf\bin;C:\Espressif\tools\xtensa-esp32s3-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32s3-elf\bin;C:\Espressif\tools\riscv32-esp-elf\esp-2021r2-patch3-8.4.0\riscv32-esp-elf\bin;C:\Espressif\tools\esp32ulp-elf\2.28.51-esp-20191205\esp32ulp-elf-binutils\bin;C:\Espressif\tools\esp32s2ulp-elf\2.28.51-esp-20191205\esp32s2ulp-elf-binutils\bin;C:\Espressif\tools\cmake\3.20.3\bin;C:\Espressif\tools\openocd-esp32\v0.11.0-esp32-20211220\openocd-esp32\bin;C:\Espressif\tools\ninja\1.10.2;C:\Espressif\tools\idf-exe\1.0.3;C:\Espressif\tools\ccache\4.3\ccache-4.3-windows-64;C:\Espressif\tools\dfu-util\0.9\dfu-util-0.9-win64 Custom extra vars (idf.customExtraVars) {"OPENOCD_SCRIPTS":"C:\Espressif\tools\openocd-esp32\v0.11.0-esp32-20211220/openocd-esp32/share/openocd/scripts","IDF_CCACHE_ENABLE":"1"} Virtual env Python Path (idf.pythonBinPath) C:\Espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe Serial port (idf.port) COM1 OpenOCD Configs (idf.openOcdConfigs) board/esp32c3-builtin.cfg ESP-IDF Tools Path (idf.toolsPath) C:\Espressif Git Path (idf.gitPath) C:\Espressif\tools\idf-git\2.30.1\cmd\git.exe -------------------------------------------------------- Configurations access ------------------------------------------------------------- Access to ESP-ADF Path (idf.espAdfPath) false Access to ESP-IDF Path (idf.espIdfPath) true Access to ESP-MDF Path (idf.espMdfPath) false Access to ESP-IDF Custom extra paths Access to C:\Espressif\tools\xtensa-esp32-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32-elf\bin: true Access to C:\Espressif\tools\xtensa-esp32s2-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32s2-elf\bin: true Access to C:\Espressif\tools\xtensa-esp32s3-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32s3-elf\bin: true Access to C:\Espressif\tools\riscv32-esp-elf\esp-2021r2-patch3-8.4.0\riscv32-esp-elf\bin: true Access to C:\Espressif\tools\esp32ulp-elf\2.28.51-esp-20191205\esp32ulp-elf-binutils\bin: true Access to C:\Espressif\tools\esp32s2ulp-elf\2.28.51-esp-20191205\esp32s2ulp-elf-binutils\bin: true Access to C:\Espressif\tools\cmake\3.20.3\bin: true Access to C:\Espressif\tools\openocd-esp32\v0.11.0-esp32-20211220\openocd-esp32\bin: true Access to C:\Espressif\tools\ninja\1.10.2: true Access to C:\Espressif\tools\idf-exe\1.0.3: true Access to C:\Espressif\tools\ccache\4.3\ccache-4.3-windows-64: true Access to C:\Espressif\tools\dfu-util\0.9\dfu-util-0.9-win64: true Access to Virtual env Python Path (idf.pythonBinPath) true Access to CMake in environment PATH undefined Access to Ninja in environment PATH undefined Access to ESP-IDF Tools Path (idf.toolsPath) true ----------------------------------------------------------- Executables Versions ----------------------------------------------------------- Git version 2.30.1.windows.1 ESP-IDF version 4.4.1 Python version 3.8.7 Python's pip version 22.1.1 -------------------------------------------------- Python packages in idf.pythonBinPath ---------------------------------------------------- bitstring version: 3.1.9 Brotli version: 1.0.9 certifi version: 2022.5.18.1 cffi version: 1.15.0 charset-normalizer version: 2.0.12 click version: 8.1.3 colorama version: 0.4.4 construct version: 2.10.54 contextlib2 version: 21.6.0 cryptography version: 37.0.2 ecdsa version: 0.17.0 esp-windows-curses version: 0.1 Flask version: 0.12.5 Flask-Compress version: 1.12 Flask-SocketIO version: 2.9.6 future version: 0.18.2 gcovr version: 5.1 gdbgui version: 0.13.2.0 gevent version: 1.5.0 greenlet version: 1.1.2 idf-component-manager version: 1.1.0 idna version: 3.3 itsdangerous version: 2.0.1 Jinja2 version: 3.0.3 kconfiglib version: 13.7.1 lxml version: 4.8.0 MarkupSafe version: 2.1.1 pip version: 22.1.1 psutil version: 5.9.1 pycparser version: 2.21 pyelftools version: 0.28 pygdbmi version: 0.9.0.2 Pygments version: 2.12.0 pyparsing version: 2.3.1 pyserial version: 3.5 python-engineio version: 3.14.2 python-socketio version: 4.6.1 pywin32 version: 304 PyYAML version: 6.0 reedsolo version: 1.5.4 requests version: 2.27.1 requests-toolbelt version: 0.9.1 schema version: 0.7.5 setuptools version: 62.3.2 six version: 1.16.0 tqdm version: 4.64.0 urllib3 version: 1.26.9 websocket-client version: 1.3.2 Werkzeug version: 0.16.1 wheel version: 0.36.2 windows-curses version: 2.3.0 xmlrunner version: 1.7.7 ---------------------------------------------------- Check ESP-IDF python requirements.txt ------------------------------------------------- Check ESP-IDF Python packages Python requirements from C:\Users\leksy\esp\esp-idf\requirements.txt are satisfied. ---------------------------------------------------- Check extension requirements.txt ------------------------------------------------------ Check Extension Python packages Python requirements from c:\Users\leksy.vscode\extensions\espressif.esp-idf-extension-1.4.0\requirements.txt are satisfied. ---------------------------------------------------- Check ESP-IDF debug adapter requirements.txt ------------------------------------------ Check Debug AdapterPython packages Python requirements from c:\Users\leksy.vscode\extensions\espressif.esp-idf-extension-1.4.0\esp_debug_adapter\requirements.txt are satisfied. ---------------------------------------------------- Visual Studio Code launch.json -------------------------------------------------------- { "version": "0.2.0", "configurations": [ { "type": "espidf", "name": "Launch", "request": "launch" } ] } ---------------------------------------------------- Visual Studio Code c_cpp_properties.json ---------------------------------------------- { "configurations": [ { "name": "ESP-IDF", "compilerPath": "C:\Espressif\tools\riscv32-esp-elf\esp-2021r2-patch3-8.4.0\riscv32-esp-elf\bin\riscv32-esp-elf-gcc.exe", "cStandard": "c11", "cppStandard": "c++17", "includePath": [ "${config:idf.espIdfPath}/components/", "${config:idf.espIdfPathWin}/components/", "${config:idf.espAdfPath}/components/", "${config:idf.espAdfPathWin}/components/", "${workspaceFolder}/" ], "browse": { "path": [ "${config:idf.espIdfPath}/components", "${config:idf.espIdfPathWin}/components", "${config:idf.espAdfPath}/components/", "${config:idf.espAdfPathWin}/components/**", "${workspaceFolder}" ], "limitSymbolsToIncludedHeaders": false } } ], "version": 4 }


georgik commented 2 years ago

@Ooyekunle Do you have the board with JTAG or without JTAG? Please open https://visualgdb.com/UsbDriverTool/ and check status? You should see:

USB Serial Device 303A, 1001, 01
USB JTAG Unit 303A, 1001, 02

If the device with 02 is something different, right click the device and choose WinUSB, this will change the driver.

If you do not see any device 02, then you have board without JTAG and it's not possible to debug it. The only option is to connect ESP-Prog.

Ooyekunle commented 2 years ago

@georgik How do I check status. Do you mean check the status on the website or download the tool and check status?

Thanks

georgik commented 2 years ago

@Ooyekunle Please, download the tool. Install the tool. Run the tool. You'll see list of USB devices. Connect the board and new entries should appear in the list. Compare them with the configuration:

USB Serial Device 303A, 1001, 01
USB JTAG Unit 303A, 1001, 02
Ooyekunle commented 2 years ago

image

Ooyekunle commented 2 years ago

@georgik is there ways I can check the board rev that I have and I was under the impression that all the boards came with internal JTAG debugger. Are there any revision that do not have the JTAG debugger built in our this is just an internal HW problem. Tough luck?

georgik commented 2 years ago

@Ooyekunle The screenshot for produced before or after connecting the device?

There is no 303A, 1001, 01. So the system does not recognize the device. Do you use USB-A to USB-mini cable or USB-C to USB-mini? Please try also different cable.

I recommend to hit Windows Start, type: Device Manager, hit Enter, click View, click Show hidden devices. Check whether the list does not contain a device with error mark. Check if you can see a device in section Ports (COM & LPT).

Also run Powershell and type mode to get list of all COM ports in the system.

Ooyekunle commented 2 years ago

image

@georgik So with the USB connection. I can see it's using COM3 port. I have both the USB connection via COM3 and the other breakout connection for debugging according to this https://visualgdb.com/tutorials/esp32/esp32-c3/

Ooyekunle commented 2 years ago

@georgik image

This is the device that shows up i n the usbdriver tool when I unplugged and plugged the USB according to the connection in this website https://visualgdb.com/tutorials/esp32/esp32-c3/

Ooyekunle commented 2 years ago

B619ADC0-4717-4830-A2A2-4BF320CEC61C

I have both connections hooked up.

georgik commented 2 years ago

That looks like ESP32-C3 without JTAG which is visible as Silicon Labs CP210x USB to UART Bridge 10C4, EA60. Please, run in activated ESP-IDF: idf.py build flash monitor This should give you the revision of the board when monitor is starting.

If JTAG is not present you can use:

Here are instructions from manual: Debugging through the USB interface implemented in ESP32-C3 requires to have a chip with revision 3 or newer. Please use other debugging options (e.g. with ESP-Prog) for chip revision 1 and 2. The easiest way to determine the chip revision is to look for the Chip is ESP32-C3 (revision 3) message near the end of a successful chip flashing done by idf.py flash.

Ooyekunle commented 2 years ago

image

Ooyekunle commented 2 years ago

@georgik This was the console output when I flashed the device. Where can I tell what the revision is?

image

igrr commented 2 years ago

Based on VID:PID pair 067B:2303, you have a development board with a PL2303 USB-Serial adapter (perhaps ESP-C3-32S-Kit?) The drivers for PL2303 are available here: https://www.prolific.com.tw/US/ShowProduct.aspx?p_id=225&pcid=41.

Edit: sorry, I have missed the photo of the setup. The development board is indeed one with CP2102. I think the issue is with your USB cable. What you have is probably not just a USB cable, but a USB-UART cable with PL2303 built in. Like this one: https://www.robotistan.com/pl2303-usb-ttl-serial-converter-cable. This cable contains a USB-UART converter chip, so the white & green wires coming out of it aren't actually USB D+ and D-, they are UART TX and RX.

You need to find a different cable, which is a simple USB cable without any chips inside, like this one: https://www.adafruit.com/product/4448.

Ooyekunle commented 2 years ago

@igrr Does this mean I can’t use the on-chip tag to debug or there’s a chance that I can make it work. If I download the driver, is it going to work or the board Rev just doesn’t support debugging?

thanks @georgik and @igrr

igrr commented 2 years ago

@Ooyekunle I think you can, you just need the correct USB cable. I have just edited my comment.

Ooyekunle commented 2 years ago

@igrr Do you mean the correct USB cable driver or the correct usb cable itself? Where can I get the correct usb cable ?

igrr commented 2 years ago

I meant "correct USB cable".

I think the USB cable you are using is actually a so-called USB-TTL cable, like the one offered here: https://www.robotistan.com/pl2303-usb-ttl-serial-converter-cable. Could you please confirm this? (If you remember where you got the cable from, you can post the link to the product.)

The cable you need is a simple USB cable without any conversion circuits inside. https://www.adafruit.com/product/4448 is one example. You can also make such a cable yourself, if you cut a normal USB A-microB cable in half and solder some dupont wires to the half which has a USB A plug on it.

Ooyekunle commented 2 years ago

The cable came with this ti MCU https://www.ti.com/tool/CC3200-LAUNCHXL (for the USB cable to the port of the Devkit) while the one used for the wiring is this one https://www.amazon.com/DGZZI-PL2303TA-Console-Serial-Raspberry/dp/B07W42V16T/ref=asc_df_B07W42V16T/?tag=hyprod-20&linkCode=df0&hvadid=583376942549&hvpos=&hvnetw=g&hvrand=13924914538185818565&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9011831&hvtargid=pla-990454036300&psc=1

Ooyekunle commented 2 years ago

I meant "correct USB cable".

I think the USB cable you are using is actually a so-called USB-TTL cable, like the one offered here: https://www.robotistan.com/pl2303-usb-ttl-serial-converter-cable. Could you please confirm this? (If you remember where you got the cable from, you can post the link to the product.)

The cable you need is a simple USB cable without any conversion circuits inside. https://www.adafruit.com/product/4448 is one example. You can also make such a cable yourself, if you cut a normal USB A-microB cable in half and solder some dupont wires to the half which has a USB A plug on it.

oh, should I just go ahead and get this cable or try to buy a debugger?

Ooyekunle commented 2 years ago

72C0823B-E830-49AB-8777-CA9AC4859118 You’re right. This is what I have @igrr

Ooyekunle commented 2 years ago

@georgik and @igrr Thanks a bunch. I got a new cable made for me in the store and I’m now able to debug

Ooyekunle commented 2 years ago

5CB2A52A-A76E-44BE-A220-5F67A8DFC8F9

crNewton commented 1 year ago

OK, I can install the WinUSB driver through zadig, instead of espressif's installer. This is an acceptable workaround. For those coming across this in the future, be sure that your drivers look like this:

Device 1: USB Serial image This device will remain as the default windows usbser driver, we shouldn't change it.

Device 2: Regular USB image note that if it shows its signed by espressif instead of libwdi, thats fine, it means the espressif installer worked and you don't need zadig.

This second device is the one that needs to be installed with Zadig. I used WinUSB as the driver. Be sure you select "install driver" instead of "install WCID driver" in the dropdown. It should look like this: image

I can confirm this worked for my ESP32-S3 as well, on Windows 10.

georgik commented 1 year ago

Thank you for the updates. The problem seems to be related to current state of drivers in the system. After several attempts we were not able to replicate the problem.

Closing the issue. Feel free to re-open.

@erhankur Please, read the thread, it might be valuable to consider this information when authoring drivers for C2 and C6.