Jlink debugging failure on esp32 devkitC board

I tried to debug using Jlink, but I can’t. What did I miss?

  • warning at build
Warning! Unknown upload protocol jlink-jtag
  • error at debugging
undefinedC:\Users\JJS\.platformio\packages\toolchain-xtensa-esp32\bin\xtensa-esp32-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.

Reading symbols from d:\Project\HVP\FreeRTOS_test_230116\.pio\build\esp-wrover-kit\firmware.elf...
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = jlink
PlatformIO: Initializing remote target...
Open On-Chip Debugger  v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
adapter speed: 5000 kHz

Info : tcl server disabled
Info : telnet server disabled
Warn : Failed to open device: LIBUSB_ERROR_NOT_SUPPORTED.
Error: No J-Link device found

.pioinit:11: Error in sourced command file:

[env:esp-wrover-kit]
platform = espressif32
framework = arduino

board = esp32dev
monitor_speed = 115200
build_type = debug 
debug_tool = jlink
upload_protocol = jlink-jtag

board_build.filesystem = littlefs
lib_deps = 
		bodmer/TFT_eSPI@^2.4.79
		lvgl/lvgl@^8.3.2
build_flags =
        -DBOARD_HAS_PSRAM
        -mfix-esp32-psram-cache-issue
        ; -DCONFIG_FREERTOS_USE_TRACE_FACILITY
  • H/W connection
    TMS: IO14
    TDI: IO12
    TCK: IO13
    TDO:IO15
    VCC: 3.3V
    GND: GND

  • Jlink driver: WinUSB Driver (by using Zadig)

  • run InstDrivers.exe in core_dir/packages/tool-jlink/USBDriver

Then it’s a driver issue. Can you uninstall the driver installed by Zadig again, or try WinUSB instead of libusb in Zadig?

I have tried those as below. But debugging with J-Link dose not work.

[env:esp32dev]
platform = espressif32
framework = arduino
board = esp32dev
debug_tool = jlink
upload_protocol = jlink-jtag
monitor_speed = 115200
build_type = debug 
  • PIO debug result is shown as below:
undefined'platformio'��(��) ���� �Ǵ� �ܺ� ����, ������ �� �ִ� ���α׷�, �Ǵ�
��ġ ������ �ƴմϴ�.
  • if the upload_protocol = jlink, the upload result is shown as below:
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.11.0-esp32-20220706 (2022-07-06-15:48)
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.
adapter speed: 5000 kHz

** Programming Started **
** Programming Finished in 5228 ms **
** Verify Started **
** Verify OK **
** Programming Started **
** Programming Finished in 1426 ms **
** Verify Started **
** Verify OK **
** Programming Started **
** Programming Finished in 1104 ms **
** Verify Started **
** Verify OK **
** Programming Started **
** Programming Finished in 1197 ms **
** Verify Started **
** Verify OK **
shutdown command invoked
========================================= [SUCCESS] Took 15.50 seconds =========================================

--- Available ports:
--- Enter port index or full name: 
  • if the upload_protocol = jlink-jtag, the upload result is shown as below:
========================================= [SUCCESS] Took 45.97 seconds =========================================

--- Available ports:
--- Enter port index or full name: 

When I created my esp32dev pio project, there were c_cpp_properties.json, extensions.json and launch.json in the .vscode folder. If I click the PIO Debug, I got an error message with “Could not find the specified task”.
my launch.json file is as below:

   "version": "0.2.0",
   "configurations": [
       {
           "type": "platformio-debug",
           "request": "launch",
           "name": "PIO Debug",
           "executable": "c:/Users/JJS/Documents/PlatformIO/Projects/230126-094810-arduino-blink/.pio/build/esp32dev/firmware.elf",
           "projectEnvName": "esp32dev",
           "toolchainBinDir": "C:/Users/JJS/.platformio/packages/toolchain-xtensa-esp32/bin",
           "internalConsoleOptions": "openOnSessionStart",
           "preLaunchTask": {
               "type": "PlatformIO",
               "task": "Pre-Debug"
           }
       },

I created tasks.json in .vscode as below, then the debugging was successful.

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Pre-Debug",
            "type": "shell",
            "command": "pio run",
            "group": {
                "kind": "build",
                "isDefault": true
            },
        }
    ]
}

It’s fortunate that it was debugged, but I wonder why I need to create a tasks.json file in this project debugging with J-Link. Even when debugging with FTDI in the esp-wrover-kit project, there was a preLaunchTask item in the launch.json file, but tasks.json was not created and debugging was successful.