OpenOCD not finding JLINK with ESP32 Project

I have read the many posts on how to get JLINK working in PlatformIO with an ESP32 project but can’t find a reference to the specific problem I am having. I see many people have made this work so I know it is possible. I have tried all the fixes I can find and none have been successful. The specific board is a ESP32-DevkitC-32E and I have the JLINK connected as follows:
IO12: JTAG TDI
IO13: JTAG TCK
IO14: JTAG TMS
IO15: JTAG TDO
RST/EN: JTAG Reset
3.3V: VTref
2 ground pins

Here is my platfomio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
debug_tool = jlink
upload_protocol = jlink

I have installed the latest JLINK software and have tried setting the JLINK driver to WINUSB and libusb-win32. PlatformIO and VSCode are at the latest level. I am running on a win10 Pro machine.

My specific problem is if I try to upload or debug, I get the following message and error. Upload works fine with esptool. I have used JLink on multiple other projects (mainly with NXP K20 MCUs).

I’ve been working on this for a couple of days now (including “conversations” with Gemini and CoPilot) and can’t fix it.
Can anyone help, please?

Configuring upload protocol…
AVAILABLE: cmsis-dap, esp-bridge, esp-prog, espota, 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 .pio\build\esp32dev\firmware.bin
Open On-Chip Debugger v0.12.0-esp32-20230313 (2023-03-13-09:05)
Licensed under GNU GPL v2
*For bug reports, read *

  •    http://openocd.org/doc/doxygen/bugs.html*
    

debug_level: 1

Error: The specified debug interface was not found (jlink)
The following debug adapters are available:
1: ftdi
2: usb_blaster
3: esp_usb_jtag
4: ft232r
5: usbprog
6: vsllink
7: rlink
8: ulink
9: arm-jtag-ew
10: remote_bitbang
11: hla
12: osbdm
13: opendous
14: cmsis-dap
15: xds110
16: st-link
17: jtag_esp_remote
**** [upload] Error 1*

More information on this problem. I found that the OpenOCD version in PlatofrmIO is not the latest. I added the following line to platformio.ini:

platform_packages=platformio/tool-openocd-esp32@^2.1200.20230419

This installed the latest OpenOCD version and now the message is as follows. The jlink interface is still not found.

Is anyone else experiencing this problem?!

CURRENT: upload_protocol = jlink
Uploading .pio\build\esp32dev\firmware.bin
Open On-Chip Debugger v0.12.0-esp32-20230419 (2023-04-18-22:02)
Licensed under GNU GPL v2
For bug reports, read

  •    http://openocd.org/doc/doxygen/bugs.html*
    

debug_level: 1
*WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release. *
*** program_esp input args <0x10000 verify> ***
Warn : An adapter speed is not selected in the init scripts. OpenOCD will try to run the adapter at very low speed (100 kHz).
Warn : To remove this warnings and achieve reasonable communication speed with the target, set *
“adapter speed” or “jtag_rclk” in the init scripts.
Warn : Failed to open device: LIBUSB_ERROR_ACCESS
Error: No J-Link device found
*** OpenOCD init failed ***
shutdown command invoked
C:/Users/Al Testani/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg:4: Error:
at file “C:/Users/Al Testani/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg”, line 4
**** [upload] Error 1

Some progress…

I got out a different JLINK dongle (a different EDU mini) and connected it to USB. I opened jlink.exe and was allowed to update the firmware. I made sure with Zagid I had installed the WINUSB driver. I can now upload using the JLINK but it is defaulting to a speed of 100KHz which is incredibly slow. I does program the ESP32 but sloooowly. Debugging doesn’t work at this point.

I am getting the warning message:
Warn : An adapter speed is not selected in
the init scripts. OpenOCD will try to run the adapter at very low speed (100 kHz).
Warn : To remove this warnings and achieve
reasonable communication speed with the target, set “adapter speed” or “jtag_rclk” in
the init scripts.

How and in what file do I change the adapter speed? How do I get debugging to work? I would be grateful for any help with this!
Thanks!

After getting no response and trying everything I could think of, I gave up on JLINK and went to an ESP-PROG for uploading and debugging. It works perfectly.

This is the platformio.ini that I have. The speed directives are because the default speeds seemed too slow. The init_break is there because, apparently it isn’t the default as it usually is.

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
upload_protocol = esp-prog
upload_speed = 921600
debug_tool = esp-prog
debug_speed = 5000
debug_init_break = tbreak setup

1 Like