JLINK debugging first try error

I have just received my Chinese JLINK clone.
Added debug_tool = jlink
The package downloaded successfully, I have installed the driver, started debugging, I get a warning and an error, and nothing works::

Target interface speed: 4000kHz
Target endian: little

Connecting to J-Link…

Reading symbols from d:\PIO\Duett\DEV.pio\build\due\firmware.elf…
undefinedC:\Users\cspalos.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-gdb.exe: warning: Couldn’t determine a path for the index cache directory.

PlatformIO Unified Debugger → Redirecting...
PlatformIO: debug_tool = jlink
PlatformIO: Initializing remote target…
.pioinit:14: Error in sourced command file:
:2331: Nem hozhat� l�tre kapcsolat, mert a c�lsz�m�t�g�p m�r visszautas�totta a kapcsolatot.

The last sentence is in Hungarian and means something like: No connection could be established because the target computer refused the connection.

I have also tried with the official Segger GDB server, it also could not connect…

What shall I try to overcome this problem?

Ok if it doesn’t even work with the official tools something more fundamental must be wrong. What’s the wiring between the JLink and the Due? Which exact JLink device do you have?

2 Likes

This is the device:
https://www.amazon.de/gp/product/B07RWBNW6S/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1

Wiring is:
Pin1 VTref to 3V3
Pin4 GND to GND
Pin19 5V to 5V
Pin7 SWDIO to SWDIO
Pin9 SWCLK to SWCLK
Pin15 RESET to RESET
These last three all connected to the 0.1" pins next to Pin12 and Pin13 of the Arduino Due.

What is unclear for me:

I am still using USB programming port for upload. Shall also USB be connected so that the debug information can be uploaded with the image?

How can I tell to my probe that I want to use SWD and not JTAG (I don’t have the right wire for JTAG yet)

Is it a good idea to allow a firmware update on the clone? It seemed to update correctly, but when I try to debug, often a firmware update popup shows up for a second again.

What is the word undefined in the output?

undefinedSEGGER J-Link GDB Server V6.52 Command Line Version
JLinkARM.dll V6.52 (DLL compiled Sep 27 2019 17:50:11)
Command line: -singlerun -if SWD -select USB -device ATSAM3X8E -port 2331
-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: on
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: ATSAM3X8E
Target interface: SWD
Target interface speed: 4000kHz
Target endian: little

Connecting to J-Link…
Reading symbols from d:\PIO\Duett\DEV.pio\build\due\firmware.elf…
undefinedC:\Users\cspalos.platformio\packages\toolchain-gccarmnoneeabi\bin\arm-none-eabi-gdb.exe: warning: Couldn’t determine a path for the index cache directory.
PlatformIO Unified Debugger → Redirecting...
PlatformIO: debug_tool = jlink
PlatformIO: Initializing remote target…
.pioinit:14: Error in sourced command file:
:2331: Nem hozhat� l�tre kapcsolat, mert a c�lsz�m�t�g�p m�r visszautas�totta a kapcsolatot.

Seems this is a windows error when PIO wants to connect to the GDB server port at 2331. Are the JLink drivers installed? (PIO debugger won't work in VSCode - #5 by ivankravets)

1 Like

Yes, I have installed the drivers. But it did not work the advertised way: c:\Users\Csaba.platformio\packages\tool-jlink\USBDriver\InstDrivers.exe did not work, it stopped after the UAC. I had to start c:\Users\Csaba.platformio\packages\tool-jlink\USBDriver\x64\dpinst_x64.exe directly.

Now I have tried on a different computer, exactly the same result.

I have changed the windows language to English. The error message is>

PlatformIO: Initializing remote target…
Could not connect to J-Link.
Please check power, connection and settings…pioinit:16: Error in sourced command file:
:2331: No connection could be made because the target machine actively refused it.

Are you using this to power the target board? Or are you also supplying USB power? In this case you shouldn’t connect the JLink’s 5V to the target.

Do you have a picture of the physical setup?

Does the error stay the same when the RESET line is disconnected (it should still to a SWD reset)?

1 Like

In the current setup I do use the 5V from the probe to power the target board. I have just tried the other way, powering through the programming port without connecting 5V, did not help. The board itself is working in both setups, The LED on the probe is on, but cannot connect.

I have just tried to disconnect RESET, did not change.

Sometimes I get a popup to update the firmware. If I let it update, seems to update well, and the next time the popup does not appear.

Is this setting correct?:
Target connection timeout: 0 ms
Where can I increase it?

The “undefined” words disappeared. (It is a different PC).

This is the setup without 5V connected, board powered over USB programming port.
k%C3%A9p

Try ti run JLinkGDBServerCL.exe. Does it sees your hardware?

It does see the hardware and offers a Firmware update. It seems to install the firmware update, and reports that the update was successful, although it could not connect the hardware afterward. The next time there is no such update popup.

But the GDB connection is not sucessful:

SEGGER J-Link GDB Server V6.54c Command Line Version

JLinkARM.dll V6.54c (DLL compiled Nov 7 2019 17:01:02)

-----GDB Server start settings-----
GDBInit file: none
GDB Server Listening port: 2331
SWO raw output listening port: 2332
Terminal I/O port: 2333
Accept remote connection: localhost only
Generate logfile: off
Verify download: off
Init regs on start: off
Silent mode: off
Single run mode: off
Target connection timeout: 0 ms
------J-Link related settings------
J-Link Host interface: USB
J-Link script: none
J-Link settings file: none
------Target related settings------
Target device: Unspecified
Target interface: JTAG
Target interface speed: 4000kHz
Target endian: little

Connecting to J-Link…
Connecting to J-Link failed. Connected correctly?
GDBServer will be closed…
Shutting down…
Could not connect to J-Link.
Please check power, connection and settings.

I assume I bricked my JLink clone by updating the firmware with the official one.

It’s rather unlikely that you have bricked your J-Link.

Currently, the J-Link software cannot talk to the J-Link debug probe. So conduct the following test without the Arduino connected.

  • Download and install Zadig. It’s a software for configuring USB drivers.

  • In Zadig, check Options > List All Devices.

  • You should now see two interfaces related to J-Link: CDC (Interface 0) and BULK Interface (Interface 2). Do they have the JLinkCDC and jlink driver installed?

3 Likes

Thanks, Manuel,

I can only see one J-Link entry, CDC:

k%C3%A9p

I cannot see the BULK Interface you mentioned:

k%C3%A9p

Do you think, I can repair this?

Csaba

The driver installer shows these drivers as successfully installed:

k%C3%A9p

I just realized I was using a V9 version. The V8 version shows a single interface as well and in Zadig it looks exactly like your output.

And your probe shows up as a USB device. That’s a good start.

Can you start J-Flash Vxx (a software that comes with the J-Link software) – again with just the J-Link probe (and nothing connected to it):

  • Choose Create a new project and click Start J-Flash
  • Click OK (without changing target device / interface / speed)
  • Select Target > Connect from the menu

Now an error will occur because you have no target connected. But the log output can give some hints. Does it start with something like:

Connecting...
 - Connecting via USB to J-Link device 0
 - J-Link firmware: J-Link ARM V8 compiled Nov 28 2014 13:44:46

If J-Flash can detected the J-Link version, then the communication with the probe is working correctly.

2 Likes

Bad news:
Connecting …

  • Connecting via USB to J-Link device 0
  • ERROR: Cannot connect to J-Link via USB.
  • ERROR: Failed to connect.
    Could not establish a connection to the J-Link.

But it makes a difference whether the probe is plugged in or not: when plugged in, I get a line “- Connecting via USB to J-Link device 0” and a notification about a firmware update, else I don’t.

What do you mean by whether the probe is plugged in? I understand it as J-Link plugged in to computer, which doesn’t make a lot of sense.

1 Like

I just mean that the probe is not completely dead, the J-Flash software does recognize the presence of the probe when plugged in, just cannot connect to it.

I still don’t understand the “difference whether the probe is plugged in or not”. What is plugged in to what?

Anyway, it seems your options are:

  • Try a different USB cable to make sure it’s not just the cable
  • Try a different USB port to make sure it’s not related to that
  • Try to reflash the J-Link firmware. There are several guides available. Just search for “update jlink clone”.
1 Like

Thanks, I also think I have to reflash.
It will be some hassle, because there are no ERASE and TST jumpers on my PCB, but I will figure it out.

Thank you for your help!