Hello,
I’m attempting to setup a Segger J-Link to debug an Adafruit ESP32 Metro. I can neither upload nor debug using the J-Link.
The J-Link works correctly when downloading/debugging an Adafruit FeatherM0, so I’m confident that the J-Link is working correctly. The green LED on the J-Link is on and not blinking.
I soldered the small JTAG interface connector onto the board and verified that it’s okay (no solder bridges or bad connections, etc.). As noted in several web articles I changed the USB driver to WinUSB (Using JLinkConfig instead of Zadig) and tried changing the debug_speed to a lower value. Also, in order to simplify as much as possible, the code I’m currently uploading is just an empty shell with just a setup and a loop.
This is my platfornio.ini file:
[env:adafruit_metro_esp32s2]
platform = espressif32
board = adafruit_metro_esp32s2
framework = arduino
;lib_deps = adafruit/Adafruit NeoPixel@^1.10.5
;build_flags = -v
debug_speed = 1000 <--- Tried several different values.
debug_tool = jlink
; SWD interface
upload_protocol = jlink
; JTAG interface
;upload_protocol = jlink-jtag
The following is the log from the terminal when building and uploading:
Processing adafruit_metro_esp32s2 (platform: espressif32; board: adafruit_metro_esp32s2; framework: arduino)
-----------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/adafruit_metro_esp32s2.html
PLATFORM: Espressif 32 (4.4.0) > Adafruit Metro ESP32-S2
HARDWARE: ESP32S2 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (jlink) External (cmsis-dap, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 @ 3.20003.220626 (2.0.3)
- tool-esptoolpy @ 1.30300.0 (3.3.0)
- tool-mkfatfs @ 2.0.1
- tool-mklittlefs @ 1.203.210628 (2.3)
- tool-mkspiffs @ 2.230.0 (2.30)
- tool-openocd-esp32 @ 2.1100.20220706 (11.0)
- toolchain-riscv32-esp @ 8.4.0+2021r2-patch3
- toolchain-xtensa-esp32s2 @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio\build\adafruit_metro_esp32s2\firmware.elf
Checking size .pio\build\adafruit_metro_esp32s2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [= ] 5.5% (used 17932 bytes from 327680 bytes)
Flash: [== ] 15.4% (used 221594 bytes from 1441792 bytes)
Configuring upload protocol...
AVAILABLE: cmsis-dap, 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\adafruit_metro_esp32s2\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
DEPRECATED! use 'adapter speed' not 'adapter_khz'
adapter speed: 1000 kHz
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: esp32s2.cpu: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: Unexpected OCD_ID = ffffffff
Warn : target esp32s2 examination failed
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: esp32s2.cpu: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: Unexpected OCD_ID = ffffffff
Error: Target not examined yet
embedded:startup.tcl:1184: Error: ** Unable to reset target **
in procedure 'program_esp'
in procedure 'program_error' called at file "C:/Users/jtgar/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 104
at file "embedded:startup.tcl", line 1184
*** [upload] Error 1
=========================== [FAILED] Took 2.58 seconds ===========================
When I attempt to debug (f5) the terminal log looks normal, however the following dialog is displayed:
This is the above referenced json file:
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
//
// PIO Unified Debugger
//
// Documentation: https://docs.platformio.org/page/plus/debugging.html
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
{
"version": "0.2.0",
"configurations": [
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "c:/Users/jtgar/~Software/Arduino/PlatformIO Source/Metro ESP32 J-Tag Test/.pio/build/adafruit_metro_esp32s2/firmware.elf",
"projectEnvName": "adafruit_metro_esp32s2",
"toolchainBinDir": "C:/Users/jtgar/.platformio/packages/toolchain-xtensa-esp32s2/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
}
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "c:/Users/jtgar/~Software/Arduino/PlatformIO Source/Metro ESP32 J-Tag Test/.pio/build/adafruit_metro_esp32s2/firmware.elf",
"projectEnvName": "adafruit_metro_esp32s2",
"toolchainBinDir": "C:/Users/jtgar/.platformio/packages/toolchain-xtensa-esp32s2/bin",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (without uploading)",
"executable": "c:/Users/jtgar/~Software/Arduino/PlatformIO Source/Metro ESP32 J-Tag Test/.pio/build/adafruit_metro_esp32s2/firmware.elf",
"projectEnvName": "adafruit_metro_esp32s2",
"toolchainBinDir": "C:/Users/jtgar/.platformio/packages/toolchain-xtensa-esp32s2/bin",
"internalConsoleOptions": "openOnSessionStart",
"loadMode": "manual"
}
]
}
This is the debug console log:
undefinedC:\Users\jtgar\.platformio\packages\toolchain-xtensa-esp32s2\bin\xtensa-esp32s2-elf-gdb.exe: warning: Couldn't determine a path for the index cache directory.
Reading symbols from c:\Users\jtgar\~Software\Arduino\PlatformIO Source\Metro ESP32 J-Tag Test\.pio\build\adafruit_metro_esp32s2\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
DEPRECATED! use 'adapter speed' not 'adapter_khz'
adapter speed: 1000 kHz
Info : tcl server disabled
Info : telnet server disabled
Info : J-Link V11 compiled Jul 22 2022 10:21:23
Info : Hardware version: 11.00
Info : VTarget = 0.000 V
Info : clock speed 1000 kHz
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: esp32s2.cpu: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: Unexpected OCD_ID = ffffffff
Warn : target esp32s2 examination failed
Info : starting gdb server for esp32s2 on pipe
Info : accepting 'gdb' connection from pipe
Error: Target not examined yet
Error executing event gdb-attach on target esp32s2:
Warn : No symbols for FreeRTOS!
Error: Target not halted
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
Error: error during select: Unknown error
.pioinit:11: Error in sourced command file:
Remote communication error. Target disconnected.: Success.
Any help would be appreciated.
Thanks,
Jack