Search code examples
jtagsegger-jlink

Unable to install and configure a J-Link JTAG debugger on a Mac


I have a Segger J-Link which I am trying to use on a Macbook running MacOS Catalina 10.15.4, with openocd and GDB against an ESP32 board. The problem is that I can not seen the device:

$ ls /dev/cu.*
/dev/cu.Bluetooth-Incoming-Port /dev/cu.JimsiPhone-WirelessiAP  /dev/cu.SLAB_USBtoUART      /dev/cu.usbserial-0001

None of these is the J-Link. If I run lsusb I can see it:

$ lsusb
Bus 020 Device 002: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 020 Device 003: ID 1366:0101 SEGGER J-Link ARM

I have installed the "J-Link Software and Documentation Pack" downloaded from Segger. I have checked the Mac "Security and privacy" settings and it does not report that it blocked any drivers or programs from being installed or run.

On the J-Link, the green LED is on, with a very brief flash about twice per second.

I'm sure I have a piece missing, and would appreciate some help.

UPDATE: I have been following instructions here:

OpenOCD Instructions

It all works until I get to step 6, and I follow these instructions:

Serial driver instructions

The problem is, a path for the driver never shows up, as I described above. I don't think I can run OpenOCD if I can't make it talk to my J-link.

When I run openocd-esp32, I get (full paste from openocd-esp32 output is below):

Error: No J-Link device found.

The contents of esp32-wroom-32.cfg is:

echo "WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release."
set ESP32_FLASH_VOLTAGE 3.3
source [find target/esp32.cfg]

Here is the full paste:

Jims-MacBook-Pro-486:~ jim$ openocd -f interface/jlink.cfg -f board/esp-wroom-32.cfg -c "program_esp32 build/hello-world.bin 0x10000 verify exit"
Open On-Chip Debugger  v0.10.0-esp32-20200420 (2020-04-20-16:15)
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.
Info : Configured 2 cores
Error: No J-Link device found.
** OpenOCD init failed **
shutdown command invoked

Assertion failed: (jtag_trst == 0), function jtag_checks, file src/jtag/core.c, line 343.
Abort trap: 6

Running JLinkExe does find the J-Link:

Jims-MacBook-Pro-486:~ jim$ JLinkExe
SEGGER J-Link Commander V6.80b (Compiled Jun  5 2020 17:42:04)
DLL version V6.80b, compiled Jun  5 2020 17:41:46

Connecting to J-Link via USB...Updating firmware:  J-Link V11 compiled Apr 23 2020 16:49:23
Replacing firmware: J-Link V11 compiled Aug 14 2019 16:21:09
Waiting for new firmware to boot
New firmware booted successfully
O.K.
Firmware: J-Link V11 compiled Apr 23 2020 16:49:23
Hardware version: V11.00
S/N: 51000936
License(s): GDB
VTref=0.000V


Type "connect" to establish a target connection, '?' for help
J-Link>

After doing the above I now get a different error message when running openocd-esp32 (perhaps because of the J-Link FW upgrade?). Initially it complained that there was not an adapter speed set, so I modified interface/jlink.cfg and added:

adapter_khz 3000

I now get a different error:

Error: JTAG scan chain interrogation failed: all ones

Which I have been Googling, and which could mean a bad board or still another configuration issue. There is no SD card in the SD card socket and no other SPI devices on the board, although the ESP32-WROVER-32U has SPI flash on it.

Here is the complete output from openocd-esp32:

Jims-MacBook-Pro-486:~ jim$ openocd -f interface/jlink.cfg -f board/esp-wroom-32.cfg -c "program_esp32 build/hello-world.bin 0x10000 verify exit"
Open On-Chip Debugger  v0.10.0-esp32-20200420 (2020-04-20-16:15)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
adapter speed: 3000 kHz

WARNING: boards/esp-wroom-32.cfg is deprecated, and may be removed in a future release.
Info : Configured 2 cores
Info : J-Link V11 compiled Apr 23 2020 16:49:23
Info : Hardware version: 11.00
Info : VTarget = 0.000 V
Info : clock speed 3000 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: esp32.cpu0: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Info : Listening on port 3333 for gdb connections
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
Info : cpu0: Debug controller 0 was reset.
Info : cpu0: Core 0 was reset.
Error: esp32_soc_reset: Couldn't halt target before SoC reset
embedded:startup.tcl:449: Error: ** Unable to reset target **
in procedure 'program_esp32' 
in procedure 'program_esp' called at file "/Users/jim/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200420/openocd-esp32/share/openocd/scripts/target/esp32.cfg", line 64
in procedure 'program_error' called at file "/Users/jim/.espressif/tools/openocd-esp32/v0.10.0-esp32-20200420/openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 75
at file "embedded:startup.tcl", line 449
Warn : Flash driver of esp32.flash does not support free_driver_priv()
Warn : Flash driver of esp32.irom does not support free_driver_priv()
Warn : Flash driver of esp32.drom does not support free_driver_priv()

Success! This circuit used the Segger 10 pin needle connector. On that connector pin 1 is VTREF and on my board it was left floating, when it should have been connected to V3.3. I connected it and:

Jims-MacBook-Pro-486:~ jim$ openocd -f interface/jlink.cfg -f board/esp32-wrover.cfg
Open On-Chip Debugger  v0.10.0-esp32-20200420 (2020-04-20-16:15)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz

WARNING: boards/esp32-wrover.cfg is deprecated, and may be removed in a future release.
         If your board is ESP32-WROVER-KIT, use board/esp32-wrover-kit-1.8v.cfg instead.
Info : Configured 2 cores
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link V11 compiled Apr 23 2020 16:49:23
Info : Hardware version: 11.00
Info : VTarget = 3.290 V
Info : clock speed 1000 kHz
Info : JTAG tap: esp32.cpu0 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : JTAG tap: esp32.cpu1 tap/device found: 0x120034e5 (mfg: 0x272 (Tensilica), part: 0x2003, ver: 0x1)
Info : esp32: Debug controller 0 was reset.
Info : esp32: Core 0 was reset.
Info : esp32: Debug controller 1 was reset.
Info : esp32: Core 1 was reset.
Info : Listening on port 3333 for gdb connections

Solution

  • I would suggest to validate your setup step by step - I personally do not like big bang integrations.

    1. Verify that your the Segger software can see your JLink probe - the good thing is that lsusb can see it. JLink Commander should provide some useful information.
    2. Launch openocd without any executable-related arguments: openocd -f interface/jlink.cfg -f board/esp-wroom-32.cfg
    3. Verify that basic commands are working, i.e. resetting the CPU, displaying registers, reading/writing memory.
    4. If you you are still experimenting issues, double-check your wiring - see here for more information.