ESP32 Metro J-Link

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jtgartner
 
Posts: 51
Joined: Mon Mar 27, 2017 8:09 pm

ESP32 Metro J-Link

Post by jtgartner »

Hello,
I’m using PlatformIO and 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 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:

Code: Select all

[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:

Code: Select all

 
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://BANNED/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 pops up:
dialog.png
dialog.png (30.58 KiB) Viewed 284 times
This is the referenced json file:

Code: Select all

// 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"
        }
    ]
}
And finally, this is the debug console log:

Code: Select all

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://BANNED/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.
Thanks,
Any help would be appreciated.

Jack

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: ESP32 Metro J-Link

Post by mikeysklar »

Which model of the Segger J-Link are you using?

Can you remove Platform IO from the equation and follow the Adafruit guide for getting OpenOCD going?

https://learn.adafruit.com/adafruit-met ... th-openocd

User avatar
jtgartner
 
Posts: 51
Joined: Mon Mar 27, 2017 8:09 pm

Re: ESP32 Metro J-Link

Post by jtgartner »

Thanks for the reply Mikey. Turns out that my problem was hardware related:

Code: Select all

Info : VTarget = 0.000 V
I had a bad solder joint on the small jtag connector. It was okay when I tested it, but I when I plugged the jtag cable in, my “good” solder connection moved and obviously wasn’t so good after all.
It's hard soldering those small connectors using a 300W plumbers soldering iron ;-).

Anyway, I can now download successfully, and I'm trying to figure out how to get the debugger to work correctly. But that's a different subject and I'll post again if needed.

Thanks again,

Jack

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: ESP32 Metro J-Link

Post by mikeysklar »

Thank you for getting back to us about the soldering being the issue.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”