Only differences between Yourigh and me is that he connected EN to nTRST and sets the frequency to 5MHz. My setup is EN to nReset (because there’s no ntrst pin on jlink edu mini) and I set the frequency to 3MHz because the Jlink EDU mini max frequency for jtag is 4MHz.
First question: Is it possible with this setup to debug the ESP32? - Maybe over SWD?
After setup I still get the LIBUSB_ERROR_TIMEOUT. I also set jlink to winusb over zadig and tried every USB Port individually but could not solve the problem.
Open On-Chip Debugger v0.10.0-esp32-20190708 (2019-07-08-11:04)
Licensed under GNU GPL v2
For bug reports, read OpenOCD: Bug Reporting
debug_level: 1
adapter speed: 3000 kHz
esp32 interrupt mask on
Warn : Failed to send data to device: LIBUSB_ERROR_TIMEOUT.
Warn : Failed to send data to device: LIBUSB_ERROR_TIMEOUT.
Error: Sending data to device timed out.
Error: transport_write() failed: timeout occurred.
Error: jaylink_jtag_io() failed: timeout occurred.
Error: Failed to fetch AR regs!
Warn : Last read operation left 579 bytes.
Warn : Failed to send data to device: LIBUSB_ERROR_TIMEOUT.
Warn : Failed to send data to device: LIBUSB_ERROR_TIMEOUT.
Error: Sending data to device timed out.
Error: transport_write() failed: timeout occurred.
Error: jaylink_jtag_io() failed: timeout occurred.
Error: Failed to fetch AR regs!
Warn : Last read operation left 579 bytes.
Warn : Failed to send data to device: LIBUSB_ERROR_TIMEOUT.
Warn : Failed to send data to device: LIBUSB_ERROR_TIMEOUT.
Error: Sending data to device timed out.
Error: transport_write() failed: timeout occurred.
Error: jaylink_jtag_io() failed: timeout occurred.
Error: Failed to fetch AR regs!
Warn : Last read operation left 1245 bytes.
Error: timed out while waiting for target halted / 1 - 2
** Programming Started **
auto erase enabled
Error: Target not halted
Error: auto_probe failed
embedded:startup.tcl:480: Error: ** Programming Failed **
in procedure ‘program_esp32’
in procedure ‘program_error’ called at file “C:/Users/muhlr/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp32.cfg”, line 150
at file “embedded:startup.tcl”, line 480
Warn : Flash driver of esp32.flash does not support free_driver_priv()
Warn : Flash driver of irom does not support free_driver_priv()
Warn : Flash driver of drom does not support free_driver_priv()
*** [upload] Error 1
Firstly, you need to get it working in “upload” mode. So, pio run -t upload should work via J-Link. only if it works, you can move to debugging. In your case, it looks like an issue with drivers/zadig/cables. Have you tried different options described in this topic ESP32 + J-link debugger does not start ?
Hi thanks for fast responding. I tried every option in zadig. 3 of them ended in the same issue of timeout and the other USB Serial (CDC) could not find the jlink.
I checked the wires carefully and get same connections with the topic ESP32 + Jlink debugger does not start. Only nTRST is not aviable and therefore EN is connected to nReset as mentioned above.
On the ESP32 board there are some components for the arduino ide to upload some code. I desolderet the components U2, VT1 and VT2 just to get sure nothing makes problems with the jlink. You find the schematic here.
I have successfully used JTAG debugging with the ESP32 in the past (see Low-cost ESP32 In-circuit Debugging). It might not fully apply as I used FTDI-based debuggers instead of J-LINK.
The USB driver most likely is configured correctly. If not, the error message would look very different.
In my setup, neither nRESET nor nTRST was connected and the USB chip and reset logic you have removed from your board were still in place. So you might want to try at least once without connecting nRESET. It doesn’t seem to be needed.
From all similar issues I find when googling, LIBUSB_ERROR_TIMEOUT seems to be caused by timing problems, either due to a high data rate or due to congestion on the USB bus. Your data rate is low is low and therefore unlikely to be the problem. But can you try other USB combinations: no hub, a different USB cable, a different USB port?
I don’t have a JLINK EDU Mini, but I will try with a JLINK clone later today.
Suggests that an even lower adapter_speed might be needed. Can you change it to like 500kHz? (<User dir>\.platformio\packages\tool-openocd-esp32\share\openocd\scripts\board\esp-wroom-32.cfg)
I’ve tested an ESP32 board with two JLINK clones and they both work on Windows and on macOS.
Additionally, I’ve tested using the incorrect USB driver. The result is:
Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED.
And it appears in the same log output positions as the first LIBUSB_ERROR_TIMEOUT warning in your case. So the USB driver most likely is not the problem. The error message would look differently.
Therefore I’m pretty sure that your computer is unable to talk to the JLINK adapter. The communication fails before the target becomes relevant. So for your next steps, just try without connecting the ESP32.
So I still recommend to investigate the USB connection: cables, hub, USB port
I set down the frequency to 500kHz but it wasn’t successful.
I organised a Jlink EDU and tried with this. This was successful. I can now upload and debug my code.
The problem is solved now.
I also tried to disconect the nRESET/nTRST and upload code as manuelbl suggested and he was right. It’s not needed.
I don’t know if my Jlink EDU Mini is broken or why it dont work. I will try some diffrent usb cables on it later this week just to verfi if it’s connection or it’s a broken jlink.