Page 1
J-Link / J-Trace User Guide Document: UM08001 Software Version: 6.16e Revision: 0 Date: June 27, 2017 A product of SEGGER Microcontroller GmbH & Co. KG www.segger.com...
Page 2
Please make sure your manual is the latest edition. While the information herein is assumed to be accurate, SEGGER Microcontroller GmbH & Co. KG (SEGGER) assumes no responsibility for any errors or omissions. SEGGER makes and you receive no warranties or conditions, express, implied, statutory or in any communication with you.
Page 3
Chapter “Adding Support for New Devices” added. 6.00 160519 Chapter “Related Software” 5.12f 160503 * Section “J-Link RTT Viewer” updated and moved from section “RTT”. Chapter “Working with J-Link and J-Trace” 5.12d 160427 * Section “J-Link script files” updated. Chapter “Working with J-Link and J-Trace”...
Page 4
151204 Chapter “Semihosting” added. Chapter “Related Software” 5.10 151127 * Section “J-Scope” removed. Chapter “Working with J-Link and J-Trace” * Section “The J-Link settings file” added. 5.02m 151125 Chapter “Low Power Debugging” added. Various Chapters 5.02l 151123 * Some typos corrected.
Table of contents Introduction ........................22 Requirements ....................23 Supported OS ....................24 Common features of the J-Link product family ..........25 Supported CPU cores ..................26 Built-in intelligence for supported CPU-cores ............27 1.5.1 Intelligence in the J-Link firmware ............27 1.5.2 Intelligence on the PC-side (DLL) ............
Page 16
J-Link STM32 Unlock (Command line tool) ........115 3.13 J-Link Software Developer Kit (SDK) ............118 Setup ......................... 119 Installing the J-Link software and documentation pack ........120 4.1.1 Setup procedure ................120 Setting up the USB interface ............... 121 4.2.1 Verifying correct driver installation .............121...
Page 20
J-Trace integration example - IAR Embedded Workbench for ARM ..337 16.3 Embedded Trace Buffer (ETB) ..............341 16.4 Flash programming ................... 342 16.4.1 How does flash programming via J-Link / J-Trace work? ...... 342 16.4.2 Data download to RAM ..............342 16.4.3 Data download via DCC ..............342 16.4.4 Available options for flash programming ...........
Page 21
18.5.2 Breakpoint variant ................. 362 18.5.3 J-Link GDBServer optimized variant ..........362 18.6 Enabling Semihosting in J-Link RDI + AXD ..........363 18.6.1 Using SWIs in your application ............363 Support and FAQs ....................364 19.1 Measuring download speed ................ 365 19.2...
This is the user documentation for owners of SEGGER debug probes, J-Link and J-Trace. This manual documents the software which with the J-Link Software and Documentation Package as well as advanced features of J-Link and J-Trace, like Real Time Transfer (RTT), or Trace.
Requirements Requirements Host System To use J-Link or J-Trace you need a host system running Windows 2000 or later. For a list of all operating systems which are supported by J-Link, please refer to Supported OS on page 24. Target System A target system with a supported CPU is required.
CHAPTER 1 Supported OS Supported OS J-Link/J-Trace can be used on the following operating systems: • Microsoft Windows 2000 • Microsoft Windows XP • Microsoft Windows XP x64 • Microsoft Windows 2003 • Microsoft Windows 2003 x64 • Microsoft Windows Vista •...
Memory viewer (J-Mem) included • Remote server included, which allows using J-Trace via TCP/IP networks • RDI interface available, which allows using J-Link with RDI compliant software • Flash programming software (J-Flash) available • Flash DLL available, which allows using flash functionality in custom applications •...
CHAPTER 1 Supported CPU cores Supported CPU cores J-Link / J-Trace supports any common ARM Cortex core, ARM legacy core, Microchip PIC32 core and Renesas RX core. For a detailed list, please refer to: SEGGER website: Supported Cores If you experience problems with a particular core, do not hesitate to contact SEGGER.
Link firmware. This means, all target sequences (JTAG/SWD/…) are generated on the PC- side and the J-Link simply sends out these sequences and sends the result back to the DLL. Using this way of implementation also allows old J-Links to be used with new CPU cores as long as a DLL-Version is used which has intelligence for the CPU.
CHAPTER 1 Where to find further information Where to find further information The following items are not the scope of the J-Link / J-Trace User Guide (UM08001) and therefore documented elsewhere in the respective place described/listed below. 1.6.1 SEGGER debug probes 1.6.1.1...
Components requiring a license Components requiring a license J-Link PLUS and higher are fully featured J-Links and come with all licenses included. Other models may do not come with all features enabled. For a detailed overview of the included licenses of the SEGGER debug probes, please refer to:...
Use of software SEGGER J-Link software may only be used with original SEGGER products and authorized OEM products. The use of the licensed software to operate SEGGER product clones is pro- hibited and illegal. 2.2.1...
If you are in doubt if your unit may be legally used with SEGGER J-Link software, please get in touch with us. End users may be liable for illegal use of J- Link software with clones.
J-Link Commander (Command line tool) J-Link Commander (Command line tool) J-Link Commander (JLink.exe) is a tool that can be used for verifying proper installation of the USB driver and to verify the connection to the target CPU, as well as for simple analysis of the target system.
Page 38
3.2.1.3 device Selects a specific device J-Link shall connect to and performs a reconnect. In most cases explicit selection of the device is not necessary. Selecting a device enables the user to make use of the J-Link flash programming functionality as well as using unlimited breakpoints in flash memory.
Page 39
Command string to be executed. Command Example exec SupplyPower = 1 3.2.1.6 exit This command closes the target connection, the connection to the J-Link and exits J-Link Commander. Syntax 3.2.1.7 exitonerror This command toggles whether J-Link Commander exits on error or not.
Page 42
CHAPTER 3 J-Link Commander (Command line tool) Syntax hwinfo 3.2.1.18 Closes any existing connection to J-Link and opens a new one via TCP/IP. If no IP Address is specified, the Emulator selection dialog shows up. Syntax ip [<Addr>] Parameter Meaning...
Page 45
This command sets the status of the power supply over pin 19 of the JTAG connector. The KS(Kickstart) versions of J-Link have the 5V supply over pin 19 activated by default. This feature is useful for some targets that can be powered over the JTAG connector.
Page 49
LM3Sxxx DeviceName Kinetis EFM32Gxxx Example unlock Kinetis 3.2.1.46 Closes any existing connection to J-Link and opens a new one via USB. It is possible to select a specific J-Link by port number. Syntax usb [<Port>] Parameter Meaning Valid values: 0..3...
Selects a command file and starts J-Link Commander in batch mode. The batch mode of J-Link Commander is similar to the execution of a batch file. The command file is parsed line by line and one command is executed at a time.
Page 53
3.2.2.8 -JLinkScriptFile Passes the path of a J-Link script file to the J-Link Commander. J-Link scriptfiles are mainly used to connect to targets which need a special connection sequence before communication with the core is possible. For more information about J-Link script files, please refer to J- Link Script Files .
Page 54
-RTTTelnetPort <Port> Example JLink.exe -RTTTelnetPort 9100 3.2.2.12 -SettingsFile Select a J-Link settings file to be used for the target device. The settings file can contain all configurable options of the Settings tab in J-Link Control panel. Syntax -SettingsFile <PathToFile> Example JLink.exe -SettingsFile “C:\Work\settings.txt”...
3.2.3 Using command files J-Link commander can also be used in batch mode which allows the user to use J-Link com- mander for batch processing and without user interaction. Please do not confuse command file with J-Link script files (please refer to J-Link script files for more information about J- Link script files).
IDEs like emIDE or Eclipse. J-Link GDB Server is a remote server for GDB making it possible for GDB to connect to and communicate with the target device via J-Link. GDB Server and GDB communicate via a TCP/IP connection, using the standard GDB remote protocol.
Page 57
(-device) is given, the configuration dialog will not pop up. 3.3.2.2 Setting up GDB Server CL version The command line version of GDB Server is part of the J-Link Software Package for all supported platforms. On Windows its name is JLinkGDBServerCL.exe, on Linux and Mac it is JLinkGDBServer.
Page 58
Stay on top • Show log window. • Generate logfile: If checked, a log file with the GDB <-> GDB Server <-> J-Link communication will be created. • Verify download: If checked, the memory on the target will be verified after download.
3.3.3 Supported remote (monitor) commands J-Link GDB Server comes with some functionalities which are not part of the standard GDB. These functions can be called either via a gdbinit file passed to GDB Server or via monitor commands passed directly to GDB, forwarding them to GDB Server.
Page 61
Performs one or more single instruction steps. SWO DisableTarget Undo target configuration for SWO and disable it in J-Link. SWO EnableTarget Configure target for SWO and enable it in J-Link. Prints the maximum supported SWO speed for J-Link and SWO GetMaxSpeed Target CPU.
Page 64
3.3.3.10 interface Note Deprecated. Use command line option instead. Selects the target interface used by J-Link / J-Trace. Syntax interface <InterfaceIdentifier> 3.3.3.11 jtagconf Configures a JTAG scan chain with multiple devices on it. <IRPre> is the sum of IRLens of all devices closer to TDI, where IRLen is the number of bits in the IR (Instruction Register) of one device.
Page 67
Note There are different reset strategies for different CPUs. Moreover, the reset strategies which are available differ from CPU core to CPU core. J-Link can perform various reset strategies and always selects the best fitting strategy for the selected device.
Page 69
-speed instead. Sets the JTAG speed of J-Link / J-Trace. Speed can be either fixed (in kHz), automatic recognition or adaptive. In general, Adaptive is recommended if the target has an RTCK signal which is connected to the corresponding RTCK pin of the device (S-cores only). For detailed information about the different modes, refer to JTAG Speed .
Page 70
< SWO disabled successfully. 3.3.3.29 SWO EnableTarget Configures the target to be able to output SWO data and starts J-Link to capture it. CPU and SWO frequency can be 0 for auto-detection. If CPUFreq is 0, J-Link will measure the current CPU speed.
Page 71
#Configure SWO for stimulus ports 0-255, fixed CPU and SWO frequency > monitor SWO EnableTarget 72000000 6000000 0xFF 0 < SWO enabled successfully. 3.3.3.30 SWO GetMaxSpeed Prints the maximum SWO speed supported by and matching both, J-Link and the target CPU frequency. Syntax SWO GetMaxSpeed <CPUFrequency [Hz]> Example #Get SWO speed for 72MHz CPU speed >...
3.3.4 SEGGER-specific GDB protocol extensions J-Link GDB Server implements some functionality which are not part of the standard GDB remote protocol in general query packets. These SEGGER-specific general query packets can be sent to GDB Server on the low-level of GDB, via maintenance commands, or with a custom client connected to GDB Server.
Page 73
ReturnValue is hex-encoded. Return value 0 is “00000000”, return value -1 is “FFFFFFFF”. 3.3.4.2 qSeggerSTRACE:start Starts capturing of STRACE data. Note For more information please refer to UM08002 (J-Link SDK user guide), chapter STRACE . Syntax qSeggerSTRACE:start Response <ReturnValue> ReturnValue is a 4 Byte signed integer.
Page 74
3.3.4.4 qSeggerSTRACE:read Reads the last recently called instruction addresses. The addresses are returned LIFO, meaning the last recent address is returned first. Note For more information please refer to UM08002 (J-Link SDK user guide), chapter STRACE . Syntax qSeggerSTRACE:read:<NumItems> Parameter Meaning Maximum number of trace data (addresses) to be read.
Page 75
ReturnValue is the hexadecimal number of bytes in the buffer or empty on error. 3.3.4.9 qSeggerSWO:GetSpeedInfo Returns the base frequency and the minimum divider of the connected J-Link. With this information, the available SWO speeds for J-Link can be calculated and the matching one for the target CPU frequency can be selected.
Command line options There are several command line options available for the GDB Server which allow configu- ration of the GDB Server before any connection to a J-Link is attempted or any connection from a GDB client is accepted. Note Using GDB Server CL, device, interface, endian and speed are mandatory options to correctly connect to the target, and should be given before connection via GDB.
Page 77
-singlerun Starts GDB Server in single run mode. -jlinkscriptfile Specifies a J-Link script file. -select Selects the interface to connect to J-Link (USB/IP). -settingsfile Selects the J-Link Settings File. -strict Starts GDB Server in strict mode. Executes a gdb file on first connection.
Page 78
When using GDB Server CL this option is mandatory to correctly connect to the target, and should be given before connection via GDB. 3.3.5.4 Selects the target interface which is used by J-Link to connect to the device. The default value is JTAG. Syntax -if <Interface>...
Page 83
This command line option prevents GDB Server from closing, to allow connecting a target after starting GDB Server. Note The recommended order is to power the target, connect it to J-Link and then start GDB Server. Syntax -notimeout 3.3.5.19...
Page 84
3.3.5.22 -jlinkscriptfile Passes the path of a J-Link script file to the GDB Server. This scriptfile is executed before the GDB Server starts the debugging / identifying communication with the target. J-Link scriptfiles are mainly used to connect to targets which need a special connection sequence before communication with the core is possible.
Page 85
In normal run mode GDB Server will stay open and wait for new connections. When started in single run mode GDB Server will close immediately when connecting to the target fails. Make sure it is powered and connected to J-Link before starting GDB Server.
Page 86
Currently the device name is checked. If no device name is given or the device is unknown to the J-Link, GDB Server exits instead of selecting “Unspecified” as device or showing the device selection dialog.
3.3.6 Program termination J-Link GDB Server is normally terminated by a close or Ctrl-C event. When the single run mode is active it will also close when an error occurred during start or after all connections to GDB Server are closed.
CHAPTER 3 J-Link GDB Server 3.3.6.1 Exit codes J-Link GDB Server terminates with an exit code indicating an error by a non-zero exit code. The following table describes the defined exit codes of GDB Server. Exit code Description No error. GDB Server closed normally.
J-Link Remote Server J-Link Remote Server allows using J-Link / J-Trace remotely via TCP/IP. This enables you to connect to and fully use a J-Link / J-Trace from another computer. Performance is just slightly (about 10%) lower than with direct USB connection.
Page 90
SEGGER is not possible. Instead the vendor can connect the device via J-Link to a local computer and start the Remote server in tunneling mode. The serial number of the J-Link is then sent to a to an engineer at SEGGER.
Page 91
Start J-Link Remote Server in tunneling mode Connect to the J-Link / J-Trace via J-Link Commander J-Link Commander can be used to verify a connection to the J-Link can be established as follows: Start J-Link Commander From within J-Link Commander enter ip tunnel:<SerialNo>...
J-Flash is an application to program data images to the flash of a target device. With J- Flash the internal flash of all J-Link supported devices can be programmed, as well as common external flashes connected to the device. Beside flash programming all other flash operations like erase, blank check and flash content verification can be done.
CHAPTER 3 J-Link RTT Viewer J-Link RTT Viewer J-Link RTT Viewer is a Windows GUI application to use all features of RTT in one application. It supports: • Displaying terminal output of Channel 0. • Up to 16 virtual Terminals on Channel 0.
Select USB or TCP/IP as the connection to J-Link. For USB a specific J-Link serial number can optionally be entered, for TCP/IP the IP or hostname of the J-Link has to be entered. Select the target device to connect to. This allows J-Link to search in the known RAM of the target.
Page 99
JLinkRTTViewer.exe –interface swd 3.7.7.4 --host Enter the IP address or hostname of the J-Link. This option only applies, if connection type IP is used. Use * as <IPAddr> for a list of available J-Links in the local subnet. Syntax –host <IPAddr>...
CHAPTER 3 J-Link RTT Viewer Example JLinkRTTViewer.exe -rttrange “20000000 400” 3.7.7.9 --autoconnect Let J-Link RTT Viewer connect automatically to the target without showing the Connection Settings (see Connection Settings ). Syntax –autoconnect Example JLinkRTTViewer.exe –autoconnect 3.7.8 Menus and Shortcuts File menu elements...
Command line-only version of SWO Viewer. All commands available for J-Link SWO Viewer can be used with J-Link SWO Viewer Cl. Similar to the GUI Version, J-Link SWO Viewer Cl asks for a device name or CPU clock speed at startup to be able to calculate the correct SWO speed or to connect to a running J-Link GDB Server.
3.8.1 Usage J-Link SWO Viewer is available via the start menu. It asks for a device name or CPU clock speed at startup to be able to calculate the correct SWO speed or to connect to a running J-Link GDB Server.
Page 105
3.8.2.7 -swofreq Define the SWO frequency that shall be used by J-Link SWO Viewer for sampling SWO data. Usually not necessary to define since optimal SWO speed is calculated automatically based on the CPU frequency and the capabilities of the connected J-Link.
3.8.4 Target example code for terminal output /********************************************************************* SEGGER MICROCONTROLLER GmbH & Co KG Solutions for real time microcontroller applications ********************************************************************** (c) 2012-2017 SEGGER Microcontroller GmbH & Co KG www.segger.com Support: support@segger.com ********************************************************************** ---------------------------------------------------------------------- File : SWO.c Purpose : Simple implementation for output via SWO for Cortex-M processors.
Usage SWOAnalyzer.exe <SWOfile> This can be achieved by simply dragging the SWO output file created by the J-Link DLL onto the executable. Creating an SWO output file In order to create the SWO output file, which is the input file for the SWO Analyzer, the J- Link config file needs to be modified.
JTAGLoad is a tool that can be used to open and execute an svf (Serial vector format) file for JTAG boundary scan tests. The data in the file will be sent to the target via J-Link / J-Trace. SVF is a standard format for boundary scan vectors to be used with different tools and targets.
3.11 J-Link RDI (Remote Debug Interface) The J-Link RDI software is a remote debug interface for J-Link. It makes it possible to use J-Link with any RDI compliant debugger. The main part of the software is an RDI-compliant DLL, which needs to be selected in the debugger. here are two additional features available which build on the RDI software foundation.
3.12.1 J-Link STR91x Commander (Command line tool) J-Link STR91x Commander (JLinkSTR91x.exe) is a tool that can be used to configure STR91x cores. It permits some STR9 specific commands like: • Set the configuration register to boot from bank 0 or 1.
Page 113
Quit Command line options J-Link STR91x Commander can be started with different command line options for test and automation purposes. In the following, the command line options which are available for J-Link Commander are explained. All command line options are case insensitive.
Page 114
Selects a command file and starts J-Link STR91x Commander in batch mode. The batch mode of J-Link STR91x Commander is similar to the execution of a batch file. The command file is parsed line by line and one command is executed at a time.
Processor specific tools 3.12.1.5 -SelectEmuBySN Connect to a J-Link with a specific serial number via USB. Useful if multiple J-Links are connected to the same PC and multiple instances of J-Link Commander shall run and each connects to another J-Link.
Page 116
To select from a list of all available emulators on Ethernet, please use * as <IPAddr>. 3.12.2.2 -SelectEmuBySN Connect to a J-Link with a specific serial number via USB. Useful if multiple J-Links are connected to the same PC. Syntax -SelectEmuBySN <SerialNo>...
Page 117
JLinkSTM32.exe -SetDeviceFamily STM32F2xxxx // Selects STM32F2 series} 3.12.2.6 -Exit In general, the J-Link STM32 utility waits at the end of the unlock process for any user input before application closes. This option allows to skip this step, so that the utility closes automatically.
3.13 J-Link Software Developer Kit (SDK) The J-Link Software Developer Kit is needed if you want to write your own program with J- Link / J-Trace. The J-Link DLL is a standard Windows DLL typically used from C programs (Visual Basic or Delphi projects are also possible). It makes the entire functionality of J- Link / J-Trace available through its exported functions, such as halting/stepping the CPU core, reading/writing CPU and ICE registers and reading/writing memory.
Chapter 4 Setup This chapter describes the setup procedure required in order to work with J-Link / J-Trace. Primarily this includes the installation of the J-Link Software and Documentation Package, which also includes a kernel mode J-Link USB driver in your host system.
J-Link is shipped with a bundle of applications, corresponding manuals and some example projects and the kernel mode J-Link USB driver. Some of the applications require an addi- tional license, free trial licenses are available upon request from www.segger.com Refer to chapter J-Link software and documentation package on page 34 for an overview of the J-Link Software and Documentation Pack.
J-Link firmware, the serial number, a target voltage of 0.000V, a complementary error message, which says that the supply voltage is too low if no target is connected to J-Link / J-Trace, and the speed selection. The screenshot below shows an example.
The LED on the J-Link / J-Trace is rapidly flashing. • The J-Link / J-Trace is recognized as Unknown Device by Windows. To have a clean system and help Windows to reinstall the J-Link driver, follow this proce- dure: J-Link / J-Trace (UM08001)
Page 123
1. Disconnect J-Link / J-Trace from your PC. 2. Open the Add/Remove Programs dialog ( Start > Settings > Control Panel > Add/ Remove Programs ) select Windows Driver Package - Segger (jlink) USB and click the Change/Remove button. 3. Confirm the uninstallation process.
In addition to that, you can set a default gateway for the emulator which allows using it even in large intranets. For simplicity the setup process of J-Link Pro (referred to as J-Link) is described in this section.
(use DHCP, IP address, subnet mask, …) of a J-Link supporting the Ethernet interface, SEGGER provides a GUI-based tool, called J-Link Configurator. The J-Link Configurator is part of the J-Link Software and Documentation Package and can be used free of charge. 4.5.1...
Page 128
CHAPTER 4 J-Link Configurator In order to configure an old J-Link, which uses the old USB 0 - 3 USB identification method, to use the new USB identification method (reporting the real serial number) simply select “Real SN” as USB identification method and click the OK button. The same dialog also allows configuration of the IP settings of the connected J-Link if it supports the Ethernet interface.
J-Links are connected to the PC and shows a selection dialog which allows the user to select the appropriate J-Link to connect to. So even in IDEs which do not have an selection option for the J-Link, it is possible to connect to different J-Links.
The J-LinkARM.dll is a standard Windows DLL typically used from C or C++, but also Visual Basic or Delphi projects. It makes the entire functionality of the J-Link / J-Trace available through the exported functions. The functionality includes things such as halting/stepping the ARM core, reading/writing CPU and ICE registers and reading/writing memory.
For a list of supported 3rd-party debuggers and IDEs and documentation on how to get started with those IDEs and J-Link / J-Trace es well as on how to use the advanced features of J-Link / J-Trace with any of them, please refer to:...
J-Link / J-Trace related information and in addition to that it should report that it found a JTAG target and the target’s core ID. The screenshot below shows the output of JLink.exe . As can be seen, it reports a J-Link with one JTAG device connected.
5.3.1 Main indicator For J-Links up to V7, the main indicator is single color (Green). J-Link V8 comes with a bi- color indicator (Green & Red LED), which can show multiple colors: green, red and orange. 5.3.1.1...
5.3.3 Output indicator Some newer J-Links such as the J-Link Pro/Ultra come with additional input/output indica- tors. The output indicator is used to give the user some information about the emulator-to- target connection.
5.4.1 Multiple devices in the scan chain J-Link / J-Trace can handle multiple devices in the scan chain. This applies to hardware where multiple chips are connected to the same JTAG connector. As can be seen in the following figure, the TCK and TMS lines of all JTAG device are connected, while the TDI and TDO lines form a bus.
If only one device is connected to the scan chain, the default configuration can be used. In other cases, J-Link / J-Trace may succeed in automatically recognizing the devices on the scan chain, but whether this is possible depends on the devices present on the scan chain.
The SWD speed which is used for target communication should not exceed target CPU speed * 10 . The maximum SWD speed which is supported by J-Link depends on the hardware version and model of J-Link. For more information about the maximum SWD speed for each J-Link / J-Trace model, please refer to J-Link / J-Trace models on page 29.
Page 142
Example 2 Target CPU running at 10 MHz. Possible SWO output speeds are: 10MHz, 5MHz, 3.33MHz, ... J-Link V7: Supported SWO input speeds are: 6MHz / n, n>= 1: 6MHz, 3MHz, 2MHz, 1.5MHz, ... Permitted combinations are: SWO output SWO input...
All that is required is proper setup of the scan chain for each debugger. This enables J-Link / J-Trace to debug more than one core on a target at the same time. The following figure shows a host, debugging two CPU cores with two instances of the same debugger.
Multi-core debugging 5.6.2 Using multi-core debugging in detail 1. Connect your target to J-Link / J-Trace. 2. Start your debugger, for example IAR Embedded Workbench for ARM. 3. Choose Project|Options and configure your scan chain. The picture below shows the configuration for the first CPU core on your target.
J-Links connected to the same host at the same time. In order to connect to the correct J-Link, the user has to make sure that the correct J-Link is selected (by SN or IP). In cases where no specific J-Link is selected, following pop up will shop and allow the user to select the proper J-Link: The sketch below shows a host, running two application programs.
Page 147
For example, old IAR EWARM versions supports connecting to a J-Link via the USB0-3 method only. As soon as more than one J-Link is connected to the pc, there is no opportunity to pre-select the J-Link which should be used for a debug session.
Since software version V3.86 J-Link the J-Link control panel window allows the user to monitor the J-Link status and the target status information in real-time. It also allows the user to configure the use of some J-Link features such as flash download, flash breakpoints and instruction set simulation.
Page 149
Save settings, otherwise they are lost when the debug session is closed. Section: Flash download In this section, settings for the use of the J-Link FlashDL feature and related settings can be configured. When a license for J-Link FlashDL is found, the color indicator is green and “License found”...
Page 150
Save settings: When this button is pushed, the current settings in the Settings tab will be saved in a configuration file. This file is created by J-Link and will be created for each project and each project configuration (e.g. Debug_RAM, Debug_Flash). If no settings file is given, this button is not visible.
Page 151
Note It is possible for the debugger to bypass the breakpoint functionality of the J-Link soft- ware by writing to the debug registers directly. This means for ARM7/ARM9 cores write accesses to the ICE registers, for Cortex-M3 devices write accesses to the memory mapped flash breakpoint registers and in general simple write accesses for software breakpoints (if the program is located in RAM).
Page 153
J-Link control panel • Status: Shows the encoding and the baudrate of the SWV data received by the target (Manchester/UART, currently J-Link only supports UART encoding). • Bytes in buffer: Shows how many bytes are in the DLL SWV data buffer.
Some CPUs can actually be halted before executing any instruction, because the start of the CPU is delayed after reset release. If a pause has been specified, J-Link waits for the specified time before trying to halt the CPU. This can be useful if a bootloader which resides in flash or ROM needs to be started after reset.
5.9.1.5 Type 4: Hardware, halt with WP The hardware RESET pin is used to reset the CPU. After reset release, J-Link continuously tries to halt the CPU using a watchpoint. This typically halts the CPU shortly after reset release; the CPU can in most systems execute some instructions before it is halted.
Page 156
Type 2: ResetPin J-Link pulls its RESET pin low to reset the core and the peripherals. This normally causes the CPU RESET pin of the target device to go low as well, resulting in a reset of both CPU and peripherals.
Page 157
(reset no longer active) afterwards. 4. Clear VC_CORERESET. This type of reset may fail if: • J-Link has no connection to the debug interface of the CPU because it is in a low power mode. • The debug interface is disabled after reset and needs to be enabled by a device internal bootloader.
Page 158
CHAPTER 5 Reset strategies quest or halted by vector catch). When using this reset strategy, J-Link performs a reset of the CPU and peripherals, using the SYSRESETREQ bit and sets VC_CORERESET in order to halt the CPU after reset, before it executes a single instruction. Then the watchdog of the S3FN60D device is disabled.
DCC handler from time to time. This DCC handler typically requires less than 1 s per call. The DCC handler, as well as the optional DCC abort handler, is part of the J-Link software package and can be found in the Samples\DCC\IAR directory of the package.
Most IDEs provide a path to a J-Link settings file on a per-project-per-debug-configuration basis. This file is used by J-Link to store various debug settings that shall survive between debug sessions of a project. It also allows the user to perform some override of various settings.
J-Link software. J-Link script files are written in C-like syntax in order to have an easy start to learning how to write J-Link script files. The script file syntax supports most statements (if-else, while, declaration of variables, …) which are allowed in C, but not all of them.
Page 162
Currently this function is only used to configure whether the target which is connected to J-Link has an ETB or not. For more information on how to configure the existence of an ETB, please refer to Global DLL variables .
Page 164
This makes sense on targets on which J-Link can not perform a auto-detection of the APs which are present on the target system. Type can only be a known global J-Link DLL AP constant. For a list of all available constants, please refer to Global DLL constants .
Page 165
For SWD The JTAG -> SWD switching sequence is output. It is also made sure that the “overrun mode enable” bit in the SW-DP CTRL/STAT register is cleared, as in SWD mode J-Link always assumes that overrun detection mode is disabled.
Page 167
Error Not supported by the current CPU + target interface combination Example JLINK_CORESIGHT_WriteDAP(JLINK_CORESIGHT_DP_REG_ABORT, 0, 0x1E); 5.12.2.8 JLINK_ExecCommand() Gives the option to use Command strings in the J-Link script file. Prototype int JLINK_ExecCommand(const char* sMsg); Example JLINK_ExecCommand("TraceSampleAdjust TD=2000"); Note Has no effect when executed in Flasher stand-alone mode or when calling this function from a function that implements the __probe attribute.
Page 171
Prototype int JLINK_SYS_Report1(const char * sMsg, int v); 5.12.2.34 JLINK_SYS_Sleep() Waits for a given number of milliseconds. During this time, J-Link does not communicate with the target. Prototype int JLINK_SYS_Sleep(int Delayms); 5.12.2.35 JLINK_SYS_UnsecureDialog() Informs the user that the device needs to be unsecured for further debugging.
Page 173
CHAPTER 5 J-Link script files Variable Description J-Link. This variable can only be set to a known glob- al J-Link DLL constant. For a list of all valid values, please refer to Global DLL constants Example CPU = ARM926EJS; Used for JTAG chain configuration. Sets the number of IR-bits of all devices which are closer to TDO than the one we want to communicate with.
Page 174
Example JLINK_TRACE_Portwidth = 4; If the connected device has an ETB and you want to use it with J-Link, this variable should be set to 1. Set- ting this variable in another function as InitEmu() does not have any effect.
Page 175
CORESIGHT_IndexAPBAPToUse = 2; Overrides the default settings to be used by the DLL when configuring the AHB-AP CSW register. By de- fault, the J-Link DLL will use the following settings for the CSW: Cortex-M0, M0+, M3, M4 [30] = 0...
5.12.5 Script file language The syntax of the J-Link script file language follows the conventions of the C-language, but it does not support all expressions and operators which are supported by the C-language. In the following, the supported operators and expressions are listed.
5.12.6 Script file writing example In the following, a short example of how a J-Link script file could look like. In this example we assume a JTAG chain with two devices on it (Cortex-A8 4 bits IRLen, custom device 5-bits IRLen).
5.13 Command strings The behavior of the J-Link can be customized via command strings passed to the JLinkAR- M.dll which controls J-Link. Applications such as J-Link Commander, but also the C-SPY debugger which is part of the IAR Embedded Workbench, allow passing one or more com- mand strings.
Page 181
Restores the default mapping, which means all memory accesses map reset are permitted. Specifies a file or directory which should be used by the J-Link ProjectFile DLL to save the current configuration. Reads the given memory area into the streaming trace instruc- ReadIntoTraceCache tion cache.
Page 182
This command is used to select a specific APB-AP to be used when connected to an ARM Cortex-A or Cortex-R device. Usually, it is not necessary to explicitly select an AHB-AP to be used, as J-Link auto-detects the AP automatically. For multi-core systems with multiple APB-APs it might be necessary.
Page 183
5.13.1.6 DisableCortexMXPSRAutoCorrectTBit Usually, the J-Link DLL auto-corrects the T-bit of the XPSR register to 1, for Cortex-M devices. This is because having it set as 0 is an invalid state and would cause several problems during debugging, especially on devices where the erased state of the flash is 0x00 and therefore on empty devices the T-bit in the XPSR would be 0.
Page 184
This command is used to disable the flash download information window for the flash down- load feature. Enabled by default. Syntax DisableInfoWinFlashDL 5.13.1.11 DisableMOEHandling The J-Link DLL outputs additional information about mode of entry (MOE) in case the target CPU halted / entered debug mode. Disabled by default. Syntax DisableMOEHandling 5.13.1.12 DisablePowerSupplyOnClose This command is used to ensure that the power supply for the target will be disabled on close.
Page 185
EnableInfoWinFlashDL 5.13.1.19 EnableMOEHandling The J-Link DLL outputs additional information about mode of entry (MOE) in case the target CPU halted / entered debug mode. Disabled by default. Additional information is output via log-callback set with JLINK_OpenEx(JLINK_LOG* pfLog, JLINK_LOG* pfErrorOut) Syntax EnableMOEHandling 5.13.1.20...
Page 186
To avoid stalling the debug session, a critical memory area can be excluded from access: J-Link will not try to read or write to critical memory areas and instead ignore the access silently. Some debuggers (such as IAR C-SPY) can try to access memory in such areas by dereferencing non-initialized pointers even if the debugged program (the debuggee) is working perfectly.
Page 187
0x00080000-0x3FFFFFFF Reserved 0x40008000-0x7FCFFFFF Reserved 0x7FD02000-0x7FD02000 Reserved 0x80000000-0xDFFFFFFF To exclude these areas from being accessed through J-Link the map exclude command should be used as follows: map exclude 0x00080000-0x3FFFFFFF map exclude 0x40008000-0x7FCFFFFF map exclude 0x7FD02000-0x7FD02000 map exclude 0x80000000-0xDFFFFFFF 5.13.1.27 map illegal This command marks a specified memory region as an illegal memory area.
Page 189
5.13.1.32 ProjectFile This command is used to specify a file used by the J-Link DLL to save the current config- uration. Using this command is recommended if settings need to be saved. This is typically the case if Flash breakpoints are enabled and used. It is recommended that an IDE uses this command to allow the JLinkARM.dll to store its settings in the same directory as the project...
Page 190
5.13.1.34 ScriptFile This command is used to set the path to a J-Link script file which shall be executed. J-Link scriptfiles are mainly used to connect to targets which need a special connection sequence before communication with the core is possible.
Page 191
SetAllowSimulation 1 // Enables instruction set simulation 5.13.1.38 SetBatchMode This command is used to tell the J-Link DLL that it is used in batch-mode / automatized mode, so some dialogs etc. will automatically close after a given timeout. Disabled by default.
Page 192
The IDCODE stream is expected as a hex-encoded byte stream. If the CPU e.g. works on a word-basis for the IDCODE, this stream is interpreted as a little endian formatted stream where the J-Link library then loads the words from and passes them to the device during connect.
Page 193
5.13.1.46 SetFlashDLNoRMWThreshold This command sets the J-Link DLL internal threshold when a write to flash memory does not cause a read-modify-write (RMW) operation. For example, when setting this value to 0x800, all writes of amounts of data < 2 KB will cause the DLL to perform a read-modify-write operation on incomplete sectors.
Page 195
5.13.1.53 SetResetType This command selects the reset strategy which shall be used by J-Link, to reset the device. The value which is used for this command is analog to the reset type which shall be selected. For a list of all reset types which are available, please refer to Reset strategies . Please note that there different reset strategies for ARM 7/9 and Cortex-M devices.
Page 196
Example SetRTTTelnetPort 9100 5.13.1.57 SetRTTSearchRanges In some cases J-Link cannot locate the RTT buffer in known RAM. This command is used to set (multiple) ranges to be searched for the RTT buffer. Syntax SetRTTSearchRanges <RangeAddr> <RangeSize> [, <RangeAddr1> <RangeSize1>, ..]...
Page 197
5.13.1.60 SetSysPowerDownOnIdle When using this command, the target CPU is powered-down when no transmission between J-Link and the target CPU was performed for a specific time. When the next command is given, the CPU is powered-up. Note This command works only for Cortex-M3 devices.
Page 198
Description All sectors using checksum Example SetVerifyDownload = 1 // Select programmed sectors, fastest method 5.13.1.62 SetWorkRAM This command can be used to configure the RAM area which will be used by J-Link. Syntax SetWorkRAM <StartAddressOfArea>-<EndAddressOfArea> Example SetWorkRAM 0x10000000-0x100FFFFF 5.13.1.63 ShowControlPanel Executing this command opens the control panel.
Leave everything as it is, do not add any characters. Example SWOSetConversionMode = 0 5.13.2 Using command strings For instructions on how to execute J-Link script files depending on the debug environment used, please refer to: SEGGER Wiki: Getting Started with Various IDEs 5.13.2.1 In J-Link commander The J-Link command strings can be tested with the J-Link Commander.
5.15.4 Cache handling of ARM9 cores ARM9 cores with cache require J-Link / J-Trace to handle the caches during debug. If the processor enters debug state with caches enabled, J-Link / J-Trace does the following: When entering debug state J-Link / J-Trace performs the following: •...
J-Link Commander and J-Link Configurator. Below, a small description of how to use use them to configure the feature is given. Note VCOM can only be used when debugging via SWD target interface. Pin 5 = J-Link-Tx (out), Pin 17 = J-Link-Rx (in). Note Currently, only J-Link models with hardware version 9 or newer comes with VCOM capabilities.
Introduction Introduction The J-Link DLL comes with a lot of flash loaders that allow direct programming of internal flash memory for popular microcontrollers. Moreover, the J-Link DLL also allows program- ming of CFI-compliant external NOR flash memory. The flash download feature of the J- Link DLL does not require an extra license and can be used free of charge.
CHAPTER 6 Supported devices Supported devices J-Link supports download into the internal flash of a large number of microcontrollers. You can always find the latest list of supported devices on our website: List of supported target devices In general, J-Link can be used with any ARM7/ARM9/ARM11, Cortex-M0/M1/M3/M4/M7/ M23/M33, Cortex-A5/A7/A8/A9/A12/A15/A17 and Cortex-R4/R5 core even if it does not provide internal flash.
A few debuggers come with their own flashloaders and need to be configured to use the J- Link flashloader in order to achieve the maximum possible performance. For further information on how to specify the target device and on how to use the J-Link flashloader in different debuggers, please refer to:...
Specifying of the CFI area is done in a J-Link script file, as explained below. For further information on J-Link script files, please refer to J-Link Script Files and for further information on how to use J-Link script files with different debuggers, please refer to:...
Setup for various debuggers (SPIFI flash) Setup for various debuggers (SPIFI flash) The J-Link DLL supports programming of SPIFI flash and the J-Link flash download feature can be used therefore by different debuggers, such as IAR Embedded Work bench, Keil MDK, GDB based IDEs, …...
QSPI flash support QSPI flash support The J-Link DLL also supports programming of any (Q)SPI flash connected to a device that is supported by the J-Link DLL, if the device allows memory-mapped access to the flash. Most modern MCUs / CPUs provide a so called “QSPI area” in their memory-map which allows the CPU to read-access a (Q)SPI flash as regular memory (RAM, internal flash etc.).
Using the DLL flash loaders in custom applications The J-Link DLL flash loaders make flash behave as RAM from a user perspective, since flash programming is triggered by simply calling the J-Link API functions for memory reading / writing. For more information about how to setup the J-Link API for flash programming...
Debugging applications that change flash contents at runtime The J-Link DLL cashes flash contents in order to improve overall performance and therefore provide the best debugging experience possible. In case the debugged application does change the flash contents, it is necessary to disable caching of the effected flash range.
Introduction Introduction The J-Link DLL supports a feature called flash breakpoints which allows the user to set an unlimited number of breakpoints in flash memory rather than only being able to use the hardware breakpoints of the device. Usually when using hardware breakpoints only, a maximum of 2 (ARM 7/9/11) to 8 (Cortex-A/R) breakpoints can be set.
Link. For some devices J-Link comes with a device-based license and some J-Link models also come with a full license for flash breakpoints but the normal J-Link comes without any licenses. For more information about licensing itself and which devices have a device-based...
CHAPTER 7 Supported devices Supported devices J-Link supports flash breakpoints for a large number of microcontrollers. You can always find the latest list of supported devices on our website: List of supported target devices In general, J-Link can be used with any ARM7/ARM9/ARM11, Cortex-M0/M1/M3/M4/M7/ M23/M33, Cortex-A5/A7/A8/A9/A12/A15/A17 and Cortex-R4/R5 core even if it does not provide internal flash.
J-Link control panel: 7.4.2 Compatibility with various debuggers Flash breakpoints can be used in all debugger which use the proper J-Link API to set break- points. Compatible debuggers/ debug interfaces are: •...
Why can flash breakpoints not be used with Rowley Crossworks? Because Rowley Cross- works does not use the proper J-Link API to set breakpoints. Instead of using the break- point-API, Crossworks programs the debug hardware directly, leaving J-Link no choice to use its flash breakpoints.
1. Halt mode 2. Monitor mode Halt mode is the default debug mode used by J-Link. In this mode the CPU is halted and stops program execution when a breakpoint is hit or the debugger issues a halt request. This means that no parts of the application continue running while the CPU is halted (in debug mode) and peripheral interrupts can only become pending but not taken as this would require execution of the debug interrupt handlers.
Enable Monitor Debugging Enable Monitor Debugging As explained before, by default J-Link uses halt mode debugging. In order to enable mon- itor mode debugging, the J-Link software needs to be explicitly told to use monitor mode debugging. This is done slightly differently from IDE to IDE. In general, the IDE does not notice any difference between halting and monitor debug mode.
A CPU core-specific monitor code is necessary to perform monitor mode debugging with J- Link. This monitor performs the communication with J-Link while the CPU is in debug mode (meaning in the monitor exception). The monitor code needs to be compiled and linked as a normal part of the application.
ISRs from the user application vector table. For such cases, it is impossible for J-Link to automatically check for the existence of a monitor mode handler as the handler is usually linked in the user application and not in the additional software layer, so the DLL will automatically switch back to halt mode debugging.
However, there is a small window in which it can happen that a breakpoint is hit before J-Link has restored the monitor bits. If this happens, instead of entering debug mode, a HardFault is triggered. To avoid hanging of the application, a special version of the Hard- Fault_Handler is needed which detects if the reason for the HardFault was a breakpoint and if so, just ignores it and resumes execution of the target application.
“check if CPU is halted/hit a BP”. To avoid this, there is a special setting for J-Link that can be activated, to handle such cases in a better way, which is explained in the following.
While usually the J-Link DLL handles communication losses as errors, there is a possibili- ty to enable low power mode handling in the J-Link DLL, which puts the DLL into a less restrictive mode (low-power handling mode) when it comes to such loss-cases. The low-...
J-Link does it’s best to handle cases where one or more of the above restrictions is not considered but depending on how the IDE reacts to specific operations to fail, error mes- sages may appear or the debug session will be terminated by the IDE.
SEGGER and a new release of the J-Link soft- ware package being available. The J-Link DLL allows customers to add support for new devices on their own. It is also possible to edit/extend existing devices of the device database by for example adding new flash banks (e.g.
XML file. The DLL is looking for this file in the same directory where the J-Link settings file is located. The location of the settings file depends on the IDE / software being used. For more information about where the settings file is located for...
CHAPTER 10 Adding a new device 10.3 Adding a new device In order to add support for a new device to the J-Link DLL, the following needs to be added to the JLinkDevices.xml : <Database> <Device> <ChipInfo Vendor="..." Name="..." WorkRAMAddr="..."...
CHAPTER 10 Editing/Extending an Existing Device 10.4 Editing/Extending an Existing Device In order to edit/extend a device that is already in the built-in device database of the J-Link DLL, the following needs to be added to the JLinkDevices.xml : <Database> <Device>...
Name E.g. Name=“STM32F407IE” Hexadecimal value that specifies the address of a RAM area that can be used by J-Link during flash programming etc. Should not be used by any DMAs on the device. Cannot exist WorkRAMAddr without also specifying WorkRAMSize. If no flash banks are added for the new device, this attribute is optional.
Page 241
For a list of valid attribute values, please refer to Attribute values - Core . String that specifies the path to a J-Link script file if required for the device. Path can be relative or absolute. If path is JLinkScriptFile relative, is relative to the location of the JLinkDevices.xml...
10.5.4 <FlashBankInfo> Specifies a flash bank for the device. This allows to use the J-Link flash download func- tionality with IDEs, debuggers and other software that uses the J-Link DLL (e.g. J-Link Commander) for this device. The flash bank can then be programmed via the normal flash download functionality of the J-Link DLL.
Page 243
XML Tags and Attributes Parameter Meaning Hexadecimal value that specifies the start address of the flash bank. The J-Link DLL uses this attribute together with MaxSize to determine which memory write accesses per- formed by the debugger, shall be redirected to the flash...
CMSIS Flash Algorithms Compatibility CMSIS flash algorithms are also supported by the Open Flashloader concept. Therefore, an existing *.FLM file can be simply referenced in a J-Link XML device description file. The LoaderType attribute needs to be set to FLASH_ALGO_TYPE_OPEN .
SPI flashes, without any additional hardware. Both, J-Flash SPI and J-Flash SPI CL are part of the J-Link Software and Documentation Package which is available free of charge. This chapter assumes that you already possess working knowledge of the J-Link device.
Flash SPI requires a J-Link or Flasher to interface to the hardware. It is able to program all kinds of SPI flashes, even if the CPU they are connected to, is not supported by J-Link / Flasher because J-Flash SPI communicates directly with the SPI flash bypassing all other components of the hardware.
J-Flash SPI requires a PC running one of the supported operating system (see above) with a free USB port dedicated to a J-Link. A network connection is required only if you want to use J-Flash SPI together with J-Link Remote Server.
The following chapter provides an overview of J-Flash SPI related licensing options. 11.2.1 Introduction A J-Link PLUS, ULTRA+, PRO or Flasher ARM/PRO is required to use J-Flash SPI. No addi- tional license is required / available. J-Link / J-Trace (UM08001)
This chapter presents an introduction to J-Flash SPI. It provides an overview of the included sample projects and describes the menu structure of J-Flash SPI in detail. 11.3.1 Setup For J-Link setup procedure required in order to work with J-Flash SPI, please refer to chapter Setup on page 119. 11.3.1.1 What is included? Tons of defines.
Page 252
Opens and/or sets the focus to the project window. Target menu elements Command Description Creates a connection through the J-Link using the configura- Connect tion options set in the Project settings… of the Options dropdown menu. Disconnects a current connection that has been made through Disconnect the J-Link.
Page 253
A entry of the list can be selected to move the focus to the re- open windows> spective window. Help menu elements Command Description Opens the J-Link Manual (UM08001) in the default .PDF applica- J-Link User Guide tion of the system. About… J-Flash SPI and company information. J-Link / J-Trace (UM08001)
This dialog is used to choose the connection to J-Link. The J-Link can either be connected over USB or via TCP/IP to the host system. Refer to the J-Link Manual (UM08001) for more information regarding the operation of J-Link and J-Link Remote Server.
Page 255
Init steps and Exit steps which can be used to execute custom command sequences. Interface Speed Specifies the SPI communication speed J-Link uses to communicate with the SPI flash. Init and Exit steps Can be used to add custom command sequences like for example write protection register.
Page 259
Enable J-Link logfile If this option is checked, you can specify a file name for the J-Link logfile. The J-Link logfile differs from the log window output of J-Flash SPI. It does not log J-Flash SPI operations performed.
In order to program multiple targets in parallel using J-Flash SPI, the following is needed: • Multiple J-Flash SPI projects, each configured to connect to a specific J-Link / Flasher (emulator to connect to is selected by serial number). The easiest way is to setup the appropriate project once and then make multiple copies of this project.
Page 263
CHAPTER 11 Command Line Interface @ECHO OFF ECHO Open first project which is configured to connect to the first J-Link. ECHO Open data file, start auto processing and exit open JFlashSPI.exe -openprjC:\\Projects\\Project01.jflash -openC:\\Data\ \data.bin, 0x100000 -auto -exit IF ERRORLEVEL goto ERROR ECHO Open second project which is configured to connect to the second J-Link.
1. Select File -> New Project to create a new project with default settings. 2. Open the Project Settings context menu. Select Options -> Project Settings to open the Project settings dialog and select the type of connection to J-Link. 3. Define the SPI communication speed. The default settings work without any problem for most targets, but to achieve the last quantum of performance, manual tuning may be necessary.
Page 267
Below is a small example excerpt from a J-Flash project, which shows a example sequence to erase sector 0 of the SPI flash using the 0xD8 command. Further examples can be found in the installation directory of the J-Link software and documentation package. [CPU] // Set write enable ExitStep0_Action = "Activate CS"...
11.10.1 Performance values In direct programming mode (J-Link directly connects to the pins of the SPI flash), the programming speed is mainly limited by the SPI communication speed, the USB speed of J-Link (if a Full-Speed or Hi-Speed based J-Link is used) and the maximum programming speed of the flash itself.
11.11.1 SPI interface connection For direct SPI flash programming, J-Link needs to be wired to the SPI flash in a specific way. For more information about the pinout for the J-Link SPI target interface, please refer to the J-Link Manual (UM08001). The minimum pins that need to be connected, are: VTref, GND, SPI-CLK, MOSI, MISO.
J-Link could not measure the target (flash) reference voltage on pin 1 of its connector. Remedy: The target interface of J-Link works with level shifters to be as flexible as possible. There- fore, the reference I/O voltage the flash is working with also needs to be connected to pin 1 of the J-Link connector.
/ debug probe interface. It is defined only for cores that have the same CPU register set as ARM7 CPUs. This chapter describes how to use the RDI DLL which comes with the J-Link Software and Documentation Package. The J-Link RDI DLL allows the user to use J- Link with any RDI-compliant debugger and IDE.
J-Link RDI mainly consists of a DLL designed for ARM cores to be used with any RDI compliant debugger. The J-Link DLL feature flash download and flash breakpoints can also be used with J-Link RDI.
12.2 Licensing In order to use the J-Link RDI software a separate license is necessary for each J-Link. For some devices J-Link comes with a device-based license and some J-Link models also come with a full license for J-Link RDI. The normal J-Link however, comes without any licenses.
SEGGER Wiki: Getting Started with Various IDEs for information on how to get started with any IDE officially supported by J-Link / J-Trace. If official support is not implemented natively but via RDI, the RDI setup procedure will also be explained there.
Page 278
3. Now J-Link RDI is available in the Target Environments list. 4. Select J-Link and press OK to connect to the target via J-Link. For more information about the generic setup of J-Link RDI, please refer to Configuration on page 287. After...
ARM RVDS (RealView developer suite) Software version J-Link RDI has been tested with ARM RVDS version 2.1 and 3.0. There should be no prob- lems with earlier versions of RVDS (up to version v3.0.1). All screenshots are taken from ARM’s RVDS version 2.1.
Page 281
OK, Short Name: JLinkRDI Description: J-Link RDI Interface. 6. Back in the RDI Target List Dialog, select JLink-RDI and click Configure. For more information about the generic setup of J-Link RDI, please refer to Configuration on page 287.
Page 282
7. Click the OK button in the configuration dialog. Now close the RDI Target List dialog. Make sure your target hardware is already connected to J-Link. 8. In the Connection control dialog, expand the JLink ARM RDI Interface and select the ARM_0 processor.
12.3.3 GHS MULTI Software version J-Link RDI has been tested with GHS MULTI version 4.07. There should be no problems with other versions of GHS MULTI. All screenshots are taken from GHS MULTI version 4.07. Configuring to use J-Link RDI 1.
Page 285
Setup for various debuggers 5. Confirm the choices by clicking the Apply button after the Connect button. 6. The J-Link RDI Configuration dialog will open. For more information about the generic setup of J-Link RDI, please refer to Configuration on page 287.
CHAPTER 12 Configuration 12.4 Configuration This section describes the generic setup of J-Link RDI (same for all debuggers) using the J-Link RDI configuration dialog. 12.4.1 Configuration file JLinkRDI.ini All settings are stored in the file JLinkRDI.ini. This file is located in the same directory as JLinkRDI.dll.
General tab Connection to J-Link This setting allows the user to configure how the DLL should connect to the J-Link. Some J- Link models also come with an Ethernet interface which allows to use an emulator remotely via TCP/IP connection.
Page 289
Init tab Macro file A macro file can be specified to load custom settings to configure J-Link RDI with advanced commands for special chips or operations. For example, a macro file can be used to initialize a target to use the PLL before the target application is downloaded, in order to speed up the download.
Page 292
Furthermore it is necessary for some chips to enter the correct CPU clock frequen- Cache flash contents If enabled, the flash content is cached by the J-Link RDI software to avoid reading data twice and to speed up the transfer between debugger and target.
Page 294
12.4.4.7 Log tab A log file can be generated for the J-Link DLL and for the J-Link RDI DLL. This log files may be useful for debugging and evaluating. They may help you to solve a problem yourself, but is also needed by customer support help you.
The default implementation uses one channel per direction, which are meant for printable terminal input and output. With the J-Link RTT Viewer this channel can be used for multiple “virtual” terminals, allowing to print to multiple windows (e.g. one for standard output, one for error output, one for debugging output) with just one target buffer.
When RTT is active on the host computer, either by using RTT directly via an application like RTT Viewer or by connecting via Telnet to an application which is using J-Link, like a debugger, J-Link automatically searches for the SEGGER RTT Control Block in the target’s known RAM regions.
13.2.4 Requirements SEGGER RTT does not need any additional pin or hardware, despite a J-Link connected via the standard debug port to the target. It does not require any configuration of the target or in the debugging environment and can even be used with varying target speeds.
The application is part of the J-Link Software and Documentation Pack for Windows, Linux and OS X. The source of J-Link RTT Logger can be used as a starting point to integrate RTT in other PC applications, like debuggers, and is part of the J-Link SDK.
13.4 Implementation The SEGGER RTT implementation code is written in ANSI C and can be integrated into any embedded application by simply adding the available sources. RTT can be used via a simple and easy to use API. It is even possible to override the standard printf() functions to be used with RTT.
Page 304
Example c = SEGGER_RTT_GetKey(); (c == 'q') { exit(); 13.4.1.4 SEGGER_RTT_HasKey() Checks if at least one character for reading is available in SEGGER RTT buffer. Syntax int SEGGER_RTT_HasKey (void); Return value Value Meaning At least one character is available in the buffer.
Page 305
Error. Example SEGGER_RTT_printf(0, "SEGGER RTT Sample. Uptime: %.10dms.", /*OS_Time*/ 890912); // Formatted output on channel 0: SEGGER RTT Sample. Uptime: 890912ms. Additional information (1) Conversion specifications have following syntax: • %[flags][FieldWidth][.Precision]ConversionSpecifier (2) Supported flags: • -: Left justify within the field width •...
Page 307
With SEGGER_RTT_Write() all kinds of data, not only printable one can be sent. 13.4.1.11 SEGGER_RTT_WaitKey() Waits until at least one character is available in SEGGER RTT buffer 0. Once a character is available, it is read and returned. Syntax int SEGGER_RTT_WaitKey (void);...
AP which is the AHB-AP that shall be used for RTT background memory access, needs to be manually specified. This is done via the following J-Link Command string: CORESIGHT_SetIndexAHBAPToUse . For more information about how to use J-Link command strings in various environments, please refer to Using command strings . J-Link / J-Trace (UM08001)
13.6 Example code /********************************************************************* SEGGER MICROCONTROLLER GmbH & Co KG Solutions for real time microcontroller applications ********************************************************************** (c) 2014-2017 SEGGER Microcontroller GmbH & Co KG www.segger.com Support: support@segger.com ********************************************************************** ---------------------------------------------------------------------- File : RTT.c Purpose : Simple implementation for output via RTT.
Q: I do not see any output, although the use of RTT in my application is correct. What can I do? A: In some cases J-Link cannot locate the RTT buffer in the known RAM region. In this case the possible region or the exact address can be set manually via a J-Link exec command: •...
(e.g. ARM that provides the ETM as a trace component for their cores). For more information about what timings need to be met for a specific J-Trace model, please refer to J-Link / J-Trace models . 14.2.3...
This allows to also do trace on such targets with a regular J-Link, as the on-chip trace buffer can be read out via the regular debug interface J-Link uses to communicate with the target CPU.
(would lead to a too big performance drop), a copy of the application contents is cached in the J-Link software at the time the application download is performed. This implies that streaming trace is only possible with prior download of the application in the same debug session.
IDC sockets mounted on a ribbon cable. *On later J-Link products like the J-link ULTRA, these pins are reserved for firmware exten- sion purposes. They can be left open or connected to GND in normal debug environment.
Page 323
CHAPTER 15 20-pin J-Link connector Pins 4, 6, 8, 10, 12, 14, 16, 18, 20 are GND pins connected to GND in J-Link. They should also be connected to GND in the target system. 15.1.1.1 Target board design We strongly advise following the recommendations given by the chip manufacturer. These recommendations are normally in line with the recommendations given in the table Pinout for JTAG on page 322.
Target power supply . Pins 4, 6, 8, 10, 12, 14, 16, 18, 20 are GND pins connected to GND in J-Link. They should also be connected to GND in the target system.
15.1.3 Pinout for SWD + Virtual COM Port (VCOM) The J-Link and J-Trace JTAG connector is also compatible to ARM’s Serial Wire Debug (SWD). *On later J-Link products like the J-link ULTRA, these pins are reserved for firmware exten- sion purposes. They can be left open or connected to GND in normal debug environment.
15.1.4 Pinout for SPI *On later J-Link products like the J-link ULTRA, these pins are reserved for firmware exten- sion purposes. They can be left open or connected to GND in normal debug environment. The following table lists the pinout for the SPI interface on J-Link.
Output nected to TDI of the target CPU. For CPUs which do not pro- vide TDI (SWD-only devices), this pin is not used. J-Link will ignore the signal on this pin when using SWD. Not connected inside J-Link. Leave open on target hardware.
Page 329
CHAPTER 15 19-pin JTAG/SWD and Trace connector against overload and short-circuit. Power can be controlled via the J-Link commander. The following commands are available to control power: Command Explanation Switch target power on power on Switch target power off power off perm Set target power supply default to “on”...
Output ly connected to TDI of the target CPU. For CPUs which do not provide TDI (SWD-only devices), this pin is not used. J-Link will ignore the signal on this pin when using SWD. By default, TRST is not connected, but the Cortex-M Adapter...
15.4 Reference voltage (VTref) VTref is the target reference voltage. It is used by the J-Link to check if the target has power, to create the logic-level reference for the input comparators and to control the output logic levels to the target. It is normally fed from Vdd of the target board and must not have a series resistor.
CHAPTER 15 Adapters 15.5 Adapters There are various adapters available for J-Link as for example the JTAG isolator, the J-Link RX adapter or the J-Link Cortex-M adapter. For more information about the different adapters, please refer to J-Link adapters J-Link / J-Trace (UM08001)
No additional special trace port is required, so that the ETB can be read via J-Link. The trace functionality via J-Link is limited by the size of the ETB. While capturing runs, the trace information in the buffer will be overwritten every time the buffer size has been reached.
In this case, the RAM code is started as described above before downloading any data. The RAM code then communicates with the host computer (via DCC, JTAG and J-Link / J- Trace), transferring data to the target. The RAM code then programs the data into flash and waits for new data from the host.
Every time you connect to J-Link / J-Trace, JLinkARM.dll checks if its embedded firmware is newer than the one used the J-Link / J-Trace. The DLL will then update the firmware automatically. This process takes less than 3 seconds and does not require a reboot.
18.3.3 J-Link GDBServer optimized version When using J-Link GDBServer with a GDB-based environment, there is a third implemen- tation for semihosting available which is a hybrid of the other implementations, combining the advantages of both. With this implementation, an SVC instruction with the usual SVC reason is used to issue a semihosting call but the debugger does not set a breakpoint or vector catch on the start of the SVC exception handler.
Page 354
18.3.3.1 SVC exception handler sample code In the following, some sample code for the SVC handler, prepared to be used with J-Link GDBServer optimized semihosting, is given: SVC_Handler: ; For semihosting R0 and R1 contain the semihosting information and may not ;...
CHAPTER 18 Enabling semihosting in J-Link GDBServer 18.5 Enabling semihosting in J-Link GDBServer By default, semihosting is disabled in J-Link GDBServer. Depending on the mechanism to be used, different setups are necessary 18.5.1 SVC variant The following commands need to be added to the gdbinit file that is executed at the start...
The S bit in $vector_catch has no effect unless semihosting is disabled. $semihosting_vector This variable controls the location of the breakpoint set by J-Link RDI to detect a semihosted SWI. It is set to the SWI entry in the exception vector table () by default.
This chapter contains troubleshooting tips as well as solutions for common problems which might occur when using J-Link / J-Trace. There are several steps you can take before con- tacting support. Performing these steps can solve many problems and often eliminates the need for assistance.
Troubleshooting 19.2 Troubleshooting 19.2.1 General procedure If you experience problems with J-Link / J-Trace, you should follow the steps below to solve these problems: • Close all running applications on your host system. • Disconnect the J-Link / J-Trace device from USB.
PC and if possible with another target system to see if it works there. If the device functions correctly, the USB setup on the original machine or your target hardware is the source of the problem, not J-Link / J-Trace. If you need to contact support, send the following information to support@segger.com :...
Need help?
Do you have a question about the J-Link and is the answer not in the manual?
Questions and answers