ESP32 + J-link debugger does not start

First result is esp-idf/tips-and-quirks.rst at master · espressif/esp-idf · GitHub… do you use GPIO15 in your sketch? Is it connected to something else?

Nope, GPIO15 is unused. Same as others for JTAG. I do not use on-board LED either. Could the connected LED interfere?

Interestingly, the platformio does not detect Jlink when used for debug but does when used for upload. On debug I get the same as before.

The onboard LED is on GPIO13 which is MTCK. We can give it a try if it changes something. Can you change the pin to any other but not 12,13,14 or 15?

I was not using GPIO13 in code. But the was LED was physically connected to a GPIO13.
I de-soldered it and it did not make any difference.

Since I don’t have that hardware it’s hard for me to reproduce. I’d suggest opening an issue according to esp-idf/tips-and-quirks.rst at master · espressif/esp-idf · GitHub or maybe @ivankravets can help.

successful upload after dropping the frequency in share/openocd/scripts/board/esp-wroom-32.cfg

# On DevKit-J, this can go as high as 20MHz if CPU frequency is 80MHz, or 26MHz>     # if CPU frequency is 160MHz or 240MHz.
#adapter_khz 20000
adapter_khz 5000

Debugger also running.
Thank you a lot!

full path
EDIT: C:\Users<USER>.platformio\packages\tool-openocd-esp32\share\openocd\scripts\board

3 Likes

Oh great, I actually read that and forgot about it >_>

The maximum possible adapter speed can also be influenced by wire lengths (or bad wire quality), so maybe try another shorter, better cable with the higher speed of 20MHz. Or stay on the working 5MHz for now :slight_smile:

10MHz works fine, I will increase it when on the manufactured board with better signal integrity.

1 Like

Thanks all for this thread, it really helped me work through similar problems I was having.

After following all the suggestions, I still had a problem with constant LIBUSB_ERROR_TIMEOUT messages.

The solution was to use different USB ports on the back of my PC - apparently the controller for the ports on the front of my PC has some subtle problem (although it seems to work fine for every other device). I hope this may be of some use to anyone else who has a similar problem.

2 Likes

Yourigh, (or anybody else who has demonstrably figured this out)

Did you ever get a working recipe to debug the ESP32 Feather Huzzah with a SEGGER JLink? I have trodden in your footsteps including even removing the LED, and setting the adapter speed much lower. The JTAG wires are soldered on!

[env:featheresp32]

platform = espressif32
board = featheresp32
framework = arduino
monitor_speed = 9600

debug_tool = jlink
upload_protocol = jlink
debug_init_break = tbreak setup

I have also seen all of the error reports you obtained.

I think I have done the right thing with Zadiq, though the recipe is a bit ambiguous. Here’s my pic.
2020-02-01_185815

I’m running out of ideas now! Would someone kindly toss me a line please?

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: 20 kHz
esp32 interrupt mask on
Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED.
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway…
Error: esp32.cpu0: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway…
Error: esp32.cpu0: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
*** [upload] Error 253

And if I plug the USB cable into a different hole (as suggested by DavidPowell) I get this
Uploading .pio\build\featheresp32\firmware.bin
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: 20 kHz
esp32 interrupt mask on
Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED.
Warn : Failed to open device: LIBUSB_ERROR_NOT_FOUND.
Error: No J-Link device found.
** OpenOCD init failed **
shutdown command invoked

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

Did you actually replace the driver for the debugger with the WinUSB one? Based on earlier output logs, your log output suggests that you’re still using the jlink driver. In your screenshot, the replace driver button was yet to be pressed, as the current driver in use was still the jlink one (i.e. left side - current driver, right side - driver to install).

Thanks for replying. I very much appreciate your kindness. After three days I’m getting rather frustrated. If I manage to crack this I’ll clarify with ate another “how to”.

Yes, I took that screen shot simply to demonstrate that I was replacing the correct driver, which I have done AFAIK. I suppose WinUSB(v6…) is the right replacement driver?

My device manager now shows this. Does it match what you see on your system?

I’m actually not sure what the error messages mean:

Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED.
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway…
Error: esp32.cpu0: IR capture error; saw 0x00 not 0x01

Does it mean that it can’t find the right library. Or does it mean it can’t find the right JTAG debuuger, or that the JTAG can’t talk to the ESP. Obviously after several days, I have tried every combo I can think of. So I’m guessing I have not understood something really simple.

Mik

So have you tried libusb instead?

Thanks again. :slight_smile:
Yup, tried them all. Deleted them all, Re-installed them all. Just get different flavor failuers.

libusb

esp32 interrupt mask on
Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED.
Warn : Failed to retrieve serial number: LIBUSB_ERROR_NOT_FOUND.
Error: Failed to claim interface: LIBUSB_ERROR_ACCESS.
Error: Failed to open device: unspecified error.
Error: No J-Link device found.
** OpenOCD init failed **
shutdown command invoked

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
========================================================== [FAILED] Took 3.03 seconds ==========================================================
The terminal process terminated with exit code: 1

May I ask what your device manager entries look like when the lib is correctly installed?

Can you show a screenshot of zadig on which device you are changing the driver? Are there any other JLink related devices in the list or device manager?

Hi Max, So kind of you to respond.

I described my jlink/platformIO/openOCD process with screenshots. Sadly I’m limited to one screenshot, so I put it all in this document.

Is this the particular bit you wanted to see?

I select the BULK interface and update it.
2020-02-03_120504

Mik

Well I’m kinda lost but it should have worked. Once you have repalced the drivers with WinUSB, you aren’t able to use the normal JLink tools until the driver is uninstalled again, right? Otherwise the driver wasn’t properly replaced.

This link (Error while flashing SoftDevice - J-Link EDU · Issue #228 · sandeepmistry/arduino-nRF5 · GitHub) says it was solved by reinstalling JLink drivers and then using Zadig again with WinUSB, and that the Bulk interface is the right one to replace. This thread ([OpenOCD-user] JLink works on 0.4.0, but not on 0.6.1 | OpenOCD - Open On-Chip Debugger) says that libusb-win32 drivers may also work.

1 Like

Thanks again.

Drivers uninstalled and Zadiq’d many times, in may different combos. I’ve tried all the library combos too.

I’m totally sure the hookup is correct.

However, I’m on the track of something else now.
J-LINK — PlatformIO latest documentation says that this is the setup for JLink:

debug_tool = jlink

; JTAG interface
upload_protocol = jlink-jtag

I found that it was choking on the jlink_jtag word.

Just below it says this:

  1. Start debugging session using PlatformIO IDE. PlatformIO will install J-Link software dependencies
  2. Navigate to [core_dir]/packages/tool-jlink/USBDriver
  3. Run InstDrivers.exe .

Im my case, no such directory exists, and clearly no such install has occurred. The specified directory has no JLink stuff in it whatsoever. So my challenge now is to find out why.

1 Like

Hi Mik,
I see you tried a lot of options to get it working. I would try to change the frequency reasonable numbers. 20 kHz may be too slow for some reason (maybe some timeout would occur). Go to 1000 kHz, I was running on 5000 kHz fine with some 10 cm long cables.

In the meantime, I am not using the J-link anymore, I switched to ESP-prog. Anyway the Zadig procedure was very similar. There are 2 interfaces, and only one needs to be replaced (for my case it was Interface 0). This may be bit different on J-link (I don’t remember this detail anymore).

Pictuse how it looks like for ESP-prog, it works in this state:

Also keep in mind that Windows sometimes forgets the driver replacement, so check again in zadig if it is replaced correctly. This also happens I use different USB port.

Another thing possibly is that you may need to update FW in your J-link.

Good luck with debugging, I hope you will make it work!

1 Like

Yourigh,
Thank you so much for your response, and the useful screen shots. . (5th day on this now) Yup, refreshed FW in jlink, I tried all the options you mention but to be sure I just ran through a bunch of speeds again, hunting around at various kHz. I should mention that I can get it to work under eclipse.

I’m pretty sure that there is some configuration issue - see my previous post. But I can’t seem to find the documentation that explains how to integrate SEGGER JTAG software components into the platfromio tree. The automagic install that they say happens, simply does not for me.

Apparently if I want some professional help I have to ante up $150.

It would be a lot less expensive for me to simply order an ESP-Prog and start over.

Thanks again. If I discover a fix, I’ll post the solution for sure.

Mik