ESP32 + J-link debugger does not start

Hello,
I am aware there have been posts on this topic and went through them. Unfortunately I did not find the fix for my issue.
I was trying many thing on different computer (including some of custom definitions of debug_tool) on different computer unsuccessfully.

Could you please help me to resolve this? I would love to give a unified debugger a chance (just bought a month plan).

On this computer I did these steps:

  1. J-link driver intstalled
  2. latest SEGGER J-link software installed (V6.44h)
  3. ESP32 Feather connected to Jlink by this table:
    image
    EDIT: ESP32 EN connected to pin 3(nTRST) of J-link
  4. connected USB of the ESP32 feather board to PC
  5. connected Jlink to PC
  6. Upload simple program to board (pin toogle) - successfully running
  7. Start debugging
  8. this error occurred:

I have the latest PlatformIO on Visual Studio Code Home 2.0.2·Core 3.6.7

The project configuration plaformio.ini:

[env:featheresp32]
platform = espressif32
board = featheresp32
framework = arduino
debug_tool = jlink

launch.json:

{
"version": "0.2.0",
"configurations": [
    {
        "type": "platformio-debug",
        "request": "launch",
        "name": "PIO Debug",
        "executable": "d:/PROJECTS/01_GIT_REPOS/FRA_Sensor_platform/3-FW_SW/1-FW_device/FRA_SP_ESP32/.pioenvs/featheresp32/firmware.elf",
        "toolchainBinDir": "D:/Cadence/SPB_Data/.platformio/packages/toolchain-xtensa32/bin",
        "preLaunchTask": {
            "type": "PlatformIO",
            "task": "Pre-Debug"
        },
        "internalConsoleOptions": "openOnSessionStart"
    },
    {
        "type": "platformio-debug",
        "request": "launch",
        "name": "PIO Debug (skip Pre-Debug)",
        "executable": "d:/PROJECTS/01_GIT_REPOS/FRA_Sensor_platform/3-FW_SW/1-FW_device/FRA_SP_ESP32/.pioenvs/featheresp32/firmware.elf",
        "toolchainBinDir": "D:/Cadence/SPB_Data/.platformio/packages/toolchain-xtensa32/bin",
        "internalConsoleOptions": "openOnSessionStart"
    }
]
}

Can you also not program the device via the J-Link? (use upload_protocol = jlink in the platformio.ini)

Thank you for a reply. Yes, uploading also fails through j-link, I can send a log shortly.

I verified the connections in a great detail couple times.

When uploading via j-link:

esptool.py v2.6
Configuring upload protocol…
AVAILABLE: esp-prog, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = jlink
Uploading .pioenvs\featheresp32\firmware.bin
Open On-Chip Debugger v0.10.0-esp32-20190313 (2019-03-13-09:57)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
adapter speed: 20000 kHz
Info : Configured 2 cores
esp32 interrupt mask on
Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED.
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`

Hm did you try solutions like Error while flashing SoftDevice - J-Link EDU · Issue #228 · sandeepmistry/arduino-nRF5 · GitHub? Can you download https://zadig.akeo.ie/ and replace the J-Link driver with libusb?

2 Likes

JLINK detected! by changing the driver to WinUSB via Zadig, moving forward to this message:


Do you have any ideas about it? (i tried to connect CHIP_PU (RST) to pin 3 or 15 on JTAG, but it stays the same)

1 Like

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?