Difference between revisions of "J-Link cannot connect to the CPU"

From SEGGER Wiki
Jump to: navigation, search
(Connection is unsuccessful)
(25 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
There are many different scenarios, which may prevent the J-Link from establishing a successful connection to the target device. The following article refers to the different scenarios and provides information on how to troubleshoot and in the next step how to fix them.
 
There are many different scenarios, which may prevent the J-Link from establishing a successful connection to the target device. The following article refers to the different scenarios and provides information on how to troubleshoot and in the next step how to fix them.
In general, we recommend to verify the correct connection between J-Link and the target device using the diagnostic utility [https://wiki.segger.com/J-Link_Commander J-Link Commander] before moving to the actual environment (e.g. Embedded Studio IDE). Therefore, this article refers to J-Link Commander and assumes that the [https://www.segger.com/downloads/jlink J-Link Software and Documentation] package (incl. J-Link USB driver) is installed. We recommend to work through this article from the beginning to the end.
+
In general, we recommend to verify the correct connection between J-Link and the target device using the diagnostic utility [https://wiki.segger.com/J-Link_Commander J-Link Commander] before moving to the actual environment (e.g. Embedded Studio IDE). Therefore, this article refers to J-Link Commander and assumes that the latest [https://www.segger.com/downloads/jlink J-Link Software and Documentation Pack] (incl. J-Link USB driver) is installed. We recommend to work through this article from the beginning to the end.
   
 
== J-Link connection ==
 
== J-Link connection ==
Line 9: Line 9:
 
[[File:Troubleshoot_JLinkCommander.png]]
 
[[File:Troubleshoot_JLinkCommander.png]]
 
=== Connection is unsuccessful ===
 
=== Connection is unsuccessful ===
  +
If the connection is not successful, please follow the steps below and perform the test above again.
 
  +
==== Windows ====
  +
If the connection is unsuccessful, first check if the J-Link is listed in the Windows Device Manager. If it is not, you can skip the [[#OpenOCD | OpenOCD]] paragraph and continue with [[#Test_Connection | Test Connection]].
  +
  +
==== Linux ====
  +
If the J-Link software package was installed by downloading and unpacking [https://www.segger.com/downloads/jlink/JLink_Linux_x86_64.tgz the .tgz archive], additional steps are required in order to enable the J-Link software to connect to J-Links via USB. These steps are described in the '''README.txt''' that is shipped with the .tgz archive of the J-Link software.
  +
Below is an excerpt of the '''README.txt''' of J-Link V7.86f:
  +
[...]
  +
In order to run J-Link/ Flasher software with standard user rights you have to do the following:
  +
  +
- Copy the file "99-jlink.rules" provided with this software package
  +
in the /etc/udev/rules.d/ directory using this command:
  +
  +
sudo cp 99-jlink.rules /etc/udev/rules.d/
  +
  +
Note: For older systems it might be necessary to replace the "ATTRS" calls in the 99-jlink.rules by "SYSFS" calls
  +
  +
- Either restart your system or manually trigger the new rules with the following commands:
  +
  +
sudo udevadm control -R
  +
sudo udevadm trigger --action=remove --attr-match=idVendor=1366 --subsystem-match=usb
  +
sudo udevadm trigger --action=add --attr-match=idVendor=1366 --subsystem-match=usb
  +
  +
Alternatively, the J-Link software can be installed using either [https://www.segger.com/downloads/jlink/JLink_Linux_x86_64.deb the .deb] or [https://www.segger.com/downloads/jlink/JLink_Linux_x86_64.rpm the .rpm package], both of which are installed using a package manager.
  +
The package manager will run the required steps implicitly upon installation of the J-Link software.
  +
  +
==== OpenOCD ====
  +
For OpenOCD, a separate J-Link USB driver needs to be installed / used. If the OpenOCD J-Link USB driver is configured, J-Link can be used with OpenOCD but not with ordinary J-Link utilities like for example J-Link Commander. In order to be able to communicate with the J-Link in the native J-Link utilities, the driver needs to be switched back from the J-Link OpenOCD driver to the original J-Link USB driver.
  +
  +
==== Test Connection ====
 
* Reboot the PC to make sure that the USB protocol itself is not in a confused state
 
* Reboot the PC to make sure that the USB protocol itself is not in a confused state
 
* Exchange the USB cable
 
* Exchange the USB cable
Line 16: Line 45:
 
* Verify that the J-Link USB driver is installed
 
* Verify that the J-Link USB driver is installed
 
* Switch to a different PC to exclude PC related issues
 
* Switch to a different PC to exclude PC related issues
  +
Make sure that you are not affected by the issues below:
If you followed the steps above and J-Link Commander is still not able to connect to the J-Link, please write us an e-mail to XXX. The e-mail should include the serial number of the affected unit as well as the answer to the questions below:<br>
 
  +
* J-Link configured for CMSIS boot mode, check settings within J-Link Configurator: https://wiki.segger.com/J-Link_Configurator#Configuring_Bootmode
  +
*https://wiki.segger.com/Incorrect_J-Link_USB_driver_installed
  +
*https://wiki.segger.com/J-Trace_PRO_Cortex-M
  +
*https://wiki.segger.com/J-Trace_driver_(WinUSB)_is_installed_but_the_driver_could_not_be_started
  +
If you followed the steps above and J-Link Commander is still not able to connect to the J-Link, please get in touch with SEGGER directly via our support system: https://www.segger.com/support/technical-support/. The message should include the answers to the questions below:<br>
 
If you physically connect the J-Link to the PC via USB:
 
If you physically connect the J-Link to the PC via USB:
* Does the green LED of the J-Link lit?
+
* Is the green LED of the J-Link lit?
 
* Does the Windows device manager show the J-Link in the list of USB devices?
 
* Does the Windows device manager show the J-Link in the list of USB devices?
 
* Please send us a screenshot of the J-Link Commander while the J-Link is connected via USB to the PC.
 
* Please send us a screenshot of the J-Link Commander while the J-Link is connected via USB to the PC.
  +
 
== Target connection ==
 
== Target connection ==
  +
In general, we recommend to use an evaluation board to verify the correct functionality between the J-Link and the target device before moving to a custom hardware in order to exclude issues which might be caused by an incorrect hardware design.
TBD.
 
  +
===Verify functionality using J-Link Commander===
  +
'''Please make sure that you are using the latest software version, available for download here: [https://www.segger.com/downloads/jlink https://www.segger.com/downloads/jlink]'''
  +
* Connect the J-Link via USB to the PC
  +
* Power the target device
  +
* Connect the target device with the J-Link
  +
* Start [[J-Link Commander]] and follow the startup configuration instructions
  +
[[File:Troubleshoot_JLinkCommander_DeviceConnection.png]]
  +
  +
=== Connection is unsuccessful ===
  +
In case of the connection is still unsuccessful, please follow the troubleshoot instructions below. If you are using an evaluation board and the issue persists after going through the instructions, please get in touch with SEGGER directly via our support system: https://www.segger.com/ticket/.
  +
==== VTref is 0.000V ====
  +
J-Link measures 0V target reference voltage. As the target reference voltage is used by the J-Link to create the levels of the debug signals, the reference voltage is mandatory.
  +
*Check the power supply of the target hardware and verify that it is powered (switches on, jumpers are set correctly, etc...)
  +
*Measure the voltage between pin 1 (VTref) and pin 4 (GND) of the debug connector, using an multi-meter.
  +
*If power supply should be provided via J-Link (Pin19), make sure that it's enabled:<br>https://wiki.segger.com/J-Link_Commander#Power
  +
  +
==== Interface settings ====
  +
On some hardware / devices, only certain debug interfaces are connected and can be used. Another problem can be that the hardware does not allow higher interface speeds.
  +
*Check that the correct target interface is selected (JTAG, SWD, ...)
  +
*Reduce the interface speed to 100 kHz
  +
*For ARM926EJ-S cores, max. JTAG speed == 1/8 up to 1/6 of the MCU speed (may be less then 100 kHz)
  +
==== Interface signals ====
  +
If the connection to the target still fails, there is most probably an problem with the interface signals themselves.
  +
Possible reasons:
  +
*Debug signals are not connected
  +
*Debug signals are shared with other peripherals / on board emulators
  +
Possible solutions:
  +
*Disconnect on board emulators or other peripherals which may interact on the target interface lines
  +
*Check the quality of the debug signals using an oscilloscope
   
 
== After programming the target device, J-Link is no longer able to establish a connection ==
 
== After programming the target device, J-Link is no longer able to establish a connection ==
This can have different reasons as for example the application does disable the debug interface, re-configures the debug pins, enters some kind of low-power-mode, etc...In order to prevent such situations during the development process, we recommend to add an delay of one second before the actual application code is executed. This allows to perform a reset and halt the CPU before the CPU executes the "bad code" which would prevent the J-Link to establish a successful connection. Apart from this, we recommend to select the correct device as this allows the J-Link DLL to perform special handling like for example halt in bootloader or connect under reset.
+
This can have different reasons as for example the application does disable the debug interface, re-configures the debug pins, enters some kind of low-power-mode or the security of the device is activated. In order to prevent such situations during the development process, we recommend to
  +
#Add an delay of one second before the actual application code is executed. This allows the debug probe to reset the MCU and to halt it before the MCU executes the "bad code" which would prevent the J-Link to establish a successful connection
  +
#Select the correct device as this allows the J-Link DLL to perform special handling like for example halt in bootloader, connect under reset or unsecure device

Revision as of 08:44, 4 April 2023

There are many different scenarios, which may prevent the J-Link from establishing a successful connection to the target device. The following article refers to the different scenarios and provides information on how to troubleshoot and in the next step how to fix them. In general, we recommend to verify the correct connection between J-Link and the target device using the diagnostic utility J-Link Commander before moving to the actual environment (e.g. Embedded Studio IDE). Therefore, this article refers to J-Link Commander and assumes that the latest J-Link Software and Documentation Pack (incl. J-Link USB driver) is installed. We recommend to work through this article from the beginning to the end.

J-Link connection

First, verify that the connection between the J-Link and PC is functional and J-Link Commander can communicate with the J-Link successfully:

  • Connect J-Link via USB to the PC
  • Start J-Link Commander
  • If the J-Link is functional, you should see that the J-Link Commander reports USB connection O.K. and outputs the firmware string:

Troubleshoot JLinkCommander.png

Connection is unsuccessful

Windows

If the connection is unsuccessful, first check if the J-Link is listed in the Windows Device Manager. If it is not, you can skip the OpenOCD paragraph and continue with Test Connection.

Linux

If the J-Link software package was installed by downloading and unpacking the .tgz archive, additional steps are required in order to enable the J-Link software to connect to J-Links via USB. These steps are described in the README.txt that is shipped with the .tgz archive of the J-Link software. Below is an excerpt of the README.txt of J-Link V7.86f:

[...]
In order to run J-Link/ Flasher software with standard user rights you have to do the following:

- Copy the file "99-jlink.rules" provided with this software package 
  in the /etc/udev/rules.d/ directory using this command:
  
  sudo cp 99-jlink.rules /etc/udev/rules.d/
  
  Note: For older systems it might be necessary to replace the "ATTRS" calls in the 99-jlink.rules by "SYSFS" calls

- Either restart your system or manually trigger the new rules with the following commands:

  sudo udevadm control -R
  sudo udevadm trigger --action=remove --attr-match=idVendor=1366 --subsystem-match=usb
  sudo udevadm trigger --action=add    --attr-match=idVendor=1366 --subsystem-match=usb

Alternatively, the J-Link software can be installed using either the .deb or the .rpm package, both of which are installed using a package manager. The package manager will run the required steps implicitly upon installation of the J-Link software.

OpenOCD

For OpenOCD, a separate J-Link USB driver needs to be installed / used. If the OpenOCD J-Link USB driver is configured, J-Link can be used with OpenOCD but not with ordinary J-Link utilities like for example J-Link Commander. In order to be able to communicate with the J-Link in the native J-Link utilities, the driver needs to be switched back from the J-Link OpenOCD driver to the original J-Link USB driver.

Test Connection

  • Reboot the PC to make sure that the USB protocol itself is not in a confused state
  • Exchange the USB cable
  • Try a different USB slot
  • If a USB hub is used, remove it
  • Verify that the J-Link USB driver is installed
  • Switch to a different PC to exclude PC related issues

Make sure that you are not affected by the issues below:

If you followed the steps above and J-Link Commander is still not able to connect to the J-Link, please get in touch with SEGGER directly via our support system: https://www.segger.com/support/technical-support/. The message should include the answers to the questions below:
If you physically connect the J-Link to the PC via USB:

  • Is the green LED of the J-Link lit?
  • Does the Windows device manager show the J-Link in the list of USB devices?
  • Please send us a screenshot of the J-Link Commander while the J-Link is connected via USB to the PC.

Target connection

In general, we recommend to use an evaluation board to verify the correct functionality between the J-Link and the target device before moving to a custom hardware in order to exclude issues which might be caused by an incorrect hardware design.

Verify functionality using J-Link Commander

Please make sure that you are using the latest software version, available for download here: https://www.segger.com/downloads/jlink

  • Connect the J-Link via USB to the PC
  • Power the target device
  • Connect the target device with the J-Link
  • Start J-Link Commander and follow the startup configuration instructions

Troubleshoot JLinkCommander DeviceConnection.png

Connection is unsuccessful

In case of the connection is still unsuccessful, please follow the troubleshoot instructions below. If you are using an evaluation board and the issue persists after going through the instructions, please get in touch with SEGGER directly via our support system: https://www.segger.com/ticket/.

VTref is 0.000V

J-Link measures 0V target reference voltage. As the target reference voltage is used by the J-Link to create the levels of the debug signals, the reference voltage is mandatory.

  • Check the power supply of the target hardware and verify that it is powered (switches on, jumpers are set correctly, etc...)
  • Measure the voltage between pin 1 (VTref) and pin 4 (GND) of the debug connector, using an multi-meter.
  • If power supply should be provided via J-Link (Pin19), make sure that it's enabled:
    https://wiki.segger.com/J-Link_Commander#Power

Interface settings

On some hardware / devices, only certain debug interfaces are connected and can be used. Another problem can be that the hardware does not allow higher interface speeds.

  • Check that the correct target interface is selected (JTAG, SWD, ...)
  • Reduce the interface speed to 100 kHz
  • For ARM926EJ-S cores, max. JTAG speed == 1/8 up to 1/6 of the MCU speed (may be less then 100 kHz)

Interface signals

If the connection to the target still fails, there is most probably an problem with the interface signals themselves. Possible reasons:

  • Debug signals are not connected
  • Debug signals are shared with other peripherals / on board emulators

Possible solutions:

  • Disconnect on board emulators or other peripherals which may interact on the target interface lines
  • Check the quality of the debug signals using an oscilloscope

After programming the target device, J-Link is no longer able to establish a connection

This can have different reasons as for example the application does disable the debug interface, re-configures the debug pins, enters some kind of low-power-mode or the security of the device is activated. In order to prevent such situations during the development process, we recommend to

  1. Add an delay of one second before the actual application code is executed. This allows the debug probe to reset the MCU and to halt it before the MCU executes the "bad code" which would prevent the J-Link to establish a successful connection
  2. Select the correct device as this allows the J-Link DLL to perform special handling like for example halt in bootloader, connect under reset or unsecure device