UM08001 JLink
UM08001 JLink
User Guide
Document: UM08001
www.segger.com
2
Disclaimer
Specifications written in this document are believed to be accurate, but are not guar-
anteed to be entirely free of error. The information in this manual is subject to
change for functional or performance improvements without notice. Please make sure
your manual is the latest edition. While the information herein is assumed to be
accurate, SEGGER Microcontroller GmbH & Co. KG (the manufacturer) assumes no
responsibility for any errors or omissions. The manufacturer makes and you receive
no warranties or conditions, express, implied, statutory or in any communication with
you. The manufacturer specifically disclaims any implied warranty of merchantability
or fitness for a particular purpose.
Copyright notice
You may not extract portions of this manual or modify the PDF file in any way without
the prior written permission of the manufacturer. The software described in this doc-
ument is furnished under a license and may only be used or copied in accordance
with the terms of such a license.
Trademarks
Names mentioned in this manual may be trademarks of their respective companies.
Brand and product names are trademarks or registered trademarks of their respec-
tive holders.
Contact address
SEGGER Microcontroller GmbH & Co. KG
In den Weiden 11
D-40721 Hilden
Germany
Tel.+49 2103-2878-0
Fax.+49 2103-2878-28
Email: [email protected]
Internet: http://www.segger.com
Revisions
This manual describes the J-Link and J-Trace device.
For further information on topics or routines not yet specified, please contact us.
emFile
File system
emFile is an embedded file system with
FAT12, FAT16 and FAT32 support. Var-
ious Device drivers, e.g. for NAND and
NOR flashes, SD/MMC and Compact-
Flash cards, are available.
USB-Stack
USB device/host stack
A USB stack designed to work on any
embedded system with a USB control-
ler. Bulk communication and most stan-
dard device classes are supported.
Table of Contents
1 Introduction ....................................................................................................................23
1.1 Requirements.......................................................................................... 24
1.2 Supported OS ......................................................................................... 25
1.3 J-Link / J-Trace models ............................................................................ 26
1.3.1 Model comparison.................................................................................... 27
1.3.2 J-Link BASE ............................................................................................ 28
1.3.3 J-Link PLUS ............................................................................................ 34
1.3.4 J-Link ULTRA+ ........................................................................................ 39
1.3.5 J-Link PRO .............................................................................................. 44
1.3.6 J-Link Lite ARM ....................................................................................... 48
1.3.7 J-Link Lite CortexM .................................................................................. 49
1.3.8 J-Trace ARM ........................................................................................... 50
1.3.9 J-Trace for Cortex-M ................................................................................ 52
1.3.10 Flasher ARM............................................................................................ 55
1.4 Common features of the J-Link product family ............................................. 57
1.5 Supported CPU cores ............................................................................... 58
1.6 Built-in intelligence for supported CPU-cores ............................................... 59
1.6.1 Intelligence in the J-Link firmware ............................................................. 59
1.6.2 Intelligence on the PC-side (DLL) ............................................................... 59
1.6.3 Firmware intelligence per model ................................................................ 61
1.7 Supported IDEs ....................................................................................... 63
2 Licensing........................................................................................................................65
2.1 ................................................................. Components requiring a license66
2.2 License types .......................................................................................... 67
2.2.1 Built-in license ........................................................................................ 67
2.2.2 Key-based license.................................................................................... 67
2.3 Legal use of SEGGER J-Link software.......................................................... 68
2.3.1 Use of the software with 3rd party tools...................................................... 68
2.4 Original SEGGER products......................................................................... 69
2.4.1 J-Link BASE ............................................................................................ 69
2.4.2 J-Link PLUS ............................................................................................ 69
2.4.3 J-link ULTRA+ ......................................................................................... 70
2.4.4 J-Link PRO .............................................................................................. 70
2.4.5 J-Trace ARM ........................................................................................... 70
2.4.6 J-Trace for Cortex-M ................................................................................ 71
2.4.7 Flasher ARM............................................................................................ 72
2.4.8 Flasher RX .............................................................................................. 72
2.4.9 Flasher PPC ............................................................................................ 73
2.5 J-Link OEM versions ................................................................................. 74
2.5.1 Analog Devices: mIDASLink ...................................................................... 74
2.5.2 Atmel: SAM-ICE ...................................................................................... 74
2.5.3 Digi: JTAG Link........................................................................................ 75
2.5.4 IAR: J-Link / J-Link KS ............................................................................. 75
2.5.5 IAR: J-Link Lite ....................................................................................... 75
2.5.6 IAR: J-Trace ........................................................................................... 76
2.5.7 NXP: J-Link Lite LPC Edition ...................................................................... 76
2.5.8 SEGGER: J-Link Lite ARM.......................................................................... 76
2.6 J-Link OBs .............................................................................................. 77
2.7 Illegal Clones .......................................................................................... 78
4 Setup............................................................................................................................165
4.1 Installing the J-Link software and documentation pack ................................166
4.1.1 Setup procedure ....................................................................................166
4.2 Setting up the USB interface....................................................................169
4.2.1 Verifying correct driver installation ...........................................................169
4.2.2 Uninstalling the J-Link USB driver .............................................................170
4.3 Setting up the IP interface.......................................................................172
4.3.1 Configuring J-Link using J-Link Configurator...............................................172
4.3.2 Configuring J-Link using the webinterface ..................................................172
4.4 FAQs ....................................................................................................174
4.5 J-Link Configurator .................................................................................175
4.5.1 Configure J-Links using the J-Link Configurator ..........................................175
4.6 J-Link USB identification..........................................................................177
4.6.1 Connecting to different J-Links connected to the same host PC via USB .........177
4.7 Using the J-Link DLL ...............................................................................179
4.7.1 What is the JLink DLL? ............................................................................179
4.7.2 Updating the DLL in third-party programs..................................................179
6 Flash download............................................................................................................239
6.1 Introduction.......................................................................................... 240
6.2 Licensing...............................................................................................241
6.3 Supported devices..................................................................................242
6.4 Setup for various debuggers (internal flash) ..............................................243
6.4.1 IAR Embedded Workbench ......................................................................243
6.4.2 Keil MDK ...............................................................................................243
6.4.3 Mentor Sourcery CodeBench ....................................................................246
6.4.4 J-Link GDB Server ..................................................................................246
6.4.5 J-Link Commander .................................................................................247
6.4.6 J-Link RDI .............................................................................................248
6.5 Setup for various debuggers (CFI flash) ....................................................249
6.5.1 IAR Embedded Workbench / Keil MDK .......................................................249
6.5.2 J-Link GDB Server ..................................................................................250
6.5.3 J-Link commander..................................................................................250
6.6 Setup for various debuggers (SPIFI flash)..................................................251
6.7 QSPI flash support .................................................................................252
6.7.1 Setup the DLL for QSPI flash download .....................................................252
6.8 Using the DLL flash loaders in custom applications......................................253
7 Flash breakpoints.........................................................................................................255
7.1 Introduction ..........................................................................................256
7.2 Licensing...............................................................................................257
7.2.1 Free for evaluation and non-commercial use ..............................................257
7.3 Supported devices..................................................................................258
7.4 Setup & compatibility with various debuggers ............................................259
7.4.1 Setup ...................................................................................................259
7.4.2 Compatibility with various debuggers ........................................................259
7.5 Flash Breakpoints in QSPI flash ................................................................260
7.5.1 Setup ...................................................................................................260
7.6 FAQ......................................................................................................261
10 RDI.............................................................................................................................295
10.1 Introduction.......................................................................................... 296
10.1.1 Features............................................................................................... 296
10.2 Licensing .............................................................................................. 297
10.3 Setup for various debuggers ................................................................... 298
10.3.1 IAR Embedded Workbench IDE ................................................................ 298
10.3.2 ARM AXD (ARM Developer Suite, ADS) ..................................................... 301
10.3.3 ARM RVDS (RealView developer suite)...................................................... 303
10.3.4 GHS MULTI ........................................................................................... 308
10.3.5 KEIL MDK (µVision IDE).......................................................................... 311
10.4 Configuration ........................................................................................ 314
10.4.1 Configuration file JLinkRDI.ini.................................................................. 314
10.4.2 Using different configurations .................................................................. 314
10.4.3 Using mutliple J-Links simulatenously....................................................... 314
10.4.4 Configuration dialog ............................................................................... 314
10.5 Semihosting.......................................................................................... 323
10.5.1 Overview .............................................................................................. 323
10.5.2 The SWI interface .................................................................................. 323
10.5.3 Implementation of semihosting in J-Link RDI ............................................. 324
10.5.4 Semihosting with AXD ............................................................................ 324
10.5.5 Unexpected / unhandled SWIs................................................................. 325
11 RTT ............................................................................................................................327
11.1 Introduction.......................................................................................... 328
11.2 How RTT works ..................................................................................... 329
11.2.1 Target implementation ........................................................................... 329
11.2.2 Locating the Control Block ...................................................................... 329
11.2.3 Internal structures ................................................................................. 329
11.2.4 Requirements........................................................................................ 330
11.2.5 Performance ......................................................................................... 331
11.2.6 Memory footprint................................................................................... 331
11.3 RTT Communication ............................................................................... 332
11.3.1 J-Link RTT Viewer .................................................................................. 332
11.3.2 RTT Client............................................................................................. 337
11.3.3 RTT Logger ........................................................................................... 337
11.3.4 RTT in other host applications ................................................................. 337
11.4 Implementation..................................................................................... 338
11.4.1 API functions ........................................................................................ 338
11.4.2 Configuration defines ............................................................................. 344
11.5 Example code ....................................................................................... 346
11.6 FAQ ..................................................................................................... 347
17 Glossary.....................................................................................................................425
Chapter 1
Introduction
1.1 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 25.
Target System
A target system with a supported CPU is required.
You should make sure that the emulator you are looking at supports your target CPU.
For more information about which J-Link features are supported by each emulator,
please refer to Model comparison on page 27.
1.2 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 Vista
• Microsoft Windows Vista x64
• Windows 7
• Windows 7 x64
• Windows 8
• Windows 8 x64
• Windows 10
• Linux
• Mac OSX 10.5 and higher
Software features
Software features are features implemented in the software running on the host.
Software features can either come with the J-Link or be added later using a license
string from Segger.
J-Trace
J-Link J-Link J-Link J-Link J-Trace
for
BASE PLUS ULTRA+ PRO ARM
Cortex-M
J-Flash yes(opt) yes yes yes yes yes
1 yes(opt) yes yes yes yes yes
Flash breakpoints
Flash download 2 yes yes yes yes yes yes
GDB Server yes yes yes yes yes yes
RDI yes(opt) yes yes yes yes yes
1 In order to use the flash breakpoints with J-Link no additional license for flash
download is required. The flash breakpoint feature allows setting an unlimited num-
ber of breakpoints even if the application program is not located in RAM, but in flash
memory. Without this feature, the number of breakpoints which can be set in flash is
limited to the number of hardware breakpoints (typically two for ARM 7/9, up to six
for Cortex-M) For more information about flash breakpoints, please refer to Flash
breakpoints on page 255.
2
Most IDEs come with its own flashloaders, so in most cases this feature is not
essential for debugging applications in flash. The J-Link flash download feature is
mainly used in debug environments where the debugger does not come with an own
flashloader (for example, the GNU Debugger). For more information about how flash
download via FlashDL works, please refer to Flash download on page 239.
1.3.2.2 Specifications
The following table gives an overview about the specifications (general, mechanical,
electrical) for J-Link BASE.
General
For a complete list of all operating sys-
Supported OS tems which are supported, please refer
to Supported OS on page 25.
Electromagnetic compatibility (EMC) EN 55022, EN 55024
Operating temperature +5°C ... +60°C
Storage temperature -20°C ... +65 °C
Relative humidity (non-condensing) Max. 90% rH
Mechanical
Size (without cables) 100mm x 53mm x 27mm
Weight (without cables) 70g
Available interfaces
USB interface USB 2.0, full speed
JTAG 20-pin
Target interface
(14-pin adapter available)
JTAG/SWD Interface, Electrical
USB powered
Power supply
Max. 50mA + Target Supply current.
Target interface voltage (VIF) 1.2V ... 5V
Target supply voltage 4.5V ... 5V (if powered with 5V on USB)
Target supply current Max. 300mA
Open drain. Can be pulled low or
Reset Type
tristated.
Reset low level output voltage (VOL) V OL <= 10% of VIF
For the whole target voltage range (1.2V <= V IF <= 5V)
LOW level input voltage (VIL) V IL <= 40% of V IF
Table 1.1: J-Link specifications
Hardware version 3.0 4.0 5.0 5.2 5.3 5.4 6.0 7.0 8.0 9.1 9.2
Hardware features
USB !!!!!!!!!!!
JTAG interface !!!!!!!!!!!
SWD interface " " " " " " !!!!!
SWO interface " " " " " " !!!!!
Microchip ICSP
interface
" " " " " " " " " !!
Renesas FINE inter-
face
" " " " " " " " " !!
Table 1.2: J-Link BASE hardware versions
Hardware version 3.0 4.0 5.0 5.2 5.3 5.4 6.0 7.0 8.0 9.1 9.2
ARM7 !!!!!!!!!!!
ARM9 !!!!!!!!!!!
ARM11 " " " " " " !!!!!
ARM Cortex cores
Cortex-A5 " " " " " " " " " !!
Cortex-A7 " " " " " " " " " !!
Cortex-A8 " " " " " " " " !!!
Cortex-A9 " " " " " " " " " !!
Cortex-A12 " " " " " " " " " !!
Cortex-A15 " " " " " " " " " !!
Cortex-A17 " " " " " " " " " !!
Cortex-M0 " " " " " " " " !!!
Cortex-M0+ " " " " " " " " !!!
Cortex-M1 " " " " " " " " !!!
Table 1.2: J-Link BASE hardware versions
Hardware version 3.0 4.0 5.0 5.2 5.3 5.4 6.0 7.0 8.0 9.1 9.2
Cortex-M3 " " " " " " " " !!!
Cortex-M4 " " " " " " " " " !!
Cortex-M7 " " " " " " " " " !!
Cortex-R4 " " " " " " " " !!!
Cortex-R5 " " " " " " " " !!!
SC000 (M0 secure) " " " " " " " " !!!
SC300 (M3 secure) " " " " " " " " !!!
Microchip PIC32
Microchip PIC32MX " " " " " " " " " !!
Microchip PIC32MZ " " " " " " " " " !!
Renesas RX
Renesas RX110 " " " " " " " " " !!
Renesas RX111 " " " " " " " " " !!
Renesas RX210 " " " " " " " " " !!
Renesas RX21A " " " " " " " " " !!
Renesas RX220 " " " " " " " " " !!
Table 1.2: J-Link BASE hardware versions
Hardware version 3.0 4.0 5.0 5.2 5.3 5.4 6.0 7.0 8.0 9.1 9.2
Renesas RX610 " " " " " " " " !!!
Renesas RX621 " " " " " " " " !!!
Renesas RX62G " " " " " " " " !!!
Renesas RX62N " " " " " " " " !!!
Renesas RX62T " " " " " " " " !!!
Renesas RX630 " " " " " " " " !!!
Renesas RX631 " " " " " " " " !!!
Renesas RX63N " " " " " " " " !!!
Renesas RX63T " " " " " " " " !!!
Table 1.2: J-Link BASE hardware versions
1.3.3.2 Specifications
The following table gives an overview about the specifications (general, mechanical,
electrical) for J-Link PLUS.
General
For a complete list of all operating sys-
Supported OS tems which are supported, please refer
to Supported OS on page 25.
Electromagnetic compatibility (EMC) EN 55022, EN 55024
Operating temperature +5°C ... +60°C
Storage temperature -20°C ... +65 °C
Relative humidity (non-condensing) Max. 90% rH
Mechanical
Size (without cables) 100mm x 53mm x 27mm
Weight (without cables) 70g
Available interfaces
USB interface USB 2.0, full speed
JTAG 20-pin
Target interface
(14-pin adapter available)
JTAG/SWD Interface, Electrical
USB powered
Power supply
Max. 50mA + Target Supply current.
Target interface voltage (VIF) 1.2V ... 5V
Target supply voltage 4.5V ... 5V (if powered with 5V on USB)
Target supply current Max. 300mA
Open drain. Can be pulled low or
Reset Type
tristated.
Table 1.3: J-Link specifications
USB ! !
JTAG interface ! !
SWD interface ! !
Table 1.4: J-Link PLUS hardware versions
SWO interface ! !
Microchip ICSP
interface ! !
Renesas FINE inter-
face ! !
ETB Trace ! !
Supported cores
ARM legacy cores
ARM7 ! !
ARM9 ! !
ARM11 ! !
ARM Cortex cores
Cortex-A5 ! !
Cortex-A7 ! !
Cortex-A8 ! !
Cortex-A9 ! !
Cortex-A12 ! !
Cortex-A15 ! !
Cortex-A17 ! !
Table 1.4: J-Link PLUS hardware versions
Cortex-M0 ! !
Cortex-M0+ ! !
Cortex-M1 ! !
Cortex-M3 ! !
Cortex-M4 ! !
Cortex-M7 ! !
Cortex-R4 ! !
Cortex-R5 ! !
SC000 (M0 secure) ! !
SC300 (M3 secure) ! !
Microchip PIC32
Microchip PIC32MX ! !
Microchip PIC32MZ ! !
Renesas RX
Renesas RX110 ! !
Renesas RX111 ! !
Table 1.4: J-Link PLUS hardware versions
Renesas RX210 ! !
Renesas RX21A ! !
Renesas RX220 ! !
Renesas RX610 ! !
Renesas RX621 ! !
Renesas RX62G ! !
Renesas RX62N ! !
Renesas RX62T ! !
Renesas RX630 ! !
Renesas RX631 ! !
Renesas RX63N ! !
Renesas RX63T ! !
Table 1.4: J-Link PLUS hardware versions
1.3.4.2 Specifications
The following table gives an overview about the specifications (general, mechanical,
electrical) for J-link ULTRA+. All values are valid for J-link ULTRA hardware version 1.
Note: Some specifications, especially speed, are likely to be improved in the
future with newer versions of the J-Link software (freely available).
General
For a complete list of all operating sys-
Supported OS tems which are supported, please refer
to Supported OS on page 25.
Electromagnetic compatibility (EMC) EN 55022, EN 55024
Operating temperature +5°C ... +60°C
Storage temperature -20°C ... +65 °C
Relative humidity (non-condensing) Max. 90% rH
Mechanical
Size (without cables) 100mm x 53mm x 27mm
Weight (without cables) 73g
Available interfaces
USB interface USB 2.0, Hi-Speed
Target interface 20-pin J-Link debug interface connector
JTAG/SWD Interface, Electrical
Target interface voltage (VIF) 1.8V ... 5V
Target supply voltage 4.5V ... 5V
Table 1.5: J-link ULTRA specifications
USB ! !
JTAG interface ! !
SWD interface ! !
SWO interface ! !
Microchip ICSP
interface
" !
Renesas FINE inter-
face
" !
ETB Trace ! !
Supported cores
ARM legacy cores
ARM7 ! !
ARM9 ! !
ARM11 ! !
ARM Cortex cores
Cortex-A5 ! !
Cortex-A7 ! !
Cortex-A8 ! !
Table 1.6: J-Link ULTRA+ hardware versions
Cortex-A9 ! !
Cortex-A12 ! !
Cortex-A15 ! !
Cortex-A17 ! !
Cortex-M0 ! !
Cortex-M0+ ! !
Cortex-M1 ! !
Cortex-M3 ! !
Cortex-M4 ! !
Cortex-M7 " !
Cortex-R4 ! !
Cortex-R5 ! !
SC000 (M0 secure) ! !
SC300 (M3 secure) ! !
Microchip PIC32
USB ! ! !
Ethernet ! ! !
JTAG interface ! ! !
Table 1.7: J-Link PRO hardware versions
SWD interface ! ! !
SWO interface ! ! !
Microchip ICSP
interface
" " !
Renesas FINE inter-
face
" " !
ETB Trace ! ! !
Supported cores
ARM legacy cores
ARM7 ! ! !
ARM9 ! ! !
ARM11 ! ! !
ARM Cortex cores
Cortex-A5 " ! !
Cortex-A7 " ! !
Cortex-A8 " ! !
Cortex-A9 " ! !
Cortex-A12 " ! !
Cortex-A15 " ! !
Table 1.7: J-Link PRO hardware versions
Cortex-A17 " ! !
Cortex-M0 ! ! !
Cortex-M0+ ! ! !
Cortex-M1 ! ! !
Cortex-M3 ! ! !
Cortex-M4 " ! !
Cortex-M7 " " !
Cortex-R4 " ! !
Cortex-R5 " ! !
SC000 (M0 secure) ! ! !
SC300 (M3 secure) ! ! !
Microchip PIC32
1.3.6.2 Specifications
The following table gives an overview about the specifications (general, mechanical,
electrical) for J-Link Lite ARM. All values are valid for J-Link hardware version 8.
General
For a complete list of all operating sys-
Supported OS tems which are supported, please refer
to Supported OS on page 25.
Electromagnetic compatibility (EMC) EN 55022, EN 55024
Operating temperature +5°C ... +60°C
Storage temperature -20°C ... +65 °C
Relative humidity (non-condensing) Max. 90% rH
Size (without cables) 28mm x 26mm x 7mm
Weight (without cables) 6g
Mechanical
USB interface USB 2.0, full speed
JTAG 20-pin
Target interface
(14-pin adapter available)
JTAG/SWD Interface, Electrical
USB powered
Power supply
Max. 50mA + Target Supply current.
Target interface voltage (VIF) 3.3V
Target supply voltage 4.5V ... 5V (if powered with 5V on USB)
Target supply current Max. 300mA
LOW level input voltage (VIL) Max. 40% of V IF
HIGH level input voltage (VIH) Min. 60% of VIF
JTAG/SWD Interface, Timing
Data input rise time (Trdi) Max. 20ns
Data input fall time (Tfdi) Max. 20ns
Data output rise time (Trdo) Max. 10ns
Data output fall time (Tfdo) Max. 10ns
Clock rise time (Trc) Max. 10ns
Clock fall time (Tfc) Max. 10ns
Table 1.8: J-Link Lite specifications
1.3.7.1 Specifications
The following table gives an overview about the specifications (general, mechanical,
electrical) for J-Link Lite Cortex-M.
General
For a complete list of all operating sys-
Supported OS tems which are supported, please refer
to Supported OS on page 25.
Electromagnetic compatibility (EMC) EN 55022, EN 55024
Operating temperature +5°C ... +60°C
Storage temperature -20°C ... +65 °C
Relative humidity (non-condensing) Max. 90% rH
Size (without cables) 41mm x 34mm x 8mm
Weight (without cables) 6g
Mechanical
USB interface USB 2.0, full speed
19-pin 0.05'' Samtec FTSH connector
Target interface
9-pin 0.05'' Samtec FTSH connector
JTAG/SWD Interface, Electrical
USB powered
Power supply
Max. 50mA + Target Supply current.
Target interface voltage (VIF) 3.3V
Target supply voltage 4.5V ... 5V
Target supply current Max. 300mA
LOW level input voltage (VIL) Max. 40% of VIF
HIGH level input voltage (V IH) Min. 60% of V IF
JTAG/SWD Interface, Timing
Data input rise time (Trdi) Max. 20ns
Data input fall time (Tfdi) Max. 20ns
Data output rise time (Trdo) Max. 10ns
Data output fall time (T fdo) Max. 10ns
Clock rise time (Trc) Max. 10ns
Clock fall time (Tfc) Max. 10ns
Table 1.9: J-Link Lite Cortex-M specifications
1.3.8.2 Specifications
General
For a complete list of all operating sys-
Supported OS tems which are supported, please refer
to Supported OS on page 25.
Electromagnetic Compatibility (EMC) EN 55022, EN 55024
Operating Temperature +5°C ... +40°C
Storage Temperature -20°C ... +65 °C
Relative Humidity (non-condensing) <90% rH
Size (without cables) 123mm x 68mm x 30mm
Weight (without cables) 120g
Mechanical
USB Interface USB 2.0, full speed
JTAG 20-pin (14-pin adapter available)
Target Interface
JTAG+Trace: Mictor, 38-pin
JTAG/SWD Interface, Electrical
Power Supply USB powered < 300mA
Supported Target interface voltage 3.0 - 3.6 V (5V adapter available)
Table 1.10: J-Trace specifications
All tests have been performed in the testing environment which is described on Mea-
suring download speed on page 420.
The actual speed depends on various factors, such as JTAG, clock speed, host CPU
core etc.
1.3.9.2 Specifications
The following table gives an overview about the specifications (general, mechanical,
electrical) for J-Trace for Cortex-M. All values are valid for the latest hardware ver-
sion of J-Trace for Cortex-M.
General
For a complete list of all operating sys-
Supported OS tems which are supported, please refer
to Supported OS on page 19.
Electromagnetic compatibility (EMC) EN 55022, EN 55024
Operating temperature +5°C ... +60°C
Storage temperature -20°C ... +65 °C
Relative humidity (non-condensing) Max. 90% rH
Size (without cables) 123mm x 68mm x 30mm
Weight (without cables) 120g
Mechanical
USB interface USB 2.0, Hi-Speed
JTAG/SWD 20-pin
Target interface (14-pin adapter available)
JTAG/SWD + Trace 19-pin
JTAG/SWD Interface, Electrical
USB powered
Power supply
Max. 50mA + Target Supply current.
Target interface voltage (VIF) 1.2V ... 5V
Target supply voltage 4.5V ... 5V (if powered with 5V on USB)
Target supply current Max. 300mA
LOW level input voltage (VIL) Max. 40% of V IF
HIGH level input voltage (VIH) Min. 60% of VIF
JTAG/SWD Interface, Timing
Data input rise time (Trdi) Max. 20ns
Data input fall time (Tfdi) Max. 20ns
Data output rise time (Trdo) Max. 10ns
Data output fall time (Tfdo) Max. 10ns
Table 1.12: J-Trace for Cortex-M3 specifications
Hardware Cortex-M3
190 Kbytes/s (12MHz SWD)
J-Trace for Cortex-M3 V2
760 KB/s (12 MHz JTAG)
190 Kbytes/s (12MHz SWD)
J-Trace for Cortex-M V3.1
1440 KB/s (25 MHz JTAG)
Table 1.13: Download speed differences between hardware revisions
The actual speed depends on various factors, such as JTAG, clock speed, host CPU
core etc.
USB ! !
JTAG interface ! !
SWD interface ! !
SWO interface ! !
ETM Trace ! !
Supported cores
ARM Cortex cores
Cortex-M0 ! !
Cortex-M0+ ! !
Cortex-M1 ! !
Cortex-M3 ! !
Cortex-M4 " !
Cortex-M7 " !
SC000 (M0 secure) ! !
SC300 (M3 secure) ! !
Table 1.14: J-Trace for Cortex-M hardware versions
1.3.10.1 Specifications
The following table gives an overview about the specifications
(general, mechanical, electrical) for Flasher ARM.
General
For a complete list of all operating sys-
Supported OS tems which are supported, please refer
to Supported OS on page 19.
Mechanical
USB interface USB 2.0, full speed
Target interface JTAG/SWD 20-pin
JTAG Interface, Electrical
USB powered
Power supply
Max. 50mA + Target Supply current.
Target interface voltage (VIF) 1.2V ... 5V
Target supply voltage 4.5V ... 5V (if powered with 5V on USB)
Target supply current Max. 300mA
For the whole target voltage range (1.8V <= V IF <= 5V)
LOW level input voltage (VIL) Max. 40% of VIF
HIGH level input voltage (V IH) Min. 60% of V IF
For 1.8V <= V IF <= 3.6V
LOW level output voltage (VOL) with a
Max. 10% of V IF
load of 10 kOhm
HIGH level output voltage (VOH ) with a
Min. 90% of V IF
load of 10 kOhm
For 3.6 <= V IF <= 5V
LOW level output voltage (VOL) with a
Max. 20% of V IF
load of 10 kOhm
HIGH level output voltage (VOH ) with a
Min. 80% of V IF
load of 10 kOhm
SWD Interface, Electrical
USB powered
Power supply
Max. 50mA + Target Supply current.
1.2V ... 5V (SWD interface is 5V tolerant
Target interface voltage (VIF) but can output a maximum of 3.3V SWD
signals)
Target supply voltage 4.5V ... 5V (if powered with 5V on USB)
Table 1.15: Flasher ARM specifications
Version
ARM ARM Cortex- Renesas
J-Link / J-Trace Cortex-M
7/9 11 A/R RX600
model
JTAG JTAG JTAG JTAG SWD JTAG
J-Link BASE 8 ! ! ! ! ! !
J-Link PRO 3 ! ! ! ! ! !
J-link ULTRA 1 ! ! ! ! ! !
J-Link Lite ARM 8 ! ! ! ! ! !
"
Version
ARM ARM Cortex- Renesas
J-Link / J-Trace Cortex-M
7/9 11 A/R RX600
model
JTAG JTAG JTAG JTAG SWD JTAG
not sup-
J-Link 3 " " " " "
ported
not sup-
J-Link 4 " " " " "
ported
not sup-
J-Link 5 ! " " "
ported
"
J-Link Pro 1 ! ! ! ! ! !
J-Trace for Cortex-M 1 " " ! ! ! "
ARM Cortex-M3
ARM11
ARM11 has currently been tested with IAR EWARM only.
1
Requires J-Link RDI license for download of more than 32KBytes
2
Coming soon
3
Requires emulator with trace support
4 Debug support includes the following: Download to RAM, memory read/write, CPU
register read/write, Run control (go, step, halt), software breakpoints in RAM and
hardware breakpoints in flash memory.
Chapter 2
Licensing
This chapter describes the different license types of J-Link related software and the
legal use of the J-Link software with original SEGGER and OEM products.
The J-Link PLUS in the example above contains licenses for all features. Note that
GDB and FlashDL feature are no longer required.
2.4.5J-Trace ARM
J-Trace ARM is a JTAG emulator designed for ARM cores which
includes trace (ETM) support. It connects via USB to a PC run-
ning Microsoft Windows, Apple OSX or Linux. J-Trace has a
built-in 20-pin JTAG connector and a built in 38-pin JTAG+Trace
connector, which is compatible with the standard 20-pin con-
nector and 38-pin connector defined by ARM.
Included Licenses
J-Link Flashloaders
J-Link GDB Server
J-Link Debugger
J-Flash
Unlimited Flash Breakpoints
RDI / RDDI
Licenses
Comes with built-in licenses for flash download and J-Flash.
2.4.8 Flasher RX
Flasher RX is a programming tool for Renesas RX600 series
microcontrollers with on-chip or external flash memory and
Renesas RX core. Flasher RX is designed for programming flash
targets with the J-Flash software or stand-alone. In addition to
that Flasher RX has all of the J-Link RX functionality. Flasher RX
connects via Ethernet, USB or via RS232 interface to a PC run-
ning Microsoft Windows 2000 or later.
Flasher RX itself has a built-in 20-pin JTAG connector but is
shipped with an 14-pin adapter for Renesas RX devices.
Licenses
Comes with built-in licenses for flash download and J-Flash.
Chapter 3
This chapter describes the contents of the J-Link software and documentation pack-
age which can be downloaded from www.segger.com.
Software Description
JLink Commander Command-line tool with basic functionality for target analysis.
J-Link Remote Utility which provides the possibility to use J-Link / J-Trace
Server remotely via TCP/IP.
J-Mem Memory Target memory viewer. Shows the memory content of a run-
Viewer ning target and allows editing as well.
J-Link SWO Ana- Command line tool that analyzes SWO RAW output and stores
lyzer it into a file.
Command line tool that opens an svf file and sends the data in
JTAGLoad
it via J-Link / J-Trace to the target.
3.2.1 Commands
The table below lists the available commands of J-Link Commander. All commands
are listed in alphabetical order within their respective categories. Detailed descrip-
tions of the commands can be found in the sections that follow.
3.2.1.1 clrBP
This command removes a breakpoint set by J-Link.
Syntax
clrBP <BP_Handle>
Parameter Meaning
BP_Handle Handle of breakpoint to be removed.
Example
clrBP 1
3.2.1.2 clrWP
This command removes a watchpoint set by J-Link.
Syntax
clrWP <WP_Handle>
Parameter Meaning
WP_Handle Handle of watchpoint to be removed.
Example
clrWP 0x2
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.
For some devices explicit device selection is mandatory in order to allow the DLL to
perform special handling needed by the device.
Some commands require that a device is set prior to use them.
Syntax
device <DeviceName>
Parameter Meaning
Valid device name: Device is selected.
DeviceName
?: Shows a device selection dialog.
Example
device stm32f407ig
3.2.1.4 erase
Erases all flash sectors of the current device. A device has to be specified previously.
Syntax
erase
Syntax
q
Parameter Meaning
1: J-Link Commander will now exit on Error.
<1|0>
0: J-Link Commander will no longer exit on Error.
Example
eoe 1
3.2.1.7 f
Prints firmware and hardware version info. Please notice that minor hardware revi-
sions may not be displayed, as they do not have any effect on the feature set.
Syntax
f
Parameter Meaning
FileName File to delete from the Flasher.
Example
fdelete Flasher.dat
3.2.1.9 flist
On emulators which support file I/O this command shows the directory tree of the
Flasher.
Syntax
flist
Syntax
fread <EmuFile> <HostFile> [<Offset> [<NumBytes>]]
Parameter Meaning
EmuFile File name to read from.
HostFile Destination file on the host.
Offset Specifies the offset in the file, at which data reading is started.
NumBytes Maximum number of bytes to read.
Example
fread Flasher.dat C:\Project\Flasher.dat
3.2.1.11 fshow
On emulators which support file I/O this command reads and prints a specific file.
Currently, only Flasher models support file I/O.
Syntax
fshow <FileName> [-a] [<Offset> [<NumBytes>]]
Parameter Meaning
FileName Source file name to read from the Flasher.
a If set, Input will be parsed as text instead of being shown as hex.
Offset Specifies the offset in the file, at which data reading is started.
NumBytes Maximum number of bytes to read.
Example
fshow Flasher.dat
Parameter Meaning
FileName Source file name to read from the Flasher.
Example
fsize Flasher.dat
Syntax
fwrite <EmuFile> <HostFile> [<Offset> [<NumBytes>]]
Parameter Meaning
EmuFile File name to write to.
HostFile Source file on the host
Offset Specifies the offset in the file, at which data writing is started.
NumBytes Maximum number of bytes to write.
Example
fwrite Flasher.dat C:\Project\Flasher.dat
3.2.1.14 go (g)
Starts the CPU. In order to avoid setting breakpoints it allows to define a maximum
number of instructions which can be simulated/emulated. This is particulary useful
when the program is located in flash and flash breakpoints are used. Simulating
instructions avoids to reprogram the flash and speeds up (single) stepping.
Syntax
go [<NumSteps> [<Flags>]]
Parameter Meaning
Maximum number of instructions allowed to be simulated. Instruc-
tion simulation stops whenever a breakpointed instruction is hit, an
NumSteps
instruction which cannot be simulated/emulated is hit or when Num-
Steps is reached.
0: Do not start the CPU if a BP is in range of NumSteps
Flags
1: Overstep BPs
Example
go //Simply starts the CPU
go 20, 1
3.2.1.16 hwinfo
This command can be used to get information about the power consumption of the
target (if the target is powered via J-Link). It also gives the information if an over-
current happened.
Syntax
hwinfo
3.2.1.17 ip
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
Valid values:
IP Address: Connects the J-Link with the specified IP-Address
Addr
Host Name: Resolves the host name and connects to it.
*: Invokes the Emulator selection dialog.
Example
ip 192.168.6.3
3.2.1.18 is
This command returns information about the length of the scan chain select register.
Syntax
is
3.2.1.19 loadfile
This command programs a given data file to a specified destination address.
Currently supported data files are:
• *.mot
• *.srec
• *.s19
• *.s
• *.hex
• *.bin
Syntax
loadfile <Filename> [<Addr>]
Parameter Meaning
Filename Source filename
Addr Destination address (Required for *.bin files)
Example
loadfile C:\Work\test.bin 0x20000000
3.2.1.20 log
Set path to logfile allowing the DLL to output logging information.
If the logfile already exist, the contents of the current logfile will be overwritten.
Syntax
log <Filename>
Parameter Meaning
Filename Log filename
Example
log C:\Work\log.txt
3.2.1.21 mem
The command reads memory from the target system. If necessary, the target CPU is
halted in order to read memory.
Syntax
mem [<Zone>:]<Addr>, <NumBytes> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
Numbytes Number of bytes to read. Maximum is 0x100000.
Example
mem 0, 100
3.2.1.22 mem8
The command reads memory from the target system in units of bytes. If necessary,
the target CPU is halted in order to read memory.
Syntax
mem8 [<Zone>:]<Addr>, <NumBytes> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
NumBytes Number of bytes to read. Maximum is 0x10000.
Example
mem8 0, 100
3.2.1.23 mem16
The command reads memory from the target system in units of 16-bits. If necessary,
the target CPU is halted in order to read memory.
Syntax
mem16 [<Zone>:]<Addr>, <NumBytes> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
NumBytes Number of bytes to read. Maximum is 0x8000.
Example
mem16 0, 100
3.2.1.24 mem32
The command reads memory from the target system in units of 32-bits. If necessary,
the target CPU is halted in order to read memory.
Syntax
mem32 [<Zone>:]<Addr>, <NumBytes> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
NumBytes Number of bytes to read. Maximum is 0x4000.
Example
mem32 0, 100
3.2.1.25 mem64
The command reads memory from the target system in units of 64-bits. If necessary,
the target CPU is halted in order to read memory.
Syntax
mem64 [<Zone>:]<Addr>, <NumBytes> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
NumBytes Number of bytes to read. Maximum is 0x4000.
Example
mem64 0, 100
3.2.1.26 mr
Measure reaction time of RTCK pin.
Syntax
mr [<RepCount>]
Parameter Meaning
RepCount Number of times the test is repeated (Default: 1).
Example
mr 3
3.2.1.27 ms
Measures the number of bits in the specified scan chain.
Syntax
ms <ScanChain>
Parameter Meaning
ScanChain Scan chain to be measured.
Example
ms 1
3.2.1.28 power
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.
Syntax
power <State> [perm]
Parameter Meaning
State Valid values: On, Off
perm Sets the specified State value as default.
Example
f
3.2.1.29 r
Resets and halts the target.
Syntax
r
3.2.1.30 regs
Shows all current register values.
Syntax
regs
3.2.1.31 rnh
This command performs a reset but without halting the device.
Syntax
rnh
3.2.1.32 rreg
The function prints the value of the specified CPU register.
Syntax
rreg <RegIndex>
Parameter Meaning
RegIndex Register to read.
Example
rreg 15
3.2.1.33 rx
Resets and halts the target. It is possible to define a delay in milliseconds after reset.
This function is useful for some target devices which already contain an application or
a boot loader and therefore need some time before the core is stopped, for example
to initialize hardware, the memory management unit (MMU) or the external bus
interface.
Syntax
rx <DelayAfterReset>
Parameter Meaning
DelayAfter-
Delay in ms.
Reset
Example
rx 10
3.2.1.34 savebin
Saves target memory into binary file.
Syntax
savebin <Filename>, <Addr>, <NumBytes> (hex)
Parameter Meaning
Filename Destination file
Addr Source address.
NumBytes Number of bytes to read.
Example
savebin C:\Work\test.bin 0x0000000 0x100
3.2.1.35 setBP
This command sets a breakpoint of a specific type at a specified address. Which
breakpoint modes are available depends on the CPU that is used.
Syntax
setBP <Addr> [[A/T]/[W/H]] [S/H]
Parameter Meaning
Addr Address to be breakpointed.
Only for ARM7/9/11 and Cortex-R4 devices:
A/T A: ARM mode
T: THUMB mode
Only for MIPS devices:
W/H W: MIPS32 mode (Word)
H: MIPS16 mode (Half-word)
S: Force software BP
S/H
H: Force hardware BP
Example
setBP 0x8000036
3.2.1.36 setPC
Sets the PC to the specified value.
Syntax
setpc <Addr>
Parameter Meaning
Addr Address the PC should be set to.
Example
setpc 0x59C
3.2.1.37 setWP
This command inserts a new watchpoint that matches the specified parameters. The
enable bit for the watchpoint as well as the data access bit of the watchpoint unit are
set automatically by this command. Moreover the bits DBGEXT, CHAIN and the
RANGE bit (used to connect one watchpoint with the other one) are automatically
masked out. In order to use these bits you have to set the watchpoint by writing the
ICE registers directly.
Syntax
setWP <Addr> [<AccessType>] [<Size>] [<Data> [<DataMask> [<AddrMask>]]]
Parameter Meaning
Addr Address to be watchpointed.
Specifies the control data on which data event has been set:
Accesstype R: read access
W: write access
Valid values: S8 | S16 | S32
Size
Specifies to monitor an n-bit access width at the selected address.
Data Specifies the Data on which watchpoint has been set.
Specifies data mask used for comparison. Bits set to 1 are masked
out, so not taken into consideration during data comparison. Please
DataMask note that for certain cores not all Bit-Mask combinations are sup-
ported by the core-debug logic. On some cores only complete bytes
can be masked out (e.g. PIC32) or similar.
Specifies the address mask used for comparison. Bits set to 1 are
masked out, so not taken into consideration during address compar-
AddrMask ison. Please note that for certain cores not all Bit-Mask combina-
tions are supported by the core-debug logic. On some cores only
complete bytes can be masked out (e.g. PIC32) or similar.
Example
setWP 0x20000000 W S8 0xFF
3.2.1.38 sleep
Waits the given time (in milliseconds).
Syntax
sleep <Delay>
Parameter Meaning
Delay Amount of time to sleep in ms.
Example
sleep 200
3.2.1.39 speed
This command sets the speed for communication with the CPU core.
Syntax
speed <Freq>|auto|adaptive
Parameter Meaning
Freq Specifies the interface frequency in kHz.
auto Selects auto detection of JTAG speed.
adaptive Selects adaptive clocking as JTAG speed.
Example
speed 4000
speed auto
3.2.1.40 st
This command prints the current hardware status. Prints the current status of TCK,
TDI, TDO, TMS, TRES, TRST and the interface speeds supported by the target. Also
shows the Target Voltage.
Syntax
st
3.2.1.42 unlock
This command unlocks a device which has been accidentally locked by malfunction of
user software.
Syntax
unlock <DeviceName>
Parameter Meaning
Name of the device family to unlock. Supported Devices:
LM3Sxxx
DeviceName
Kinetis
EFM32Gxxx
Example
unlock Kinetis
3.2.1.43 usb
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
Port Valid values: 0..3
Example
usb
3.2.1.44 verifybin
Verifies if the specified binary is already in the target memory at the specified
address.
Syntax
verifybin <Filename>, <Addr>
Parameter Meaning
Filename Sample bin.
Addr Start address of memory to verify.
Example
verifybin C:\Work\test.bin 0x0000000
3.2.1.45 w1
The command writes one single byte to the target system.
Syntax
w1 [<Zone>:]<Addr>, <Data> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
Data 8-bits of data to write.
Example
w1 0x10, 0xFF
3.2.1.46 w2
The command writes a unit of 16-bits to the target system.
Syntax
w2 [<Zone>:]<Addr>, <Data> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
Data 16-bits of data to write.
Example
w2 0x0, 0xFFFF
3.2.1.47 w4
The command writes a unit of 32-bits to the target system.
Syntax
w4 [<Zone>:]<Addr>, <Data> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
Data 32-bits of data to write.
Example
w4 0x0, 0xAABBCCFF
3.2.1.48 wreg
Writes into a register. The value is written into the register on CPU start.
Syntax
wreg <RegName>, <Data>
Parameter Meaning
RegName Register to write to.
Data Data to write to the specified register.
Example
wreg R14, 0xFF
Command Explanation
-CommanderScript Passes a CommandFile to J-Link
-CommandFile Passes a CommandFile to J-Link
-Device Pre-selects the device J-Link Commander shall connect to
-ExitOnError Commander exits after error.
-If Pre-selects the target interface
-IP Selects IP as host interface
-JLinkScriptFile Passes a JLinkScriptFile to J-Link
-SelectEmuBySN Connects to a J-Link with a specific S/N over USB
-SettingsFile Passes a SettingsFile to J-Link
-Speed Starts J-Link Commander with a given initial speed
Table 3.2:
3.2.2.1 -CommanderScript
Similar to -CommandFile
3.2.2.2 -CommandFile
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.
Syntax
-CommandFile <CommandFilePath>
Example
See Using command files on page 98
3.2.2.3 -Device
Pre-selects the device J-Link Commander shall connect to. For some devices, J-Link
already needs to know the device at the time of connecting, since special handling is
required for some of them. For a list of all supported device names, please refer to
http://www.segger.com/jlink_supported_devices.html.
Syntax
-Device <DeviceName>
Example
JLink.exe -Device STM32F103ZE
3.2.2.4 -ExitOnError
Similar to the exitonerror (eoe) command.
3.2.2.5 -If
Selects the target interface J-Link shall use to connect to the target. By default, J-
Link Commander first tries to connect to the target using the target interface which is
currently selected in the J-Link firmware. If connecting fails, J-Link Commander goes
through all target interfaces supported by the connected J-Link and tries to connect
to the device.
Syntax
-If <TargetInterface>
Example
JLink.exe -If SWD
Additional information
Currently, the following target interfaces are supported:
• JTAG
• SWD
3.2.2.6 -IP
Selects IP as host interface to connect to J-Link. Default host interface is USB.
Syntax
-IP <IPAddr>
Example
JLink.exe -IP 192.168.1.17
Additional information
To select from a list of all available emulators on Ethernet, please use * as <IPAddr>.
3.2.2.7 -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 on page 213.
Syntax
JLink.exe -JLinkScriptFile <File>
Example
JLink.exe -JLinkScriptFile “C:\My Projects\Default.JLinkScript“
3.2.2.8 -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.
Syntax
-SelectEmuBySN <SerialNo>
Example
JLink.exe -SelectEmuBySN 580011111
3.2.2.9 -SettingsFile
DescriptionSelect a J-Link settings file to be used for the target device. The settings
fail 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.2.10 -Speed
Starts J-Link Commander with a given initial speed. Available parameters are "adap-
tive", "auto" or a freely selectable integer value in kHz. It is recommended to use
either a fixed speed or, if it is available on the target, adaptive speeds. Default inter-
face speed is 100kHz.
Syntax
-Speed <Speed_kHz>
Example
JLink.exe -Speed 4000
mander in batch mode, the path to a command file is passed to it. The syntax in the
command file is the same as when using regular commands in J-Link commander
(one line per command). SEGGER recommends to always pass the device name via
command line option due some devices need special handling on connect/reset in
order to guarantee proper function.
Example
JLink.exe -device STM32F103ZE -CommanderScript C:\CommandFile.jlink
Contents of CommandFile.jlink:
si 1
speed 4000
r
h
loadbin C:\firmware.bin,0x08000000
The GNU Project Debugger (GDB) is a freely available debugger, distributed under
the terms of the GPL. The latest Unix version of the GDB is freely available from the
GNU committee under: http://www.gnu.org/software/gdb/download/
GDB is included in many IDEs and most commonly used in connection with the GCC
compiler toolchain. This chapter shows how to configure some programs to use GDB
and connect to GDB Server. For more information about any program using GDB,
please refer to its user manual.
emIDE
emIDE is a full-featured, free and open source IDE for embedded development
including support for debugging with J-Link.
To connect to GDB Server with emIDE, the GDB Server configurations need to be set
in the project options at Project -> Properties... -> Debugger.
Select the target device you are using, the target connection, endianess and speed
and enter the additional GDB start commands.
The typically required GDB commands are:
Other commands to set up the target (e.g. Set PC to RAM, initialize external flashes)
can be entered here, too.
emIDE will automatically start GDB Server on start of the debug session. If it does
not, or an older version of GDB Server starts, in emIDE click on JLink -> Run the
JLink-plugin configuration.
The screenshot below shows a debug session in IDE. For download and more infor-
mation about emIDE, please refer to http://emide.org.
Console
GDB can be used stand-alone as a console application.
To connect GDB to GDB Server enter target remote localhost:2331 into the run-
ning GDB. Within GDB all GDB commands and the remote monitor commands are
available. For more information about debugging with GDB refer to its online manual
available at http://sourceware.org/gdb/current/onlinedocs/gdb/.
A typical startup of a debugging session can be like:
Eclipse (CDT)
Eclipse is an open source platform-independent software framework, which has typi-
cally been used to develop integrated development environment (IDE). Therefore
Eclipse can be used as C/C++ IDE, if you extend it with the CDT plug-in (http://
www.eclipse.org/cdt/).
CDT means "C/C++ Development Tooling" project and is designed to use the GDB as
default debugger and works without any problems with the GDB Server.
Refer to http://www.eclipse.org for detailed information about Eclipse.
Note: We only support problems directly related to the GDB Server. Problems
and questions related to your remaining toolchain have to be solved on your own.
Following remote commands are deprecated and only available for backward compa-
bility:
3.3.3.1 clrbp
Syntax
ClrBP [<BPHandle>]
or
ci [<BPHandle>]
Description
Removes an instruction breakpoint, where <BPHandle> is the handle of breakpoint to
be removed. If no handle is specified this command removes all pending breakpoints.
Example
> monitor clrbp 1
or
> monitor ci 1
3.3.3.2 cp15
Syntax
cp15 <CRn>, <CRm>, <op1>, <op2> [= <data>]
Description
Reads or writes from/to cp15 register. If <data> is specified, this command writes the
data to the cp15 register. Otherwise this command reads from the cp15 register. For
further information please refer to the ARM reference manual.
Example
#Read:
> monitor cp15 1, 2, 6, 7
< Reading CP15 register (1,2,6,7 = 0x0460B77D)
#Write:
> monitor cp15 1, 2, 6, 7 = 0xFFFFFFFF
3.3.3.3 device
Note: Deprecated. Use command line option -device instead.
Syntax
device <DeviceName>
Description
Selects the specified target device. This is necessary for the connection and some
special handling of the device.
Note: The device should be selected via commandline option -device when
starting GDB Server.
Example
> monitor device STM32F417IG
< Selecting device: STM32F417IG
3.3.3.4 DisableChecks
Syntax
DisableChecks
Description
Disables checking if a memory read caused an abort (ARM7/9 devices only). On some
CPUs during the init sequence for enabling access to the internal memory (for exam-
ple on the TMS470) some dummy reads of memory are required which will cause an
abort as long as the access-init is not completed.
3.3.3.5 EnableChecks
Syntax
EnableChecks
Description
Enables checking if a memory read caused an abort (ARM7/9 devices only). On some
CPUs during the init sequence for enabling access to the internal memory (for exam-
ple on the TMS470) some dummy reads of memory are required which will cause an
abort as long as the access-init is not completed. The default state is: Checks
enabled.
3.3.3.7 getargs
Syntax
getargs
Description
Get the currently set argument list which will be given to the application when calling
semihosting command SYS_GET_CMDLINE (0x15). The argument list is given as one
string.
Example
#No arguments set via setargs:
> monitor getargs
< No arguments.
#Arguments set via setargs:
> monitor getargs
< Arguments: test 0 1 2 arg0=4
3.3.3.8 go
Syntax
go
Description
Starts the target CPU.
Example
> monitor go
3.3.3.9 halt
Syntax
halt
Description
Halts the target CPU.
Example
> monitor halt
3.3.3.10 interface
Note: Deprecated. Use command line option -if instead.
Syntax
interface <InterfaceIdentifier>
Description
Selects the target interface used by J-Link / J-Trace.
3.3.3.11 jtagconf
Syntax
jtagconf <IRPre> <DRPre>
Description
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. <DRPre> is the number of devices closer to TDI.
For more detailed information of how to configure a scan chain with multiple devices
please refer to See “Determining values for scan chain configuration” on page 191..
Note: To make sure the connection to the device can be established correctly, it
is recommended to configure the JTAG scan chain via command line options at the
start of GDB Server.
Example
#Select the second device, where there is 1 device in front with IRLen 4
> monitor jtagconf 4 1
3.3.3.12 memU8
Syntax
MemU8 <address> [= <value>]
Description
Reads or writes a byte from/to a given address. If <value> is specified, this com-
mand writes the value to the given address. Otherwise this command reads from the
given address.
Example
#Read:
> monitor memU8 0x50000000
< Reading from address 0x50000000 (Data = 0x04)
#Write:
> monitor memU8 0x50000000 = 0xFF
< Writing 0xFF @ address 0x50000000
3.3.3.13 memU16
Syntax
memU16 <address> [= <value>]
Description
Reads or writes a halfword from/to a given address. If <value> is specified, this com-
mand writes the value to the given address. Otherwise this command reads from the
given address.
Example
#Read:
> monitor memU16 0x50000000
< Reading from address 0x50000000 (Data = 0x3004)
#Write:
> monitor memU16 0x50000000 = 0xFF00
< Writing 0xFF00 @ address 0x50000000
3.3.3.14 memU32
Syntax
MemU32 <address> [= <value>]
Description
Reads or writes a word from/to a given address. If <value> is specified, this com-
mand writes the value to the given address. Otherwise this command reads from the
given address. This command is similar to the long command.
Example
#Read:
> monitor memU32 0x50000000
< Reading from address 0x50000000 (Data = 0x10023004)
#Write:
> monitor memU32 0x50000000 = 0x10023004
< Writing 0x10023004 @ address 0x50000000
3.3.3.15 reg
Syntax
reg <RegName> [= <value>]
or
reg <RegName> [= (<address>)]
Description
Reads or writes from/to given register. If <value> is specified, this command writes
the value into the given register. If <address> is specified, this command writes the
memory content at address <address> to register <RegName>. Otherwise this com-
mand reads the given register.
Example
#Write value to register:
> monitor reg pc = 0x00100230
< Writing register (PC = 0x00100230)
3.3.3.16 regs
Syntax
regs
Description
Reads all CPU registers.
Example
> monitor regs
< PC = 00100230, CPSR = 20000013 (SVC mode, ARM)
R0 = 14813004, R1 = 00000001, R2 = 00000001, R3 = 000003B5
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
USR: R8 =00000000, R9 =00000000, R10=00000000, R11 =00000000, R12 =00000000
R13=00000000, R14=00000000
FIQ: R8 =00000000, R9 =00000000, R10=00000000, R11 =00000000, R12 =00000000
R13=00200000, R14=00000000, SPSR=00000010
SVC: R13=002004E8, R14=0010025C, SPSR=00000010
ABT: R13=00200100, R14=00000000, SPSR=00000010
IRQ: R13=00200100, R14=00000000, SPSR=00000010
UND: R13=00200100, R14=00000000, SPSR=00000010
3.3.3.17 reset
Syntax
reset
Description
Resets and halts the target CPU. Make sure the device is selected prior to using this
command to make use of the correct reset strategy.
Add. information
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.
Example
> monitor reset
< Resetting target
Description
Enables or disables halting the target at the semihosting breakpoint / in SVC handler
if an error occurred during a semihosting command, for example a bad file handle for
SYS_WRITE. The GDB Server log window always shows a warning in these cases.
breakOnError is disabled by default.
Example
#Enable breakOnError:
> monitor semihosting breakOnError 1
Description
Sets the SWI number used for semihosting in ARM mode. The default value for the
ARMSWI is 0x123456.
Example
> monitor semihosting ARMSWI 0x123456
< Semihosting ARM SWI number set to 0x123456
3.3.3.23 setargs
Syntax
setargs <ArgumentString>
Description
Set arguments for the application, where all arguments are in one <Argument-
String> separated by whitespaces.
The argument string can be gotten by the application via semihosting command
SYS_GET_CMDLINE (0x15).
Semihosting has to be enabled for getting the argumentstring (semihosting
enable). "monitor setargs" can be used before enabeling semihosting.
The maximum length for <ArgumentString> is 512 characters.
Example
> monitor setargs test 0 1 2 arg0=4
< Arguments: test 0 1 2 arg0=4
3.3.3.24 setbp
Syntax
setbp <Addr> [<Mask>]
Description
Sets an instruction breakpoint at the given address, where <Mask> can be 0x03 for
ARM instruction breakpoints (Instruction width 4 Byte, mask out lower 2 bits) or
0x01 for THUMB instruction breakpoints (Instruction width 2 Byte, mask out lower
bit). If no mask is given, an ARM instruction breakpoint will be set.
Example
#Set a breakpoint (implicit for ARM instructions)
> monitor setbp 0x00000000
3.3.3.25 sleep
Syntax
sleep <Delay>
Description
Sleeps for a given time, where <Delay> is the time period in milliseconds to delay.
While sleeping any communication is blocked until the command returns after the
given period.
Example
> monitor sleep 1000
< Sleep 1000ms
3.3.3.26 speed
Note: Deprecated. For setting the initial connection speed, use command line
option -speed instead.
Syntax
speed <kHz>|auto|adaptive
Description
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 on
page 192.
The speed has to be set after selecting the interface, to change it from its default
value.
Example
> monitor speed auto
< Select auto target interface speed (8000 kHz)
3.3.3.27 step
Syntax
step [<NumSteps>]
or
si [<NumSteps>]
Description
Performs one or more single instruction steps, where <NumSteps> is the number of
instruction steps to perform. If <NumSteps> is not specified only one instruction step
will be performed.
Example
> monitor step 3
#Configure SWO for stimulus ports 0-2, fixed SWO frequency and measure CPU frequency
> monitor SWO EnableTarget 0 1200000 5 0
< SWO enabled succesfully.
#Configure SWO for stimulus ports 0-255, fixed CPU and SWO frequency
> monitor SWO EnableTarget 72000000 6000000 0xFF 0
< SWO enabled succesfully.
3.3.3.32 waithalt
Syntax
waithalt <Timeout>
or
wh <Timeout>
Description
Waits for target to halt code execution, where <Timeout> is the maximum time
period in milliseconds to wait.
Example
#Wait for halt with a timeout of 2 seconds
> monitor waithalt 2000
3.3.3.33 wice
Syntax
wice <RegIndex> <value>
or
rmib <RegIndex> <value>
Description
Writes to given IceBreaker register, where <value> is the data to write.
Example
> monitor wice 0x0C 0x100
3.3.4.1 qSeggerSTRACE:config
Syntax
qSeggerSTRACE:config:<ConfigString>
Parameter
ConfigString: String containing the configuration data separating settings by ’;’.
Description
Configures STRACE for usage. Configuration for example includes specification of the
trace port width to be used for tracing (1-bit, 2-bit, 4-bit (default) Port-
Width=%Var%.
Note: For more information please refer to UM08002 (J-Link SDK user guide),
chapter STRACE.
Response
<ReturnValue>
>= 0 O.K.
< 0 Error.
3.3.4.2 qSeggerSTRACE:start
Syntax
qSeggerSTRACE:start
Description
Starts capturing of STRACE data.
Note: For more information please refer to UM08002 (J-Link SDK user guide),
chapter STRACE.
Response
<ReturnValue>
>= 0 O.K.
< 0 Error.
3.3.4.3 qSeggerSTRACE:stop
Syntax
qSeggerSTRACE:stop
Description
Stops capturing of STRACE data.
Note: For more information please refer to UM08002 (J-Link SDK user guide),
chapter STRACE.
Response
<ReturnValue>
>= 0 O.K.
< 0 Error.
3.3.4.4 qSeggerSTRACE:read
Syntax
qSeggerSTRACE:read:<NumItems>
Parameter
NumItems: Maximum number of trace data (addresses) to be read. Hexadecimal.
Description
Read 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.
Response
<ReturnValue>[<Item0><Item1>...]
Note: Using multiple instances of GDB Server, setting custom values for port,
SWOPort and TelnetPort is necessary.
The GDB Server GUI version uses persistent settings which are saved across different
instances and sessions of GDB Server. These settings can be toggled via the check-
boxes in the GUI.
Note: GDB Server CL always starts with the settings marked as default.
For GUI and CL, the settings can be changed with following command line options.
For all persistent settings there is a pair of options to enable or disable the feature.
Following additional command line options are available. These options are tempo-
rary for each start of GDB Server.
3.3.5.1 -cpu
Description
Pre-select the CPU core of the connected device, so the GDB Server already knows
the register set, even before having established a connection to the CPU.
Note: Deprecated, please use -device instead. Anyhow, it does not hurt if this
option is set, too.
Syntax
-CPU <CPUCore>
Example
jlinkgdbserver -CPU ARM7_9
Add. information
The following table lists all valid values for <CPUCore>:
3.3.5.2 -device
Description
Tells GDBServer to which device J-Link is connected before the connect sequence is
actually performed. It is recommended to use the command line option to select the
device instead of using the remote command since for some devices J-Link already
needs to know the device at the time of connecting to it since some devices need
special connect sequences (e.g. devices with TI ICEPick modules). In such cases, it is
not possible to select the device via remote commands since they are configured
after the GDB client already connected to GDBServer and requested the target regis-
ters which already requires a connection to the target.
Note: Using GDB Server CL this option is mandatory to correctly connect to the
target, and should be given before connection via GDB.
Syntax
-device <DeviceName>
Example
jlinkgdbserver -device AT91SAM7SE256
Add. information
For a list of all valid values for <DeviceName>, please refer to http://www.seg-
ger.com/jlink_supported_devices.html.
3.3.5.3 -endian
Description
Sets the endianess of the target where endianess can either be "little" or "big".
Note: Using GDB Server CL this option is mandatory to correctly connect to the
target, and should be given before connection via GDB.
Syntax
-endian <endianess>
Example
jlinkgdbserver -endian little
3.3.5.4 -if
Description
Selects the target interface which is used by J-Link to connect to the device. The
default value is JTAG.
Note: Using GDB Server CL this option is mandatory to correctly connect to the
target, and should be given before connection via GDB.
Syntax
-if <Interface>
Example
jlinkgdbserver -if SWD
Add. information
Currently, the following values are accepted for <Interface>:
• JTAG
• SWD
• FINE
• 2-wire-JTAG-PIC32
3.3.5.5 -ir
Description
Initializes the CPU register with default values on startup.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via -noir or the GUI.
Example
jlinkgdbserver -ir
3.3.5.6 -jtagconf
Syntax
-jtagconf <IRPre>,<DRPre>
Description
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. <DRPre> is the number of devices closer to TDI.
For more detailed information of how to configure a scan chain with multiple devices
please refer to See “Determining values for scan chain configuration” on page 191..
Example
#Select the second device, where there is 1 device in front with IRLen 4
jlinkgdbserver -jtagconf 4,1
3.3.5.7 -localhostonly
Description
Starts the GDB Server with the option to listen on localhost only (This means that
only TCP/IP connections from localhost are accepted) or on any IP address. To allow
remote debugging (connecting to GDBServer from another PC), deactivate this
option.
If no parameter is given, it will be set to 1 (active).
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via command line option or the GUI.
Syntax
-LocalhostOnly <State>
Example
jlinkgdbserver -LocalhostOnly 0 //Listen on any IP address (Linux/MAC default)
3.3.5.8 -log
Description
Starts the GDB Server with the option to write the output into a given log file.
The file will be created if it does not exist. If it exists the previous content will be
removed. Paths including spaces need to be set between quotes.
Syntax
-log <LogFilePath>
Example
jlinkgdbserver -log “C:\my path\to\file.log”
3.3.5.9 -logtofile
Description
Starts the GDB Server with the option to write the output into a log file.
If no file is given via -log, the log file will be created in the GDB Server application
directory.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via -nologtofile or the GUI.
Syntax
-logtofile
Example
jlinkgdbserver -logtofile
3.3.5.10 -halt
Description
Halts the target after connecting to it on start of GDB Server.
For most IDEs this option is mandatory since they rely on the target to be halted
after connecting to GDB Server.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via -nohalt or the GUI.
Syntax
-halt
Example
jlinkgdbserver -halt
3.3.5.11 -noir
Description
Do not initialize the CPU registers on startup.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via -ir or the GUI.
Syntax
-noir
3.3.5.12 -nolocalhostonly
Description
Starts GDB Server with the option to allow remote connections (from outside local-
host).
Same as -localhostonly 0
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via command line option or the GUI.
Syntax
-nolocalhostonly
3.3.5.13 -nologtofile
Description
Starts the GDB Server with the option to not write the output into a log file.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via -nologtofile or the GUI.
Note: When this option is used after -log, no log file will be generated, when -log
is used after this option, a log file will be generated and this setting will be overrid-
den.
Syntax
-nologtofile
Example
jlinkgdbserver -nologtofile // Will not generate a log file
3.3.5.14 -nohalt
Description
When connecting to the target after starting GDB Server, the target is not explicitly
halted and the CPU registers will not be inited.
After closing all GDB connections the target is started again and continues running.
Some IDEs rely on the target to be halted after connect. In this case do not use -
nohalt, but -halt.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via -halt or the GUI.
Syntax
-nohalt
Example
jlinkgdbserver -nohalt
3.3.5.15 -nosilent
Description
Starts the GDB Server in non-silent mode. All log window messages will be shown.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via command line option or the GUI.
Syntax
-nosilent
3.3.5.16 -nostayontop
Description
Starts the GDB Server in non-topmost mode. All windows can be placed above it.
Note: For the CL version this setting has no effect.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via command line option or the GUI.
Syntax
-nostayontop
3.3.5.17 -notimeout
Description
GDB Server automatically closes after a timout of 5 seconds when no target voltage
can be measured or connection to target fails.
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.18 -novd
Description
Do not explicitly verify downloaded data.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via command line option or the GUI.
Syntax
-vd
3.3.5.19 -port
Description
Starts GDB Server listening on a specified port. This option overrides the default lis-
tening port of the GDB Server. The default port is 2331.
Note: Using multiple instances of GDB Server, setting custom values for this
option is necessary.
Syntax
-port <Port>
Example
jlinkgdbserver -port 2345
3.3.5.20 -scriptfile
Description
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 tar-
get. J-Link scriptfiles are mainly used to connect to targets which need a special con-
nection sequence before communication with the core is possible. For more
information about J-Link script files, please refer to J-Link script files on page 213.
Syntax
-scriptfile <ScriptFilePath>
Example
-scriptfile “C:\My Projects\Default.JLinkScript“
3.3.5.21 -select
Description
Specifies the host interface to be used to connect to J-Link. Currently, USB and TCP/
IP are available.
Syntax
-select <Interface>=<SerialNo>/<IPAddr>
Example
jlinkgdbserver -select usb=580011111
jlinkgdbserver -select ip=192.168.1.10
Additional information
For backward compatibility, when USB is used as interface serial numbers from 0-3
are accepted as USB=0-3 to support the old method of connecting multiple J-Links to
a PC. This method is no longer recommended to be used. Please use the “connect via
emulator serial number“ method instead.
3.3.5.22 -settingsfile
Description
Select a J-Link settings file to be used for the target device. The settings fail can con-
tain all configurable options of the Settings tab in J-Link Control panel.
Syntax
-SettingsFile <PathToFile>
Example
jlinkgdbserver -SettingsFile "C:\Temp\GDB Server.jlink"
3.3.5.23 -silent
Description
Starts the GDB Server in silent mode. No log window messages will be shown.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via command line option or the GUI.
Syntax
-silent
3.3.5.24 -singlerun
Description
Starts GDB Server in single run mode. When active, GDB Server will close when all
client connections are closed.
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.
Syntax
-s
-singlerun
3.3.5.25 -speed
Description
Starts GDB Server with a given initial speed.
Available parameters are “adaptive”, “auto” or a freely selectable integer value in
kHz. It is recommended to use either a fixed speed or, if it is available on the target,
adaptive speeds.
Note: Using GDB Server CL this option is mandatory to correctly connect to the
target, and should be given before connection via GDB.
Syntax
-speed <Speed_kHz>
Example
jlinkgdbserver -speed 2000
3.3.5.26 -stayontop
Description
Starts the GDB Server in topmost mode. It will be placed above all non-topmost win-
dows and maintains it position even when it is deactivated.
Note: For the CL version this setting has no effect.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via command line option or the GUI.
Syntax
-stayontop
3.3.5.27 -timeout
Description
Set the timeout after which the target connection has to be established. If no con-
nection could be established GDB Server will close.
The default timeout is 5 seconds for the GUI version and 0 for the command line ver-
sion.
Note: The recommended order is to power the target, connect it to J-Link and
then start GDB Server.
Syntax
-timeout <Timeout[ms]>
Example
Allow target connection within 10 seconds.
3.3.5.28 -strict
Description
Starts GDB Server in sctrict mode. When strict mode is active GDB Server checks the
correctness of settings and exits in case of a failure.
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.
Syntax
- strict
Example
Following executions of GDB Server (CL) will cause exit of GDB Server.
jlinkgdbservercl -strict
Following execution of GDB Server will show the device selction dialog under Win-
dows or select "Unspecified" directly under Linux / OS X.
3.3.5.29 -swoport
Description
Set up port on which GDB Server should listen for an incoming connection that reads
the SWO data from GDB Server. Default port is 2332.
Note: Using multiple instances of GDB Server, setting custom values for this
option is necessary.
Syntax
-SWOPort <Port>
Example
jlinkgdbserver -SWOPort 2553
3.3.5.30 -telnetport
Description
Set up port on which GDB Server should listen for an incoming connection that gets
target’s printf data (Semihosting and anylized SWO data). Default port is 2333.
Note: Using multiple instances of GDB Server, setting custom values for this
option is necessary.
Syntax
-TelnetPort <Port>
Example
jlinkgdbserver -TelnetPort 2554
3.3.5.31 -vd
Description
Verifys the data after downloading it.
Note: For the GUI version, this setting is persistent for following uses of GDB
Server until changed via command line option or the GUI.
Syntax
-vd
3.3.5.32 -x
Description
Starts the GDB Server with a gdbinit (configuration) file. In contrast to the -xc com-
mand line option the GDB Server runs the commands in the gdbinit file once only
direct after the first connection of a client.
Syntax
-x <ConfigurationFilePath>
Example
jlinkgdbserver -x C:\MyProject\Sample.gdb
3.3.5.33 -xc
Description
Starts the GDB Server with a gdbinit (configuration) file. GDB Server executes the
commands specified in the gdbinit file with every connection of a client / start of a
debugging session.
Syntax
-xc <ConfigurationFilePath>
Example
jlinkgdbserver -xc C:\MyProject\Sample.gdb
The J-Link Remote Server also accepts commands which are passed to the J-Link
Remote Server via the command line.
Command Description
Selects the IP port on which the J-Link Remote Server is
port
listening.
SelectEmuBySN Selects the J-Link to connect to by its Serial Number.
Table 3.12: Available commands
3.4.1.1 port
Syntax
-port <Portno.>
Example
To start the J-Link Remote Server listening on port 19021 the command should look
as follows:
-port 19021
3.4.1.2 SelectEmuBySN
Syntax
-SelectEmuBySN <S/N>
Example
To select the emulator with Serial Number 268000000 the command should look as
follows:
-SelectEmuBySN 268000000
Target Debugger
LAN LAN
SEGGER
tunnel
server
TCP/IP- Debugger
Server
PC Internet PC
USB/Ethernet
J-Link
JTAG
Target
CPU
Example scenario
A device vendor is developing a new device which shall be supported by J-Link.
Because there is only one prototype, a shipment to 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. He then gives the serial number of the J-Link
to an engineer at SEGGER.
The engineer at SEGGER can use J-Link Commander or a debugger to test and debug
the new device without the need to have the device on his desk.
Troubleshooting
Problem Solution
1. Make sure the Remote server is not
blocked by any firewall.
Remote server cannot connect to tunnel
2. Make sure port 19020 is not blocked
server.
by any firewall.
3. Contact network admin.
1. Make sure Remote server is started
correctly.
J-Link Commander cannot connect to 2. Make sure the entered serial number is
tunnel server. correct.
3. Make sure port 19020 is not blocked
by any firewall. Contact network admin.
Table 3.13:
To test whether a connection to the tunnel server can be established or not a network
protocol analyzer like Wireshark can help.
The network transfer of a successful connection should look like:
3.6 J-Flash
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.
J-Flash requires an additional license from SEGGER to enable programming. For
license keys, as well as evaluation licenses got to http://www.segger.com or contact
us directly.
Using the syntax given below(List of available command line options), you can
directly start J-Link SWO Viewer Cl with parameters.
3.7.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.
When running in normal mode J-Link SWO Viewer automatically performs the neces-
sary initialization to enable SWO output on the target, in GDB Server mode the ini-
tialization has to be done by the debugger.
Command Description
cpufreq Select the CPU frequency.
device Select the target device.
Selects a set of itm stimulus ports which should be used
itmmask
to listen to.
Selects a itm stimulus port which should be used to listen
itmport
to.
outputfile Print the output of SWO Viewer to the selected file.
settingsfile Specify a J-Link settings file.
swofreq Select the CPU frequency.
Table 3.14: Available command line options
3.7.2.1 cpufreq
Defines the speed in Hz the CPU is running at. If the CPU is for example running at
96 MHz, the command line should look as below.
Syntax
-cpufreq <CPUFreq>
Example
-cpufreq 96000000
3.7.2.2 device
Select the target device to enable the CPU frequency auto detection of the J-Link
DLL. To select a ST STM32F207IG as target device, the command line should look as
below.
Example
-deivce STM32F207IG
3.7.2.3 itmmask
Defines a set of stimulusports from which SWO data is received and displayed by
SWO Viewer.
If itmmask is given, itmport will be ignored.
Syntax
-itmmask <Mask>
Example
Listen on ports 0 and 2
-itmmask 0x5
3.7.2.4 itmport
Defines the stimulus port from which SWO data is received and displayed by the SWO
Viewer. Default is stimulus port 0. The command line should look as below.
Syntax
-itmport <ITMPortIndex>
Example
-itmport 0
3.7.2.5 outputfile
Define a file to which the output of SWO Viewer is printed.
Syntax
-outputfile <PathToFile>
Example
-outputfile "C:\Temp\Output.log"
3.7.2.6 settingsfile
Select a J-Link settings file to use for the target device.
Syntax
-settingsfile <PathToFile>
Example
-settingsfile "C:\Temp\Settings.jlink"
3.7.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.
Syntax
-swofreq <SWOFreq>
Example
-swofreq 6000
* *
**********************************************************************
----------------------------------------------------------------------
File : SWO.c
Purpose : Simple implementation for output via SWO for Cortex-M processors.
It can be used with any IDE. This sample implementation ensures that
output via SWO is enabled in order to gurantee that the application
does not hang.
/*********************************************************************
*
* Prototypes (to be placed in a header file such as SWO.h)
*/
void SWO_PrintChar (char c);
void SWO_PrintString(const char *s);
/*********************************************************************
*
* Defines for Cortex-M debug unit
*/
#define ITM_STIM_U32 (*(volatile unsigned int*)0xE0000000) // STIM word access
#define ITM_STIM_U8 (*(volatile char*)0xE0000000) // STIM Byte access
#define ITM_ENA (*(volatile unsigned int*)0xE0000E00) // ITM Enable Reg.
#define ITM_TCR (*(volatile unsigned int*)0xE0000E80) // ITM Trace Control Reg.
/*********************************************************************
*
* SWO_PrintChar()
*
* Function description
* Checks if SWO is set up. If it is not, return,
* to avoid program hangs if no debugger is connected.
* If it is set up, print a character to the ITM_STIM register
* in order to provide data for SWO.
* Parameters
* c: The Chacracter to be printed.
* Notes
* Additional checks for device specific registers can be added.
*/
void SWO_PrintChar(char c) {
//
// Check if ITM_TCR.ITMENA is set
//
if ((ITM_TCR & 1) == 0) {
return;
}
//
// Check if stimulus port is enabled
//
if ((ITM_ENA & 1) == 0) {
return;
}
//
// Wait until STIMx is ready,
// then send data
//
while ((ITM_STIM_U8 & 1) == 0);
ITM_STIM_U8 = c;
}
/*********************************************************************
*
* SWO_PrintString()
*
* Function description
* Print a string via SWO.
*
*/
void SWO_PrintString(const char *s) {
//
// Print out character per character
//
while (*s) {
SWO_PrintChar(*s++);
}
}
3.8 J-Scope
J-Scope is a free-of-charge software to analyze and visualize data on a microcontrol-
ler in real-time, while the target is running.
Sampling can be done using either SEGGER High-Speed-Sampling (HSS) or SEGGER
RTT technology.
Both technologies are available to all MCUs that provide background memory access.
SEGGER HSS can be used without any further preparation. SEGGER RTT enables
faster sampling speeds but requires instrumentation of the target application as
described in Instrumenting an application to use it with J-Scope on page 154.
J-Scope can be used alongside other applications, e.g. a debugger, which are con-
nected to J-Link and share the connection to the J-Link. If J-Scope is used in this
mode select "Existing Session" as connection type.
All Target options will be disabled, as they are already determined by the running
session.
Note: In attach mode J-Scope will connect to J-Link indirectly via another appli-
cation connected to J-Link. J-Scope can only be used while the connection is active,
e.g. a debug session is running. It is the applications responsibility to set up the tar-
get and J-Link connection and to manage target execution. RTT can not be used in
attach mode.
Connecting to J-Link
I. Categorized mode Shows the symbols in a tree view as children of their compi-
(default) lation unit file (e.g. _NumAllocs is defined in FS_Core.c)
I. Alphabetical mode Shows all symbols in alphabetical order
II. Selection of array While complete arrays are not available for sampling, array
elements elements of supported base types can be sampled. In order
to sample specific array elements, numbers can be filled in
the corresponding field (IIa). After the user confirmed his
input by pressing enter, a selectable row is added to the dia-
log (IIb)
III. Selection of base Supported symbols are listed with a check box in the "Add
types Symbol" column. Symbols can be added to the list of sam-
pled symbols by enabling the check box.
IV. Selection of struct Member of a specific struct can be shown in a tree view by
members clicking to "+" next to a structs name.
V. Search Provides a case-insensitive search. Symbols which cannot be
selected are not shown in the search results. Structs are
shown as longs a their name or the name of at least one
member contains the search string. The user can right click
on a symbol in order to show all children of the symbol
clicked, even if they do not match the search string.
I. Toolbar
II. Zoom target indicator bar
III. Legend
IV. Graph area
V. Symbol watch
VI. Statusbar
3.8.5.1 Toolbar
I. Shows either the time (HSS mode / RTT mode with timestamp) or sample
number (RTT mode w/o timestamp) at the position of the Zoom target indi-
cator (orange line, "ZTI")
II. Show the time / sample number difference between the ZTI and the vertical
central line
3.8.5.3 Legend
Shows Color, Number, Name, Y-Resolution and Y-Offset for each symbol.
Shows X-Resolution of the graph area.
The legend can be moved independently of the main window. If the main windows is
moved, it will snap to the top right corner of the graph area.
Area where the graphs are drawn. The area is divided into divisions of 100x100 pixels
(thin gray lines, eg. I).
At startup, the area is 800px high and 1000px wide. The 4th line from the top (IIa)
and the 5th line from the right(IIb) are called central lines and have little marks
every 20px.
Their position is independent from the window size.
On the left side of the graph area(III), each symbol's base line is indicated by a label
containing the symbol number.
A symbol's base line can be changed by moving the respective label (grab and
move).
I. Symbol name according to the .elf file provided (HSS mode) or "Symbol NR
n" (RTT mode). Preceded by either a check mark (symbol is shown) or a
"X"(symbol is hidden)
II. Address of the symbol according to the .elf file (HSS mode only)
III. Size of the symbol
IV. Type of the symbol (HSS mode only)
V. Most current value sampled
VI. Color of the graph representing the symbol
VII. Minimum, Maximum and AVG sample value of the symbol
3.8.5.6 Statusbar
3.8.7 Controls
The following table describes all user actions possible due to mouse or keyboard
inputs.
Naming Examples
Workflow Examples.
• The user wants to sample a signed int, an unsigned int and a signed char
• The user wants to provide a timestamp.
• Accordingly, a RTT channel is named JScope_t4i4u4i1
• Depending on the use case, sampling for example is done on a timer or condition
Case I
• For this example, the user decides that sampling should be done every 100µs
• The users adds a time based interrupt which occurs every 100µs. The respective
ISR collects the necessary data and the current timestamp.
• Afterwards, the ISR calls SEGGER_RTT_Write()
Case II
• In an other use case, the user may decides that sampling should be done once a
specific function is called.
• The user adds a subfunction call to this function. The subfunction prepares the
data, which either can be passed as a parameter or can be available in a global
scope, and writes it to the RTT Buffer using SEGGER_RTT_Write().
Policies in RTT mode
• RTT channel name and data format must not be changed during a sampling ses-
sion.
• RTT channel name and data format can be changed between sampling sessions
(No restart of J-Scope required).
• The RTT channel name must be set accordingly to the data format.
• Only full packets according to the data format declared by the RTT channel name
may be written to the RTT channel.
• RTT packets must be sent in order.
• RTT mode should be NO_BLOCK_SKIP or BLOCK_IF_FIFO_FULL.
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 th input file for the SWO Analyzer,
the J-Link config file needs to be modified.
It should contain the following lines:
[SWO]
SWOLogFile="C:\TestSWO.dat"
SVF is a standard format for boundary scan vectors to be used with different tools
and targets. SVF files contain human-readable ASCII SVF statements consisting of an
SVF command, the data to be sent, the expected response, a mask for the response
or additional information.
JTAGLoad supports following SVF commands:
• ENDDR
• ENDIR
• FREQUENCY
• HDR
• HIR
• PIOMAP
• PIO
• RUNTEST
• SDR
• SIR
• STATE
• TDR
• TIR
A simple SVF file to read the JTAG ID of the target can look like following:
SVD files allow even more complex tasks, basically everything which is possible via
JTAG and the devices in the scan chain, like configuring an FPGA or loading data into
memory.
Syntax
-CommanderScript <CommandFilePath>
Example
See Using command files on page 98
-DRPre, -DRPost, -IRPre and -IRPost (Scan-Chain Configuration )
STR91x allows to configure a specific scan-chain via command-line. To use this fea-
ture four command line options have to be specified in order to allow a proper con-
nection to the proper device. In case of passing an incomplete configuration, the
utility tries to auto-detect.
Syntax
-DRPre <DRPre>
-DRPost <DRPost>
-IRPre <IRPre>
-IRPost <IRPost>
Example
JLink.exe -DRPre 1 -DRPost 4 -IRPre 16 -IRPost 20
-IP
Selects IP as host interface to connect to J-Link. Default host interface is USB.
Syntax
-IP <IPAddr>
Example
JLinkSTR91x.exe -IP 192.168.1.17
Additional information
To select from a list of all available emulators on Ethernet, please use * as <IPAddr>.
-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 STR91x Commander
shall run and each connects to another J-Link.
Syntax
-SelectEmuBySN <SerialNo>
Example
JLinkSTR91x.exe -SelectEmuBySN 580011111
Note: Unprotecting a secured device or will cause a mass erase of the flash
memory.
-IP <IPAddr>
Example
Additional information
To select from a list of all available emulators on Ethernet, please use * as <IPAddr>.
-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>
Example
-Speed
Starts J-Link STM32 Unlock Utility with a given initial speed. Available parameters
are "adaptive", "auto" or a freely selectable integer value in kHz. It is recom-
mended to use either a fixed speed or, if it is available on the target, adaptive
speeds. Default interface speed is 1000 kHz.
Syntax
-Speed <Speed_kHz>
-SetPowerTarget
The connected debug probe will power the target via pin 19 of the debug connector.
Syntax
-SetPowerTarget <Mode>
Example
-SetDeviceFamily
This command allows to specify a device family, so that no user input is required to
start the unlocking process.
Syntax
-SetDeviceFamily <Parameter>
Parameter
There are two different options to specify the device family to be used:
a) Pass the list index from the list which shows all supported familys on start up
ListIndex Name
1 STM32F0xxxx
2 STM32F1xxxx
3 STM32F2xxxx
4 STM32F3xxxx
5 STM32F4xxxx
6 STM32L1xxxx
Table 3.15: Available Parameter for -SetDeviceFamily
Example
-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.
Syntax
-Exit <Mode>
Example
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 documenta-
tion package, which also includes a kernel mode J-Link USB driver in your host sys-
tem.
2. The Welcome dialog box is opened. Click Next > to open the Choose Destina-
tion Location dialog box.
6. The J-Link DLL Updater pops up, which allows you to update the DLL of an
installed IDE to the DLL verion which is included in the installer. For further infor-
mation about the J-Link DLL updater, please refer to J-Link DLL updater on
page 179.
7. The Installation Complete dialog box appears after the copy process. Close the
installation wizard with the Finish > button.
The J-Link software and documentation pack is successfully installed on your PC.
8. Connect your J-Link via USB with your PC. The J-Link will be identified and after
a short period the J-Link LED stops rapidly flashing and stays on permanently.
In addition you can verify the driver installation by consulting the Windows device
manager. If the driver is installed and your J-Link / J-Trace is connected to your com-
puter, the device manager should list the J-Link USB driver as a node below "Univer-
sal Serial Bus controllers" as shown in the following screenshot:
Right-click on the driver to open a context menu which contains the command Prop-
erties. If you select this command, a J-Link driver Properties dialog box is opened
and should report: This device is working properly.
If you experience problems, refer to the chapter Support and FAQs on page 419 for
help. You can select the Driver tab for detailed information about driver provider,
version, date and digital signer.
4.4 FAQs
Q: How can I use J-Link with GDB and Ethernet?
A: You have to use the J-Link GDB Server in order to connect to J-Link via GDB and
Ethernet.
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.
A debugger / software which does not provide such a functionality, the J-Link DLL
automatically detects that multiple J-Links are connected to the PC and shows a
selection dialog which allows the user to select the appropriate J-Link he wants 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.
4.7.2.1 Updating the J-Link DLL in the IAR Embedded Workbench for
ARM (EWARM)
It is recommended to use the J-Link DLL updater to update the J-Link DLL in the IAR
Embedded Workbench. The IAR Embedded Workbench IDE is a high-performance
integrated development environment with an editor, compiler, linker, debugger. The
compiler generates very efficient code and is widely used. It comes with the J-
LinkARM.dll in the arm\bin subdirectory of the installation directory. To update this
DLL, you should backup your original DLL and then replace it with the new one.
Typically, the DLL is located in C:\Program Files\IAR Systems\Embedded Work-
bench 6.n\arm\bin\.
After updating the DLL, it is recommended to verify that the new DLL is loaded as
described in Determining which DLL is used by a program on page 180.
J-Link DLL updater
The J-Link DLL updater is a tool which comes with the J-Link software and allows the
user to update the JLinkARM.dll in all installations of the IAR Embedded Work-
bench, in a simple way. The updater is automatically started after the installation of a
J-Link software version and asks for updating old DLLs used by IAR. The J-Link DLL
updater can also be started manually. Simply enable the checkbox left to the IAR
installation which has been found. Click Ok in order to update the JLinkARM.dll
used by the IAR installation.
Process Explorer is - at the time of writing - a free utility which can be downloaded
from www.sysinternals.com.
• Click OK.
• Add the device name to the connection string (e.g. JLinkUSB:174200001:Device
STM32F103ZG).
• Click Apply.
• In the Files tab, select the application to download.
• In the Debugger tab, select 'Debug from symbol' and enter main or select Debug
from entry point.
• Click Apply.
• Start a new debug session with the newly created debug configuration.
• Now the debug session should start and downloaded the application to the tar-
get.
Chapter 5
This chapter describes functionality and how to use J-Link and J-Trace.
5.1.3 Problems
If you experience problems with any of the steps described above, read the chapter
Support and FAQs on page 419 for troubleshooting tips. If you still do not find appro-
priate help there and your J-Link / J-Trace is an original SEGGER product, you can
contact SEGGER support via e-mail. Provide the necessary information about your
target processor, board etc. and we will try to solve your problem. A checklist of the
required information together with the contact information can be found in chapter
Support and FAQs on page 419 as well.
5.2 Indicators
J-Link uses indicators (LEDs) to give the user some information about the current
status of the connected J-Link. All J-Links feature the main indicator. Some newer J-
Links such as the J-Link Pro / Ultra come with additional input/output Indicators. In
the following, the meaning of these indicators will be explained.
GREEN, switched off for J-Link heart beat. Will be activated after the emulator
10ms once per second has been in idle mode for at least 7 seconds.
GREEN, switched off for J-Link heart beat. Will be activated after the emulator
10ms once per second has been in idle mode for at least 7 seconds.
TRST
TMS
TMS
TCK
TCK
TRST
TMS
TCK
TDI TDO
JTAG
Currently, up to 8 devices in the scan chain are supported. One or more of these
devices can be CPU cores; the other devices can be of any other type but need to
comply with the JTAG standard.
5.3.1.1 Configuration
The configuration of the scan chain depends on the application used. Read JTAG
interface on page 188 for further instructions and configuration examples.
TRST
TMS
TMS
TCK
TCK
TRST
TMS
TCK
TDI TDO
JTAG
Examples
The following table shows a few sample configurations with 1,2 and 3 devices in dif-
ferent configurations.
5.4.2 SWO
Serial Wire Output (SWO) support means support for a single pin output signal from
the core. The Instrumentation Trace Macrocell (ITM) and Serial Wire Output (SWO)
can be used to form a Serial Wire Viewer (SWV). The Serial Wire Viewer provides a
low cost method of obtaining information from inside the MCU.
Usually it should not be necessary to configure the SWO speed because this is usually
done by the debugger.
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:
Host (PC)
Debugger Debugger
Instance 1 Instance 2
USB
J-Link
JTAG
Both debuggers share the same physical connection. The core to debug is selected
through the JTAG-settings as described below.
6. Choose Project|Options and configure your second scan chain. The following
dialog box shows the configuration for the second ARM core on your target.
The sketch below shows a host, running two application programs. Each application-
communicates with one CPU core via a separate J-Link.
Host (PC)
Application Application
Instance 1 Instance 2
USB USB
J-Link J-Link
1 2
JTAG JTAG
CPU0 CPU1
Older J-Links may report USB0-3 instead of unique serial number when enumerating
via USB. For these J-Links, we recommend to re-configure them to use the new enu-
meration method (report real serial number) since the USB0-3 behavior is obsolete.
Re-configuration can be done by using the J-Link Configurator, which is part of the J-
Link software and documentation package. For further information about the J-Link
configurator and how to use it, please refer to J-Link Configurator on page 175.
Re-configuration to the old USB 0-3 enumeration method
In some special cases, it may be necessary to switch back to the obsolete USB 0-3
enumeration method. 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 oppertunity to pre-select the J-Link which should be used for a
debug session.
Below, a small instruction of how to re-configure J-Link to enumerate with the old
obsolete enumeration method in order to prevent compatibility problems, a short
instruction is give on how to set USB enumeration method to USB 2 is given:
Enumeration method
1 0x00 / 0xFF: USB-Address is used for enumeration.
0x01: Real-SN is used for enumeration.
Table 5.10: Config area layout: USB-Enumeration settings
5.7.1 Tabs
The J-Link status window supports different features which are grouped in tabs. The
organization of each tab and the functionality which is behind these groups will be
explained in this section
5.7.1.1 General
In the General section, general information about J-Link and the target hardware
are shown. Moreover the following general settings can be configured:
• Show tray icon: If this checkbox is disabled the tray icon will not show from the
next time the DLL is loaded.
• Start minimized: If this checkbox is disabled the J-Link status window will show
up automatically each time the DLL is loaded.
• Always on top: if this checkbox is enabled the J-Link status window is always
visible even if other windows will be opened.
The general information about target hardware and J-Link which are shown in this
section, are:
• Process: Shows the path of the file which loaded the DLL.
• J-Link: Shows OEM of the connected J-Link, the hardware version and the Serial
number. If no J-Link is connected it shows "not connected" and the color indica-
tor is red.
• Target interface: Shows the selected target interface (JTAG/SWD) and the cur-
rent JTAG speed. The target current is also shown. (Only visible if J-Link is con-
nected)
• Endian: Shows the target endianess (Only visible if J-Link is connected)
• Device: Shows the selected device for the current debug session.
• License: Opens the J-Link license manager.
• About: Opens the about dialog.
5.7.1.2 Settings
In the Settings section project- and debug-specific settings can be set. It allows the
configuration of the use of flash download and flash breakpoints and some other tar-
get specific settings which will be explained in this topic. Settings are saved in the
configuration file. This configuration file needs to be set by the debugger. If the
debugger does not set it, settings can not be saved. All settings can only the changed
by the user himself. All settings which are modified during the debug session have to
be saved by pressing 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 set-
tings can be configured. When a license for J-Link FlashDL is found, the color indi-
cator is green and "License found" appears right to the J-Link FlashDL usage
settings.
• Auto: This is the default setting of J-Link FlashDL usage. If a license is found
J-Link FlashDL is enabled. Otherwise J-Link FlashDL will be disabled inter-
nally.
• On: Enables the J-Link FlashDL feature. If no license has been found an error
message appears.
• Off: Disables the J-Link FlashDL feature.
• Skip download on CRC match: J-Link checks the CRC of the flash content to
determine if the current application has already been downloaded to the flash. If
a CRC match occurs, the flash download is not necessary and skipped. (Only
available if J-Link FlashDL usage is configured as Auto or On)
• Verify download: If this checkbox is enabled J-Link verifies the flash content
after the download. (Only available if J-Link FlashDL usage is configured as
Auto or On)
Section: Flash breakpoints:
In this section, settings for the use of the FlashBP feature and related settings can
be configured. When a license for FlashBP is found, the color indicator is green and
"License found" appears right to the FlashBP usage settings.
• Auto: This is the default setting of FlashBP usage. If a license has been found
the FlashBP feature will be enabled. Otherwise FlashBP will be disabled inter-
nally.
• On: Enables the FlashBP feature. If no license has been found an error message
appears.
• Off: Disables the FlashBP feature.
• Show window during program: When this checkbox is enabled the "Program-
ming flash" window is shown when flash is re-programmed in order to set/clear
flash breakpoints.
• Log file: Shows the path where the J-Link log file is placed. It is possible to
override the selection manually by enabling the Override checkbox. If the Over-
ride checkbox is enabled a button appears which let the user choose the new
location of the log file.
• Settings file: Shows the path where the configuration file is placed. This config-
uration file contains all the settings which can be configured in the Settings tab.
• Override device selection: If this checkbox is enabled, a dropdown list
appears, which allows the user to set a device manually. This especially makes
sense when J-Link can not identify the device name given by the debugger or if a
particular device is not yet known to the debugger, but to the J-Link software.
• Allow caching of flash contents: If this checkbox is enabled, the flash con-
tents are cached by J-Link to avoid reading data twice. This speeds up the trans-
fer between debugger and target.
• Allow instruction set simulation: If this checkbox is enabled, instructions will
be simulated as far as possible. This speeds up single stepping, especially when
FlashBPs are used.
• 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.
• Modify breakpoints during execution: This dropdown box allows the user to
change the behavior of the DLL when setting breakpoints if the CPU is running.
The following options are available:
Allow: Allows settings breakpoints while the CPU is running. If the CPU needs to
be halted in order to set the breakpoint, the DLL halts the CPU, sets the break-
points and restarts the CPU.
Allow if CPU does not need to be halted: Allows setting breakpoints while the
CPU is running, if it does not need to be halted in order to set the breakpoint. If
the CPU has to be halted the breakpoint is not set.
Ask user if CPU needs to be halted: If the user tries to set a breakpoint while
the CPU is running and the CPU needs to be halted in order to set the breakpoint,
the user is asked if the breakpoint should be set. If the breakpoint can be set
without halting the CPU, the breakpoint is set without explicit confirmation by the
user.
Do not allow: It is not allowed to set breakpoints while the CPU is running.
5.7.1.3 Break/Watch
In the Break/Watch section all breakpoints and watchpoints which are in the DLL
internal breakpoint and watchpoint list are shown.
Section: Code
Lists all breakpoints which are in the DLL internal breakpoint list are shown.
• Handle: Shows the handle of the breakpoint.
• Address: Shows the address where the breakpoint is set.
• Mode: Describes the breakpoint type (ARM/THUMB)
• Permission: Describes the breakpoint implementation flags.
• Implementation: Describes the breakpoint implementation type. The break-
point types are: RAM, Flash, Hard. An additional TBC (to be cleared) or TBS (to
be set) gives information about if the breakpoint is (still) written to the target or
if it’s just in the breakpoint list to be written/cleared.
Note: It is possible for the debugger to bypass the breakpoint functionality of
the J-Link software 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). In these cases,
the J-Link software cannot determine the breakpoints set and the list is empty.
Section: Data
In this section, all data breakpoints which are listed in the DLL internal breakpoint
list are shown.
• Handle: Shows the handle of the data breakpoint.
• Address: Shows the address where the data breakpoint is set.
• AddrMask: Specifies which bits of Address are disregarded during the compari-
son for a data breakpoint match. (A 1 in the mask means: disregard this bit)
• Data: Shows on which data to be monitored at the address where the data
breakpoint is set.
• Data Mask: Specifies which bits of Data are disregarded during the comparison
• for a data breakpoint match. (A 1 in the mask means: disregard this bit)
• Ctrl: Specifies the access type of the data breakpoint (read/write).
• CtrlMask: Specifies which bits of Ctrl are disregarded during the comparison for
a data breakpoint match.
5.7.1.4 Log
In this section the log output of the DLL is shown. The user can determine which
function calls should be shown in the log window.
5.7.1.7 SWV
In this section SWV information are shown.
• 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.
• Bytes transferred: Shows how many bytes have been transferred via SWV,
since the debug session has been started.
• Refresh counter: Shows how often the SWV information in this section has
been updated since the debug session has been started.
• Host buffer: Shows the reserved buffer size for SWV data, on the host side.
• Emulator buffer: Shows the reserved buffer size for SWV data, on the emulator
side.
5.8.2.8 Type 7: Reset for Analog Devices CPUs (ADI Halt after kernel)
Performs a reset of the core and peripherals by setting the SYSRESETREQ bit in the
AIRCR. The core is allowed to perform the ADI kernel (which enables the debug inter-
face) but the core is halted before the first instruction after the kernel is executed in
order to guarantee that no user application code is performed after reset.
instruction of the user code is executed. Then the watchdog of the LPC1200 device is
disabled. This reset strategy is only guaranteed to work on "modern" J-Links (J-Link
V8, J-Link Pro, J-link ULTRA, J-Trace for Cortex-M, J-Link Lite) and if a SWD speed of
min. 1 MHz is used. This reset strategy should also work for J-Links with hardware
version 6, but it can not be guaranteed that these J-Links are always fast enough in
disabling the watchdog.
5.10.1.1 ResetTarget()
Description
If present, it replaces the reset strategy performed by the DLL when issuing a reset.
Prototype
void ResetTarget(void);
5.10.1.2 InitEMU()
Description
If present, it allows configuration of the emulator prior to starting target communica-
tion. 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 on page 219.
Prototype
void InitEMU(void);
5.10.1.3 InitTarget()
Description
If present, it can replace the auto-detection capability of J-Link. Some targets can
not be auto-detected by J-Link since some special target initialization is necessary
before communication with the core is possible. Moreover, J-Link uses a TAP reset to
get the JTAG IDs of the devices in the JTAG chain. On some targets this disables
access to the core.
Prototype
void InitTarget(void);
5.10.2.1 MessageBox()
Description
Outputs a string in a message box.
Prototype
__api__ int MessageBox(const char * sMsg);
5.10.2.2 MessageBox1()
Description
Outputs a constant character string in a message box. In addition to that, a given
value (can be a constant value, the return value of a function or a variable) is added,
right behind the string.
Prototype
__api__ int MessageBox1(const char * sMsg, int v);
5.10.2.3 Report()
Description
Outputs a constant character string on stdio.
Prototype
__api__ int Report(const char * sMsg);
5.10.2.4 Report1()
Description
Outputs a constant character string on stdio. In addition to that, a given value (can
be a constant value, the return value of a function or a variable) is added, right
behind the string.
Prototype
__api__ int Report1(const char * sMsg, int v);
5.10.2.5 JTAG_SetDeviceId()
Description
Sets the JTAG ID of a specified device, in the JTAG chain. The index of the device
depends on its position in the JTAG chain. The device closest to TDO has index 0. The
Id is used by the DLL to recognize the device.
Before calling this function, please make sure that the JTAG chain has been config-
ured correctly by setting the appropriate global DLL variables. For more information
about the known global DLL variables, please refer to Global DLL variables on
page 219.
Prototype
__api__ int JTAG_SetDeviceId(int DeviceIndex, unsigned int Id);
5.10.2.6 JTAG_GetDeviceId()
Description
Retrieves the JTAG ID of a specified device, in the JTAG chain. The index of the
device depends on its position in the JTAG chain. The device closest to TDO has index
0.
Prototype
__api__ int JTAG_GetDeviceId(int DeviceIndex);
5.10.2.7 JTAG_WriteIR()
Description
Writes a JTAG instruction.
Before calling this function, please make sure that the JTAG chain has been config-
ured correctly by setting the appropriate global DLL variables. For more information
about the known global DLL variables, please refer to Global DLL variables on
page 219.
Prototype
__api__ int JTAG_WriteIR(unsigned int Cmd);
5.10.2.8 JTAG_StoreIR()
Description
Stores a JTAG instruction in the DLL JTAG buffer.
Before calling this function, please make sure that the JTAG chain has been config-
ured correctly by setting the appropriate global DLL variables. For more information
about the known global DLL variables, please refer to Global DLL variables on
page 219.
Prototype
__api__ int JTAG_StoreIR(unsigned int Cmd);
5.10.2.9 JTAG_WriteDR()
Description
Writes JTAG data.
Before calling this function, please make sure that the JTAG chain has been config-
ured correctly by setting the appropriate global DLL variables. For more information
about the known global DLL variables, please refer to Global DLL variables on
page 219.
Prototype
__api__ int JTAG_WriteDR(unsigned __int64 tdi, int NumBits);
5.10.2.10JTAG_StoreDR()
Description
Stores JTAG data in the DLL JTAG buffer.
Before calling this function, please make sure that the JTAG chain has been config-
ured correctly by setting the appropriate global DLL variables. For more information
about the known global DLL variables, please refer to Global DLL variables on
page 219.
Prototype
__api__ int JTAG_StoreDR(unsigned __int64 tdi, int NumBits);
5.10.2.11JTAG_Write()
Description
Writes a JTAG sequence (max. 64 bits per pin).
Prototype
__api__ int JTAG_Write(unsigned __int64 tms, unsigned __int64 tdi, int
NumBits);
5.10.2.12JTAG_Store()
Description
Stores a JTAG sequence (max. 64 bits per pin) in the DLL JTAG buffer.
Prototype
__api__ int JTAG_Store(unsigned __int64 tms, unsigned __int64 tdi, int
NumBits);
5.10.2.13JTAG_GetU32()
Description
Gets 32 bits JTAG data, starting at given bit position.
Prototype
__api__ int JTAG_GetU32(int BitPos);
5.10.2.14JTAG_WriteClocks()
Description
Writes a given number of clocks.
Prototype
__api__ int JTAG_WriteClocks(int NumClocks);
5.10.2.15JTAG_StoreClocks()
Description
Stores a given number of clocks in the DLL JTAG buffer.
Prototype
__api__ int JTAG_StoreClocks(int NumClocks);
5.10.2.16JTAG_Reset()
Description
Performs a TAP reset and tries to auto-detect the JTAG chain (Total IRLen, Number of
devices). If auto-detection was successful, the global DLL variables which determine
the JTAG chain configuration, are set to the correct values. For more information
about the known global DLL variables, please refer to Global DLL variables on
page 219.
Note: This will not work for devices which need some special init (for example to
add the core to the JTAG chain), which is lost at a TAP reset.
Prototype
__api__ int JTAG_Reset(void);
5.10.2.17SYS_Sleep()
Description
Waits for a given number of miliseconds. During this time, J-Link does not communi-
cate with the target.
Prototype
__api__ int SYS_Sleep(int Delayms);
5.10.2.18 JLINK_CORESIGHT_AddAP()
Description
Allows the user to manually configure the AP-layout of the device J-Link is connected
to. 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 on page 222.
Prototype
__api__ int JLINK_CORESIGHT_AddAP(int Index, unsigned int Type);
Example
JLINK_CORESIGHT_AddAP(0, CORESIGHT_AHB_AP); // First AP is a AHB-AP
JLINK_CORESIGHT_AddAP(1, CORESIGHT_APB_AP); // Second AP is a APB-AP
JLINK_CORESIGHT_AddAP(2, CORESIGHT_JTAG_AP); // Third AP is a JTAG-AP
5.10.2.19JLINK_CORESIGHT_Configure()
Description
Has to be called once, before using any other _CORESIGHT_ function that accesses
the DAP.
Takes a configuration string to prepare target and J-Link for CoreSight function
usage. Configuration string may contain multiple setup parameters that are set.
Setup parameters are separated by a semicolon.
At the end of the JLINK_CORESIGHT_Configure(), the appropriate target interface
switching sequence for the currently active target interface is output, if not disabled
via setup parameter.
This function has to be called again, each time the JTAG chain changes (for dynami-
cally changing JTAG chains like those which include a TI ICEPick), in order to setup
the JTAG chain again.
For JTAG
The SWD -> JTAG switching sequence is output. This also triggers a TAP reset on the
target (TAP controller goes through -> Reset -> Idle state)
The IRPre, DRPre, IRPost, DRPost parameters describe which device inside the JTAG
chain is currently selected for communication.
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 reg-
ister is cleared, as in SWD mode J-Link always assumes that overrun detection mode
is disabled.
Make sure that this bit is NOT set by accident when writing the SW-DP CTRL/STAT
register via the _CORESIGHT_ functions.
Prototype
int JLINK_CORESIGHT_Configure(const char* sConfig);
Example
if (MAIN_ActiveTIF == JLINK_TIF_JTAG) {
// Simple setup where we have TDI -> Cortex-M (4-bits IRLen) -> TDO
JLINK_CORESIGHT_Configure("IRPre=0;DRPre=0;IRPost=0;DRPost=0;IRLenDevice=4");
} else {
// For SWD, no special setup is needed, just output the switching sequence
JLINK_CORESIGHT_Configure("");
}
v = JLINK_CORESIGHT_ReadDP(JLINK_CORESIGHT_DP_REG_CTRL_STAT);
Report1("DAP-CtrlStat: " v);
// Complex setup where we have TDI -> ICEPick (6-bits IRLen) -> Cortex-M (4-bits
IRLen) -> TDO
JLINK_CORESIGHT_Configure("IRPre=0;DRPre=0;IRPost=6;DRPost=1;IRLenDevice=4;");
v = JLINK_CORESIGHT_ReadDP(JLINK_CORESIGHT_DP_REG_CTRL_STAT);
Report1("DAP-CtrlStat: " v)
5.10.2.20JLINK_CORESIGHT_ReadAP()
Description
Reads a specific AP register.
For JTAG, makes sure that AP is selected automatically.
Makes sure that actual data is returned, meaning for register read-accesses which
usually only return data on the second access, this function performs this automati-
cally, so the user will always see valid data.
Prototype
int JLINK_CORESIGHT_ReadAP(unsigned int RegIndex);
Example
v = JLINK_CORESIGHT_ReadAP(JLINK_CORESIGHT_AP_REG_DATA);
Report1("DATA: " v);
5.10.2.21JLINK_CORESIGHT_ReadDP()
Description
Reads a specific DP register.
For JTAG, makes sure that DP is selected automatically.
Makes sure that actual data is returned, meaning for register read-accesses which
usually only return data on the second access, this function performs this automati-
cally, so the user will always see valid data.
Prototype
int JLINK_CORESIGHT_ReadDP(unsigned int RegIndex);
Example
v = JLINK_CORESIGHT_ReadDP(JLINK_CORESIGHT_DP_REG_IDCODE);
Report1("DAP-IDCODE: " v);
5.10.2.22JLINK_CORESIGHT_WriteAP()
Description
Writes a specific AP register.
For JTAG, makes sure that AP is selected automatically.
Prototype
int JLINK_CORESIGHT_WriteAP(unsigned int RegIndex, unsigned int Data);
Example
JLINK_CORESIGHT_WriteAP(JLINK_CORESIGHT_AP_REG_BD1, 0x1E);
5.10.2.23JLINK_CORESIGHT_WriteDP()
Description
Writes a specific DP register.
For JTAG, makes sure that DP is selected automatically.
Prototype
int JLINK_CORESIGHT_WriteDP(unsigned int RegIndex, unsigned int Data);
Example
JLINK_CORESIGHT_WriteDP(JLINK_CORESIGHT_DP_REG_ABORT, 0x1E);
• ARM966ES
• ARM968ES
• ARM11
• ARM1136
• ARM1136J
• ARM1136JS
• ARM1136JF
• ARM1136JFS
• ARM1156
• ARM1176
• ARM1176J
• ARM1176JS
• ARM1176IF
• ARM1176JFS
• CORTEX_M0
• CORTEX_M1
• CORTEX_M3
• CORTEX_M3R1P0
• CORTEX_M3R1P1
• CORTEX_M3R2P0
• CORTEX_M4
• CORTEX_M7
• CORTEX_A5
• CORTEX_A7
• CORTEX_A8
• CORTEX_A9
• CORTEX_A12
• CORTEX_A15
• CORTEX_A17
• CORTEX_R4
• CORTEX_R5
void InitTarget(void) {
Report("J-Link script example.");
JTAG_Reset(); // Perform TAP reset and J-Link JTAG auto-detection
if (JTAG_TotalIRLen != 9) { // Basic check if JTAG chain information matches
MessageBox("Can not find xxx device");
return 1;
}
JTAG_DRPre = 0; // Cortex-A8 is closest to TDO, no no pre devices
JTAG_DRPost = 1; // 1 device (custom device) comes after the Cortex-A8
JTAG_IRPre = 0; // Cortex-A8 is closest to TDO, no no pre IR bits
JTAG_IRPost = 5; // custom device after Cortex-A8 has 5 bits IR len
JTAG_IRLen = 4; // We selected the Cortex-A8, it has 4 bits IRLen
CPU = CORTEX_A8; // We are connected to a Cortex-A8
JTAG_AllowTAPReset = 1; // We are allowed to enter JTAG TAP reset
//
// We have a non-CoreSight compliant Cortex-A8 here
// which does not allow auto-detection of the Core debug components base address.
// so set it manually to overwrite the DLL auto-detection
//
CORESIGHT_CoreBaseAddr = 0x80030000;
}
The JLinkSettings.ini is a settings file created by the J-Link DLL on debug session
start. If no script file is explicitly passed to the DLL, it will search in the directory of
the JLinkSettings.ini for a script file named like the settings file only with a different
file extension.
-scriptfile <file>
For more information about the -scriptfile command line parameter, please refer
to J-Link GDB Server on page 100.
Command Description
device Selects the target device.
DisableCortexMXPSRAutoC Disables auto-correction of XPSR T-bit for Cortex-M
orrectTBit devices.
DisableFlashBPs Disables the FlashPB feature.
EnableFlashBPs Enables the FlashPB feature.
map exclude Ignores all memory accesses to specified area.
map indirectread Specifies an area which should be read indirect.
map ram Specifies location of target RAM.
Restores the default mapping, which means all mem-
map reset
ory accesses are permitted.
SetAllowSimulation Enables/Disables instruction set simulation.
SetCheckModeAfterRead Enables/Disables CPSR check after read operations.
SetResetPulseLen Defines the length of the RESET pulse in milliseconds.
SetResetType Selects the reset strategy.
SetRestartOnClose Specifies restart behavior on close.
Used to power-down the debug unit of the target CPU
SetDbgPowerDownOnClose
when the debug session is closed.
Used to power-down the target CPU, when there are
SetSysPowerDownOnIdle no transmissions between J-Link and target CPU, for a
specified timeframe.
Activates/Deactivates power supply over pin 19 of the
SupplyPower
JTAG connector.
Activates/Deactivates power supply over pin 19 of the
SupplyPowerDefault
JTAG connector permanently.
Table 5.12: Available command line options
5.11.1.1 device
This command selects the target device.
Syntax
device = <DeviceID>
DeviceID has to be a valid device identifier. For a list of all available device identifi-
ers please refer to chapter Supported devices on page 242.
Example
device = AT91SAM7S256
5.11.1.2 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, esepcially 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. Anyhow, if
for some reason explicit disable of this auto-correction is necessary, this can be
achieved via the following command string.
Syntax
DisableCortexMXPSRAutoCorrectTBit
5.11.1.3 DisableFlashBPs
This command disables the FlashBP feature.
Syntax
DisableFlashBPs
5.11.1.4 EnableFlashBPs
This command enables the FlashBP feature.
Syntax
EnableFlashBPs
Syntax
map exclude <SAddr>-<EAddr>
Example
This is an example for the map exclude command in combination with an NXP
LPC2148 MCU.
Memory map
0x00080000-0x3FFFFFFF Reserved
0x40008000-0x7FCFFFFF Reserved
0x7FD02000-0x7FD02000 Reserved
0x80000000-0xDFFFFFFF Reserved
To exclude these areas from being accessed through J-Link the map exclude com-
mand should be used as follows:
Example
map indirectread 0x3fffc000-0x3fffcfff
Example
map ram 0x40000000-0x40003fff;
Example
map reset
5.11.1.9 SetAllowSimulation
This command can be used to enable or disable the instruction set simulation. By
default the instruction set simulation is enabled.
Syntax
SetAllowSimulation = 0 | 1
Example
SetAllowSimulation 1 // Enables instruction set simulation
5.11.1.10 SetCheckModeAfterRead
This command is used to enable or disable the verification of the CPSR (current pro-
cessor status register) after each read operation. By default this check is enabled.
However this can cause problems with some CPUs (e.g. if invalid CPSR values are
returned). Please note that if this check is turned off (SetCheckModeAfterRead = 0),
the success of read operations cannot be verified anymore and possible data aborts
are not recognized.
Typical applications
This verification of the CPSR can cause problems with some CPUs (e.g. if invalid CPSR
values are returned). Note that if this check is turned off (SetCheckModeAfterRead =
0), the success of read operations cannot be verified anymore and possible data
aborts are not recognized.
Syntax
SetCheckModeAfterRead = 0 | 1
Example
SetCheckModeAfterRead = 0
5.11.1.11 SetResetPulseLen
This command defines the length of the RESET pulse in milliseconds. The default for
the RESET pulse length is 20 milliseconds.
Syntax
SetResetPulseLen = <value>
Example
SetResetPulseLen = 50
5.11.1.12 SetResetType
This command selects the reset startegy 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 on page 207. Please note that there different reset strategies for
ARM 7/9 and Cortex-M devices.
Syntax
SetResetType = <value>
Example
SetResetType = 0 // Selects reset strategy type 0: normal
5.11.1.13 SetRestartOnClose
This command specifies whether the J-Link restarts target execution on close. The
default is to restart target execution. This can be disabled by using this command.
Syntax
SetRestartOnClose = 0 | 1
Example
SetRestartOnClose = 1
5.11.1.14 SetDbgPowerDownOnClose
When using this command, the debug unit of the target CPU is powered-down when
the debug session is closed.
Note: This command works only for Cortex-M3 devices
Typical applications
This feature is useful to reduce the power consumption of the CPU when no debug
session is active.
Syntax
SetDbgPowerDownOnClose = <value>
Example
SetDbgPowerDownOnClose = 1 // Enables debug power-down on close.
SetDbgPowerDownOnClose = 0 // Disables debug power-down on close.
5.11.1.15 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.
Typical applications
This feature is useful to reduce the power consumption of the CPU.
Syntax
SetSysPowerDownOnIdle = <value>
5.11.1.16 SupplyPower
This command activates power supply over pin 19 of the JTAG connector. The KS
(Kickstart) versions of J-Link have the V5 supply over pin 19 activated by default.
Typical applications
This feature is useful for some eval boards that can be powered over the JTAG con-
nector.
Syntax
SupplyPower = 0 | 1
Example
SupplyPower = 1
5.11.1.17 SupplyPowerDefault
This command activates power supply over pin 19 of the JTAG connector perma-
nently. The KS (Kickstart) versions of J-Link have the V5 supply over pin 19 activated
by default.
Typical applications
This feature is useful for some eval boards that can be powered over the JTAG con-
nector.
Syntax
SupplyPowerDefault = 0 | 1
Example
SupplyPowerDefault = 1
Example
exec SupplyPower = 1
exec map reset
exec map exclude 0x10000000-0x3FFFFFFF
Chapter 6
Flash download
This chapter describes how the flash download feature of the DLL can be used in dif-
ferent debugger environments.
6.1 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 programming of CFI-compliant external NOR flash memory. The flash down-
load feature of the J-Link DLL does not require an extra license and can be used free
of charge.
Why should I use the J-Link flash download feature?
Being able to download code directly into flash from the debugger or integrated IDE
significantly shortens the turn-around times when testing software. The flash down-
load feature of J-Link is very efficient and allows fast flash programming. For
example, if a debugger splits the download image into several pieces, the flash
download software will collect the individual parts and perform the actual flash pro-
gramming right before program execution. This avoids repeated flash programming. .
Moreover, the J-Link flash loaders make flash behave like RAM. This means that the
debugger only needs to select the correct device which enables the J-Link DLL to
automatically activate the correct flash loader if the debugger writes to a specific
memory address.
This also makes it very easy for debugger vendors to make use of the flash download
feature because almost no extra work is necessary on the debugger side since the
debugger does not have to differ between memory writes to RAM and memory writes
to flash.
6.2 Licensing
No extra license required. The flash download feature can be used free of charge.
To use the J-Link flash loaders, the IAR flash loader has to be disabled. To disable the
IAR flash loader, the checkbox Use flash loader(s) at Project->Options->Debug-
ger->Download has to be disabled, as shown below.
First, choose the device in the project settings if not already done. The device set-
tings can be found at Project->Options for Target->Device.
To enable the J-Link flash loader J-Link / J-Trace at Project->Options for Tar-
get->Utilities has to be selected. It is important that "Update Target before Debug-
ging" is unchecked since otherwise uVision tries to use its own flashloader.
<DeviceName> is the name of the device for which download into internal flash mem-
ory shall be enabled. For a list of supported devices, please refer to Supported
devices on page 242. For more information about the GDB monitor commands please
refer to J-Link GDB Server on page 100.
<DeviceName> is the name of the device for which download into internal flash mem-
ory shall be enabled. For a list of supported devices, please refer to Supported
devices on page 242. In order to start downloading the binary data file into flash,
please type in the following command:
<Filename> is the path of the binary data file which should be downloaded into the
flash.
The loadfile command supports .bin, .hex, .mot and .srec files
<Addr> is the start address, the data file should be written to.
For more information about the J-Link RDI configuration dialog please refer to
UM08004, J-Link RDI User Guide, chapter Configuration dialog.
Close the debug session and open the settings file with a text editor. Add the follow-
ing lines to the file:
[CFI]
CFISize = <FlashSize>
CFIAddr = <FlashAddr>
[GENERAL]
WorkRAMSize = <RAMSize>
WorkRAMAddr = <RAMAddr>
After this the file should look similar to the sample in the following screenshot.
For more information about the GDB monitor commands please refer to J-Link GDB
Server on page 100.
r
speed 1000
exec setcfiflash 0x64000000 - 0x64FFFFFF
exec setworkram 0x20000000 - 0x2000FFFF
w4 0x40021014, 0x00000114 // RCC_AHBENR, FSMC clock enable
w4 0x40021018, 0x000001FD // GPIOD~G clock enable
w4 0x40011400, 0xB4BB44BB // GPIOD low config, NOE, NWE => Output, NWAIT => Input
w4 0x40011404, 0xBBBBBBBB // GPIOD high config, A16-A18
w4 0x40011800, 0xBBBBBBBB // GPIOE low config, A19-A23
w4 0x40011804, 0xBBBBBBBB // GPIOE high config, D5-D12
w4 0x40011C00, 0x44BBBBBB // GPIOF low config, A0-A5
w4 0x40011C04, 0xBBBB4444 // GPIOF high config, A6-A9
w4 0x40012000, 0x44BBBBBB // GPIOG low config, A10-A15
w4 0x40012004, 0x444B4BB4 // GPIOG high config, NE2 => output
w4 0xA0000008, 0x00001059 // CS control reg 2, 16-bit, write enable, Type: NOR flash
w4 0xA000000C, 0x10000505 // CS2 timing reg (read access)
w4 0xA000010C, 0x10000505 // CS2 timing reg (write access)
speed 4000
mem 0x64000000,100
loadfile C:\STMB672_STM32F103ZE_TestBlinky.bin,0x64000000
mem 0x64000000,100
Chapter 7
Flash breakpoints
This chapter describes how the flash breakpoints feature of the DLL can be used in
different debugger environments.
7.1 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 break-
points only, a maximum of 2 (ARM 7/9/11) to 8 (Cortex-A/R) breakpoints can be set.
The flash memory can be the internal flash memory of a supported microcontroller or
external CFI-compliant flash memory. In the following sections the setup for different
debuggers for use of the flash breakpoints feature is explained.
How do breakpoints work?
There are basically 2 types of breakpoints in a computer system: Hardware break-
points and software breakpoints. Hardware breakpoints require a dedicated hardware
unit for every breakpoint. In other words, the hardware dictates how many hardware
breakpoints can be set simultaneously. ARM 7/9 cores have 2 breakpoint units (called
"watchpoint units" in ARM's documentation), allowing 2 hardware breakpoints to be
set. Hardware breakpoints do not require modification of the program code. Software
breakpoints are different: The debugger modifies the program and replaces the
breakpointed instruction with a special value. Additional software breakpoints do not
require additional hardware units in the processor, since simply more instructions are
replaced. This is a standard procedure that most debuggers are capable of, however,
this usually requires the program to be located in RAM.
What is special about software breakpoints in flash?
Flash breakpoints allows setting an unlimited number of breakpoints even if the user
application is not located in RAM. On modern microcontrollers this is the standard
scenario because on most microcontrollers the internal RAM is not big enough to hold
the complete application. When replacing instructions in flash memory this requires
re-programming of the flash which takes much more time than simply replacing a
instruction when debugging in RAM. The J-Link flash breakpoints feature is highly
optimized for fast flash programming speed and in combination with the instruction
set simulation only re-programs flash that is absolutely necessary. This makes
debugging in flash using flash breakpoints almost as flawless as debugging in RAM.
What performance can I expect?
Flash algorithm, specially designed for this purpose, sets and clears flash breakpoints
extremely fast; on microcontrollers with fast flash the difference between software
breakpoints in RAM and flash is hardly noticeable.
How is this performance achieved?
We have put a lot of effort in making flash breakpoints really usable and convenient.
Flash sectors are programmed only when necessary; this is usually the moment exe-
cution of the target program is started. A lot of times, more than one breakpoint is
located in the same flash sector, which allows programming multiple breakpoints by
programming just a single sector. The contents of program memory are cached,
avoiding time consuming reading of the flash sectors. A smart combination of soft-
ware and hardware breakpoints allows us to use hardware breakpoints a lot of times,
especially when the debugger is source level-stepping, avoiding re-programming the
flash in these situations. A built-in instruction set simulator further reduces the num-
ber of flash operations which need to be performed. This minimizes delays for the
user, while maximizing the life time of the flash. All resources of the ARM microcon-
troller are available to the application program, no memory is lost for debugging.
7.2 Licensing
In order to use the flash breakpoints feature 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 flash breakpoints but the normal J-Link
comes without any licenses. For more information about licensing itself and which
devices have a device-based license, please refer to Licensing on page 65.
7.5.1 Setup
The setup for the debugger is the same as for downloading into QSPI flash. For more
information please refer to QSPI flash support on page 252.
7.6 FAQ
Q: Why can flash breakpoints not be used with Rowley Crossworks?
A: Because Rowley Crossworks does not use the proper J-Link API to set breakpoints.
Instead of using the breakpoint-API, Crossworks programs the debug hardware
directly, leaving J-Link no choice to use its flash breakpoints.
Chapter 8
This chapter describes how to use monitor mode debugging support with J-Link.
8.1 Introduction
In general, there are two standard debug modes available for CPUs:
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. In circum-
stances halt mode may cause problems during debugging specific systems:
1. Certain parts of the application need to keep running in order to make sure that com-
munication with external components does not break down. This is the case for Blue-
tooth applications where the Bluetooth link needs to be kept up while the CPU is in
debug mode, otherwise the communication would fail and a resume or single stepping
of the user application would not be possible
2. Some peripherals are also stopped when the CPU enters debug mode. For exam-
ple; Pulse-width modulation (PWM) units for motor control applications may be
halted while in an undefined / or even dangerous state, resulting in unwanted
side-effects on the external hardware connected to these units.
This is where monitor mode debugging becomes effective. In monitor debug mode
the CPU is not halted but takes a specific debug exception and jumps into a defined
exception handler that executes (usually in a loop) a debug monitor software that
performs communication with J-Link (in order to read/write CPU registers and so on).
The main effect is the same as for halting mode: the user application is interrupted
at a specific point but in contrast to halting mode, the fact that the CPU executes a
handler also allows it to perform some specific operations on debug entry / exit or
even periodically during debug mode with almost no delay. This enables the handling
of such complex debug cases as those explained above.
/*********************************************************************
*
* execUserSetup()
*
* Function description
* Called once after the target application is downloaded.
* Implement this macro to set up the memory map, breakpoints,
* interrupts, register macro files, etc.
*/
execUserSetup() {
__message "Macro-execUserSetup(): Enabling monitor mode";
__jlinkExecCommand("SetMonModeDebug = 1");
}
J-Link>exec SetMonModeDebug = 1
8.3.1 Cortex-M3
See Cortex-M4 on page 267.
8.3.2 Cortex-M4
For Cortex-M4, monitor mode debugging is supported. The monitor code provided by
SEGGER can easily be linked into the user application.
Considerations & Limitations
• The user-specific monitor functions must not block the generic monitor for more
than 100ms.
• Manipulation of the stackpointer register (SP) from within the IDE is not possible
as the stackpointer is necessary for resuming the user application on Go().
• The unlimited number of flash breakpoints feature cannot be used in monitor
mode. This restriction may be removed in a future version.
• It is not possible to debug the monitor itself, when using monitor mode.
Chapter 9
J-Flash SPI
This chapter describes J-Flash SPI and J-Flash SPI CL, which are seperate software
(executables) which allows direct programming of 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.
9.1 Introduction
The following chapter introduces J-Flash SPI, highlights some of its features, and lists
its requirements on host and target systems.
9.1.3 Features
• Directly communicates with the SPI flash via SPI protocol, no MCU in between
needed.
• Programming of all kinds of SPI flashes is supported.
• Can also program SPI flashes that are connected to CPUs that are not supported
by J-Link.
• Verbose logging of all communication.
• .hex, .mot, .srec, and .bin support.
• Intuitive user interface.
9.1.4 Requirements
9.1.4.1 Host
J-Flash SPI requires a PC running Microsoft Windows 2000 or Windows XP 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.
9.1.4.2 Target
The flash device must be an SPI flash that supports standard SPI protocols.
9.2 Licensing
The following chapter provides an overview of J-Flash SPI related licensing options.
9.2.1 Introduction
A J-Link PLUS, ULTRA+, PRO or Flasher ARM/PRO is required to use J-Flash SPI. No
additional license is required / available.
9.3.1 Setup
For J-Link setup procedure required in order to work with J-Flash SPI, please refer to
chapter Setup on page 165
Directory Contents
Command Description
Opens a data file that may be used to flash the target
Open data file... device. The data file must be an Intel HEX file, a Motorola
S file, or a Binary file (.hex, .mot, .srec, or .bin).
Merges two data files (.hex, .mot, .srec, or .bin). All
gaps will be filled with FF. Find below a short example of
merging two data files named, File0.bin and File1.bin into
File3.bin.
Command Description
Relocates the start of the data file to the supplied hex
Relocate...
offset from the current start location.
Deletes a range of values from the data file, starting and
ending at given addresses. The End address must be
Delete range...
greater than the Start address otherwise nothing will be
done.
Eliminate blank
Eliminates blank regions within the data file.
areas...
Table 9.3: Edit menu elements
Command Description
Opens and/or brings the log window to the active win-
Log
dow.
Opens and/or brings the project window to the active
Project
window.
Table 9.4: View menu elements
Command Description
Creates a connection through the J-Link using the config-
Connect uration options set in the Project settings... of the
Options drop-down menu.
Disconnects a current connection that has been made
Disconnect
through the J-Link.
Two test functions are implemented: "Generates test
data" generates data which can be used to test if the
flash can be programmed correctly. The size of the gen-
Test > erated data file can be defined.
"Tests up/download speed" writes data of an specified
size to a defined address, reads the written data back
and measures the up- and download speed.
Erase sectors Erases all selected flash sectors.
Erase chip Erases the entire chip.
Program Programs the chip using the currently active data file.
Programs the chip using the currently active data file and
Program & Verify
then verifies that it was written successfully.
The Auto command performs a sequence of steps. It con-
nects to the device, erases sectors and programs the chip
using the currently active data file before the written
Auto
data is finally verified. The range of sectors to be erased
can be configured through the Flash tab of the Project
settings dialog and through the Global settings dialog.
Verify Verifies the data found on the chip with the data file.
Reads back the data found on the chip and creates a new
data file to store this information. There are three ways
in which the data can be read back. The Selected sectors
Read back > identified on the Flash tab of the Project Settings... found
in the Options drop-down menu may be read back. The
Entire chip may be read back. A specified Range... may
be read back.
Table 9.5: Target menu elements
Command Description
Location of the project settings that are displayed in the
snapshot view found in the Project window of the J-Flash
Project settings... SPI application. Furthermore various settings needed to
locate the J-Link and pass specified commands needed
for chip initialization.
Settings that influence the general operation of J-Flash
Global settings...
SPI.
Table 9.6: Options menu elements
Command Description
Arranges all open windows, one above the other, with the
Cascade
active window at the top.
Tiles the windows horizontally with the active window at
Tile Horizontal
the top.
Tiles the windows vertically with the active window at the
Tile Vertical
left.
Table 9.7: Window menu elements
Command Description
Shows the J-Link User’s Guide in a PDF viewer such as
J-Link User’s Guide
Adobe Reader.
About... J-Flash SPI and company information.
Table 9.8: Help menu elements
9.4 Settings
The following chapter provides an overview of the program settings. Both general
and per project settings are considered.
9.4.1.1.1 USB
If this option is checked, J-Flash SPI will connect to J-Link over the USB port. You
may change the device number if you want to connect more than one J-Link to your
PC. The default device number is 0. For more information about how to use multiple
J-Links on one PC, please see also the chapter "Working with J-Link" of the J-Link
User’s Guide.
9.4.1.1.2 TCP/IP
If this option is selected, J-Flash SPI will connect to J-Link via J-Link TCP/IP Server.
You have to specify the hostname of the remote system running the J-Link TCP/IP
Server.
9.4.1.2 Interface
This dialog is used to configure the SPI interface settings like SPI communication
speed etc.
9.4.2.1 Operation
You may define the behavior of some operations such as "Auto" or "Program & Ver-
ify".
9.4.2.2 Logging
You may set some logging options to customize the log output of J-Flash SPI.
9.5.1 Overview
In addition to its traditional Windows graphical user interface (GUI), J-Flash SPI sup-
ports a command line mode as well. This makes it possible to use J-Flash SPI for
batch processing purposes. All important options accessible from the menus are
available in command line mode as well. If you provide command line options, J-
Flash SPI will still start its GUI, but processing will start immediately.
The screenshot below shows the command line help dialog, which is displayed if you
start J-Flash SPI in a console window with JFlashSPI.exe -help or JFlashSPI.exe
-?
The command line options are evaluated in the order they are passed to J-Flash, so
please ensure that a project and data file has already been opened when evaluating a
command line option which requires this.
It is recommended to always use -open<FILENAME>[,<SADDR>] to make sure the
right data file is opened.
All command line options return 0 if the processing was successful. A return value
unequal 0 means that an error occured.
Option Description
-? Displays help dialog.
-auto Erases, program and verify target.
-connect Connects to target.
-delrange<SADDR>,<EADDR> Deletes data in the given range.
-disconnect Disconnects from target.
-eliminate Eliminates blank areas in data file.
-erasechip Erases the entire flash chip.
-erasesectors Erases all sectors.
-exit Exits application.
-help Displays help dialog.
Merges a given file with the one currently
opened.
Note that when passing a .bin file via this com-
-merge<FILENAME>
mand, also the start-address where it shall be
-merge<FILENAME>.bin,<ADDR>
merged the file currently openend in J-Flash
SPI must be given, too, since .bin files do not
contain any address information.
Open a data file. Please note that the
-open<FILENAME>[,<SADDR>] <SADDR> parameter applies only if the data
file is a *.bin file.
Open an existing project file. This will also
-openprj<FILENAME> automatically open the data file that has been
recently used with this project.
-program Program target.
-programverify Program and verify target.
-readchip Read entire flash chip.
-readrange<SADDR>,<EADDR> Read specified range of target memory.
Save the current data file. Please note that the
-save[<SADDR>,<EADDR>] parameters <SADDR>,<EADDR> apply only if
the data file is a *.bin file or *.c file.
Save the current data file into the specified
-saveas<FILE- file. Please note that the parameters
NAME>[,<SADDR>,<EADDR>] <SADDR>, <EADDR> apply only if the data file
is a *.bin file or *.c file.
-saveprj Save the current project.
-saveprjas<FILENAME> Save the current project in the specified file.
-verify Verify target memory.
-usb<SN> Overrides connection settings to USB.
-ip<xxx.xxx.xxx.xxx>
Overrides connection settings to IP.
-ip<HostName>
Table 9.9: J-Flash SPI command line options
@ECHO OFF
ECHO Open a project and data file, start auto processing and exit
JFlashSPI.exe -openprjC:\Projects\Default.jflash -openC:\Data\data.bin,0x100000 -
auto -exit
IF ERRORLEVEL 1 goto ERROR
goto END
:ERROR
ECHO J-Flash SPI: Error!
pause
:END
Note that every call of JFlashSPI.exe has to be completed with the -exit option,
otherwise the execution of the batch file stops and the following commands will not
be processed.
@ECHO OFF
ECHO Open first project which is configured to connect to the first J-Link. Open data
file, start auto processing and exit
open JFlashSPI.exe -openprjC:\Projects\Project01.jflash -openC:\Data\data.bin,
0x100000 -auto -exit
IF ERRORLEVEL 1 goto ERROR
ECHO Open second project which is configured to connect to the second J-Link. Open
data file, start auto processing and exit
open JFlashSPI.exe -openprjC:\Projects\Project02.jflash -openC:\Data\data.bin,
0x100000 -auto -exit
IF ERRORLEVEL 1 goto ERROR
ECHO Open third project which is configured to connect to the third J-Link. Open data
file, start auto processing and exit
open JFlashSPI.exe -openprjC:\Projects\Project03.jflash -openC:\Data\data.bin,
0x100000 -auto -exit
IF ERRORLEVEL 1 goto ERROR
goto END
:ERROR
ECHO J-Flash SPI: Error!
pause
:END
Note that every call of JFlashSPI.exe has to completed with the -exit option, oth-
erwise stops the execution of the batch file and the following commands will not be
processed.
3. Define the SPI communication speed. The default settings work without any
problem for most targets, but to achieve the last quantum of performance, man-
ual tuning may be necessary.
4. Open the Flash and either select Automatically detect SPI flash or manually
enter the flash parameters.
5. Save the project (File -> Save Project) and test it.
9.9 Performance
The following chapter lists programming performance for various SPI flash devices.
9.11 Support
The following chapter provides advises on troubleshooting for possible typical
problems and information about how to contact our support.
9.11.1 Troubleshooting
9.11.1.1 Typical problems
Target system has no power
Meaning:
J-Link could not measure the target (flash) reference voltage on pin 1 of its connec-
tor.
Remedy:
The target interface of J-Link works with level shifters to be as flexible as possible.
Therefore, the reference I/O voltage the flash is working with also needs to be con-
nected to pin 1 of the J-Link connector.
Programming / Erasing failed
Meaning:
The SPI communication speed may be too high for the given signal quality.
Remedy:
Try again with a slower speed. If it still fails, check the quality of the SPI signals.
Failed to verify Flash ID
Meaning:
J-Link could not verify the ID of the connected flash.
Remedy:
Check the Flash ID entered in the flash parameters dialog, for correctness.
Chapter 10
RDI
10.1 Introduction
Remote Debug Interface (RDI) is an Application Programming Interface (API) that
defines a standard set of data structures and functions that abstract hardware for
debugging purposes. 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.
Host (PC)
elf.gif
USB
J-Link
JTAG
ARM
10.1.1 Features
• Can be used with every RDI compliant debugger.
• Easy to use.
• Flash download feature of J-Link DLL can be used.
• Flash breakpoints feature of J-Link DLL can be used.
• Instruction set simulation (improves debugging performance).
10.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. For more information about licensing itself and which
devices have a device-based license, please refer to Licensing on page 65.
2. Choose Project | Options and select the Debugger category. Change the
3. Go to the RDI page of the Debugger options, select the manufacturer driver
( JLinkRDI.dll ) and click OK .
4. Now an extra menu, RDI, has been added to the menu bar.
Choose RDI | Configure to configure the J-Link. For more information about the
generic setup of J-Link RDI, please refer to Configuration on page 314.
Register
Assigned register
Index
0 R0
1 R1
2 R2
3 R3
4 R4
5 R5
6 R6
7 R7
8 R8
9 R9
10 R10
11 R11
12 R12
13 MSP / PSP (depending on mode)
14 R14 (LR)
16 R15 (PC)
17 XPSR
18 APSR
19 IPSR
20 EPSR
21 IAPSR
22 EAPSR
23 IEPSR
24 PRIMASK
25 FAULTMASK
26 BASEPRI
27 BASEPRI_MAX
28 CFBP (CONTROL/FAULT/BASEPRI/PRIMASK)
Table 10.1: Cortex-M register mapping for IAR + J-Link RDI
4. Select J-Link and press OK to connect to the target via J-Link. For more informa-
tion about the generic setup of J-Link RDI, please refer to Configuration on
page 314. After downloading an image to the target board, the debugger window
looks as follows:
3. In the Connection Control dialog use the right mouse click on the first item and
select Add/Remove/Edit Devices .
4. Now select Add DLL to add the JLinkRDI.dll . Select the installation path of the
software, for example:
C:\Program Files\SEGGER\JLinkARM_V350g\JLinkRDI.dll
5. After adding the DLL, an additional Dialog opens and asks for description: (These
values are voluntary, if you do not want change them, just click OK ) Use the fol-
lowing values and click on 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 Configu-
ration on page 314.
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. Close the Connection Control Window.
10. A project or an image is needed for debugging. After downloading, J-Link is used
to debug the target.
3. The Create a new Connection Method will be opened. Enter a name for your
configuration in the Name field and select Custom in the Type list. Confirm your
choice with the Create... button.
4. The Connection Editor dialog will be opened. Enter rdiserv in the Server field
and enter the following values in the Arguments field:
-config -dll <FullPathToJLinkDLLs>
Note that JLinkRDI.dll and JLinkARM.dll must be stored in the same directory.
If the standard J-Link installation path or another path that includes spaces has
been used, enclose the path in quotation marks.
Example:
-config -dll "C:\Program Files\SEGGER\JLinkARM_V350g\JLinkRDI.dll"
Refer to GHS manual "MULTI: Configuring Connections for ARM Targets", chapter
"ARM Remote Debug Interface (rdiserv) Connections" for a complete list of pos-
sible arguments.
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 314.
7. Click the OK button to connect to the target. Build the project and start the
debugger. Note that at least one action (for example step or run ) has to be per-
formed in order to initiate the download of the application.
Select Project | Options for Target ’<NameOfTarget>’ to open the project options
dialog and select the Debug tab.
Choose RDI Interface Driver from the list as shown above and click the Settings
button. Select the location of JLinkRDI.dll in Browse for RDI Driver DLL field.
and click the Configure RDI Driver button.
The J-Link RDI Configuration dialog will be opened.For more information about the
generic setup of J-Link RDI, please refer to Configuration on page 314.
After finishing configuration, the project can be built ( Project | Build Target) and
the debugger can be started ( Debug | Start/Stop debug session ).
10.4 Configuration
This section describes the generic setup of J-Link RDI (same for all debuggers) using
the J-Link RDI configuration dialog.
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.
License (J-Link RDI License managment)
1. The License button opens the J-Link RDI License management dialog. J-Link
RDI requires a valid license.
2. Click the Add license button and enter your license. Confirm your input by click-
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.
Command Description
SetJTAGSpeed(x); Sets the JTAG speed, x = speed in kHz (0=Auto)
Waits a given time,
Delay(x);
x = delay in milliseconds
Resets the target,
Reset(x);
x = delay in milliseconds
Go(); Starts the ARM core
Halt(); Halts the ARM core
Read8(Addr);
Reads a 8/16/32 bit value,
Read16(Addr);
Addr = address to read (as hex value)
Read32(Addr);
Verify8(Addr, Data); Verifies a 8/16/32 bit value,
Verify16(Addr, Data); Addr = address to verify (as hex value)
Verify32(Addr, Data); Data = data to verify (as hex value)
Write8(Addr, Data); Writes a 8/16/32 bit value,
Write16(Addr, Data); Addr = address to write (as hex value)
Write32(Addr, Data); Data = data to write (as hex value)
WriteVerify8(Addr, Data); Writes and verifies a 8/16/32 bit value,
WriteVerify16(Addr, Data); Addr = address to write (as hex value)
WriteVerify32(Addr, Data); Data = data to write (as hex value)
WriteRegister(Reg, Data); Writes a register
WriteJTAG_IR(Cmd); Writes the JTAG instruction register
WriteJTAG_DR(nBits, Data); Writes the JTAG data register
Table 10.2: Macro file commands
JTAG speed
This allows the selection of the JTAG speed. There are basically three types of speed
settings (which are explained below):
• Fixed JTAG speed
• Automatic JTAG speed
• Adaptive clocking
For more information about the different speed settings supported by J-Link, please
refer to JTAG Speed on page 192.
JTAG scan chain with multiple devices
The JTAG scan chain allows to specify the instruction register organization of the tar-
get system. This may be needed if there are more devices located on the target sys-
tem than the ARM chip you want to access or if more than one target system is
connected to one J-Link at once.
10.5 Semihosting
Semihosting is a mechanism for ARM targets to communicate input/output requests
from application code to a host computer running a debugger.
It effectively allows the target to do disk operations and console I/O and is used pri-
marily for flash loaders with ARM debuggers such as AXD.
10.5.1 Overview
Semihosting
Semihosting is a mechanism for ARM targets to communicate input/output requests
from application code to a host computer running a debugger. This mechanism is
used to allow functions in the C library, such as printf() and scanf() , to use the
screen and keyboard of the host rather than having a screen and keyboard on the
target system.
This is useful because development hardware often does not have all the input and
output facilities of the final system. Semihosting allows the host computer to provide
these facilities.
Semihosting is also used for Disk I/O and flash programming; a flash loader uses
semihosting to load the target program from disk.
Semihosting is implemented by a set of defined software interrupt (SWI) operations.
The application invokes the appropriate SWI and the debug agent then handles the
SWI exception. The debug agent provides the required communication with the host.
In many cases, the semihosting SWI will be invoked by code within library functions.
Usage of semihosting
The application can also invoke the semihosting SWI directly. Refer to the C library
descriptions in the ADS Compilers and Libraries Guide for more information on sup-
port for semihosting in the ARM C library.
Semihosting is not used by all tool chains; most modern tool chains (such as IAR)
use different mechanisms to achive the same goal.
Semihosting is used primarily by ARM’s tool chain and debuggers, such as AXD.
Since semihosting has been used primarily by ARM, documents published by ARM are
the best source of add. information.
For further information on semihosting and the C libraries, see the "C and C++
Libraries" chapter in ADS Compilers and Libraries Guide. Please see also the "Writing
Code for ROM" chapter in ADS Developer Guide.
Chapter 11
RTT
SEGGER’s Real Time Terminal (RTT) is a technology for interactive user I/O in embed-
ded applications. It combines the advantages of SWO and semihosting at very high
performance.
11.1 Introduction
With RTT it is possible to output information from the target microcontroller as well
as sending input to the application at a very high speed without affecting the target's
real time behavior.
SEGGER RTT can be used with any J-Link model and any supported target processor
which allows background memory access, which are Cortex-M and RX targets.
RTT supports multiple channels in both directions, up to the host and down to the
target, which can be used for different purposes and provide the most possible free-
dom to the user.
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. An additional up (to host) channel can for example be used to send
profiling or event tracing data.
When Read and Write Pointers point to the same element, the buffer is empty. This
assures there is never a race condition. The image shows the simplified structure in
the target.
11.2.4 Requirements
SEGGER RTT does not need any additional pin or hardware, despite a J-Link con-
nected via the standard debug port to the target. It does not require any configura-
tion of the target or in the debugging environment and can even be used with varying
target speeds.
RTT can be used in parallel to a running debug session, without intrusion, as well as
without any IDE or debugger at all.
11.2.5 Performance
The performance of SEGGER RTT is significantly higher than any other technology
used to output data to a host PC. An average line of text can be output in one micro-
second or less. Basically only the time to do a single memcopy().
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.
• Sending text input to Channel 0.
• Interpreting text control codes for colored text and controling the Terminal.
• Logging data on Channel 1.
All Terminals
The All Terminals tab displays the complete output of RTT Channel 0 and can display
the user input (Check Input -> Echo input... -> Echo to "All Terminals").
Each output line is prefixed by the Terminal it has been sent to. Additionally, output
on Terminal 1 is shown in red, output on Terminals 2 - 15 in grey.
Terminal 0 - 15
Each tab Terminal 0 - Terminal 15 displays the output which has been sent to this
Terminal. The Terminal tabs interpret and display Text Control Codes as sent by the
application to show colored text or erase the screen.
By default, if the RTT application does not set a Terminal Id, the output is displayed
in Terminal 0.
The Teminal 0 tab can additionally display the user input. (Check Input -> Echo
input... -> Echo to "Terminal 0")
Each Terminal tab can be shown or hidden via the menu Terminals -> Terminals... or
their respective shortcuts as described below.
File
Terminals
Alt-0 -
--> Terminal 0 - 9 Opens or closes the Terminal Tab.
Alt-9
-> Stop logging Stops loggind data and close the file. Shift-F5
Help
-> J-Link Manual... Opens the J-Link Manual PDF file. F11
-> RTT Webpage... Opens the RTT webpage. F10
Right-Click on Tab
Example 2:
SEGGER_RTT_printf(0, "%sTime:%s%s %.7d\n",
RTT_CTRL_RESET,
RTT_CTRL_BG_BRIGHT_RED,
RTT_CTRL_TEXT_BRIGHT_WHITE,
1111111
);
//
// Clear the terminal.
// The first line will not be shown after this command.
//
SEGGER_RTT_WriteString(0, RTT_CTRL_CLEAR);
11.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. Using RTT reduces the time taken for
output to a minimum and allows printing debug information to the host computer
while the application is performing time critical real time tasks.
The implementation code also includes a simple version of printf() which can be used
to write formatted strings via RTT. It is smaller than most standard library printf()
implementations and does not require heap and only a configureable ammount of
stack.
The SEGGER RTT implementation is fully configureable at compile time with pre-pro-
cessor defines. The number of channels, the size of the default channels can be set.
Reading and writing can be made task-safe with definable Lock() and Unlock() rou-
tines.
11.4.1.1 SEGGER_RTT_ConfigDownBuffer()
Description
Configure or add a down buffer by specifying its name, size and flags.
Prototype
int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName,
char* pBuffer, int BufferSize, int Flags);
Parameters
Parameter Meaning
Index of the buffer to configure. Must be lower than
BufferIndex
SEGGER_RTT_MAX_NUM_DOWN_CHANNELS.
Pointer to a 0-terminated string to be displayed as the name of the
sName
channel.
pBuffer Pointer to a buffer used by the channel.
BufferSize Size of the buffer in Bytes.
Flags Flags of the channel (blocking or non-blocking).
Table 11.2: SEGGER_RTT_ConfigDownBuffer() parameter list
Return value
>= 0 O.K.
< 0 Error.
Example
//
// Configure down channel 1
//
SEGGER_RTT_ConfigDownChannel(1, "DataIn", &abDataIn[0], sizeof(abDataIn),
SEGGER_RTT_MODE_NO_BLOCK_SKIP);
Additional information
Once a channel is configured only the flags of the channel should be changed.
11.4.1.2 SEGGER_RTT_ConfigUpBuffer()
Description
Configure or add an up buffer by specifying its name, size and flags.
Prototype
int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName,
char* pBuffer, int BufferSize, int Flags);
Parameters
Parameter Meaning
Index of the buffer to configure. Must be lower than
BufferIndex
SEGGER_RTT_MAX_NUM_UP_CHANNELS.
Pointer to a 0-terminated string to be displayed as the name of the
sName
channel.
pBuffer Pointer to a buffer used by the channel.
BufferSize Size of the buffer in Bytes.
Flags Flags of the channel (blocking or non-blocking).
Table 11.3: SEGGER_RTT_ConfigUpBuffer() parameter list
Return value
>= 0 O.K.
< 0 Error.
Example
//
// Configure up channel 1 to work in blocking mode
//
SEGGER_RTT_ConfigUpChannel(1, "DataOut", &abDataOut[0], sizeof(abDataOut),
SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
Additional information
Once a channel is configured only the flags of the channel should be changed.
11.4.1.3 SEGGER_RTT_GetKey()
Description
Reads one character from SEGGER RTT buffer 0. Host has previously stored data
there.
Prototype
int SEGGER_RTT_GetKey (void);
Return value
Example
int c;
c = SEGGER_RTT_GetKey();
if (c == ’q’) {
exit();
}
11.4.1.4 SEGGER_RTT_HasKey()
Description
Checks if at least one character for reading is available in SEGGER RTT buffer. 0
Prototype
int SEGGER_RTT_HasKey (void);
Return value
Example
if (SEGGER_RTT_HasKey()) {
int c = SEGGER_RTT_GetKey();
}
11.4.1.5 SEGGER_RTT_Init()
Description
Initializes the RTT Control Block.
Prototype
void SEGGER_RTT_Init (void);
Additional information
Should be used in RAM targets, at start of the application.
11.4.1.6 SEGGER_RTT_printf()
Description
Send a formatted string to the host.
Prototype
int SEGGER_RTT_printf (unsigned BufferIndex, const char * sFormat, ...)
Parameters
Parameter Meaning
BufferIndex Index of the up channel to sent the string to.
sFormat Pointer to format string, followed by arguments for conversion.
Table 11.4: SEGGER_RTT_printf() parameter list
Return value
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
11.4.1.7 SEGGER_RTT_Read()
Description
Read characters from any RTT down channel which have been previously stored by
the host.
Prototype
int SEGGER_RTT_Read (unsigned BufferIndex, char* pBuffer, unsigned
BufferSize);
Parameters
Parameter Meaning
BufferIndex Index of the down channel to read from.
pBuffer Pointer to a character buffer to store the read characters.
BufferSize Number of bytes available in the buffer.
Table 11.5: SEGGER_RTT_Read() parameter list
Return value
Example
char acIn[4];
int NumBytes = sizeof(acIn);
NumBytes = SEGGER_RTT_Read(0, &acIn[0], NumBytes);
if (NumBytes) {
AnalyzeInput(acIn);
}
11.4.1.8 SEGGER_RTT_SetTerminal()
Description
Set the "virtual" terminal to send following data on channel 0.
Prototype
void SEGGER_RTT_SetTerminal(char TerminalId);
Parameters
Parameter Meaning
TerminalId Id of the virtual terminal (0-9).
Table 11.6: SEGGER_RTT_SetTerminal() parameter list
Example
//
// Send a string to terminal 1 which is used as error out.
//
SEGGER_RTT_SetTerminal(1); // Select terminal 1
SEGGER_RTT_WriteString(0, "ERROR: Buffer overflow");
SEGGER_RTT_SetTerminal(0); // Reset to standard terminal
Additional information
All following data which is sent via channel 0 will be printed on the set terminal until
the next change.
11.4.1.9 SEGGER_RTT_TerminalOut()
Description
Send one string to a specific "virtual" terminal.
Prototype
int SEGGER_RTT_TerminalOut (char TerminalID, const char* s);
Parameters
Parameter Meaning
TerminalId Id of the virtual terminal (0-9).
s Pointer to 0-terminated string to be sent.
Table 11.7: SEGGER_RTT_TerminalOut() parameter list
Return value
Example
//
// Sent a string to terminal 1 without changing the standard terminal.
//
SEGGER_RTT_TerminalOut(1, "ERROR: Buffer overflow.");
Additional information
SEGGER_RTT_TerminalOut does not affect following data which is sent via channel 0.
11.4.1.10SEGGER_RTT_Write()
Description
Send data to the host on an RTT channel.
Prototype
int SEGGER_RTT_Write (unsigned BufferIndex, const char* pBuffer, unsigned
NumBytes);
Parameters
Parameter Meaning
BufferIndex Index of the up channel to send data to.
pBuffer Pointer to data to be sent.
NumBytes Number of bytes to send.
Table 11.8: SEGGER_RTT_Write() parameter list
Return value
Additional information
With SEGGER_RTT_Write() all kinds of data, not only printable one can be sent.
11.4.1.11SEGGER_RTT_WaitKey()
Description
Waits until at least one character is avaible in SEGGER RTT buffer 0. Once a character
is available, it is read and returned.
Prototype
int SEGGER_RTT_WaitKey (void);
Return value
Example
int c = 0;
do {
c = SEGGER_RTT_WaitKey();
} while (c != ’c’);
11.4.1.12SEGGER_RTT_WriteString()
Description
Write a 0-terminated string to an up channel via RTT.
Prototype
int SEGGER_RTT_WriteSting (unsigned BufferIndex, const char* s);
Parameters
Parameter Meaning
BufferIndex Index of the up channel to send string to.
s Pointer to 0-terminated string to be sent.
Table 11.9: SEGGER_RTT_WriteString() parameter list
Return value
Example
SEGGER_RTT_WriteString(0, "Hello World from your target.\n");
SEGGER_RTT_NO_BLOCK_SKIP
SEGGER_RTT_NO_BLOCK_TRIM
• BRIGHT_GREEN
• BRIGHT_YELLOW
• BRIGHT_BLUE
• BRIGHT_MAGENTA
• BRIGHT_CYAN
• BRIGHT_WHITE
RTT_CTRL_BG_*
Set the background color to one of the following colors.
• BLACK
• RED
• GREEN
• YELLOW
• BLUE
• MAGENTA
• CYAN
• WHITE (light grey)
• BRIGHT_BLACK (dark grey)
• BRIGHT_RED
• BRIGHT_GREEN
• BRIGHT_YELLOW
• BRIGHT_BLUE
• BRIGHT_MAGENTA
• BRIGHT_CYAN
• BRIGHT_WHITE
----------------------------------------------------------------------
File : RTT.c
Purpose : Simple implementation for output via RTT.
It can be used with any IDE.
-------- END-OF-HEADER ---------------------------------------------
*/
#include "SEGGER_RTT.h"
int main(void) {
int Cnt = 0;
11.6 FAQ
Q: How does J-Link find the RTT buffer?
A: There are two ways: If the debugger (IDE) knows the address of the SEGGER RTT
Control Block, it can pass it to J-Link. This is for example done by J-Link Debugger.
If another application that is not SEGGER RTT aware is used, then J-Link searches
for the ID in the known target RAM during execution of the application in the back-
ground. This process normally takes just fractions of a second and does not delay
program execution.
Q: I am debugging a RAM-only application. J-Link finds an RTT buffer, but I get no
output. What can I do?
A: In case the init section of an application is stored in RAM, J-Link migh falsely iden-
tify the block in the init section instead of the actual one in the data section.
To prevent this, set the define SEGGER_RTT_IN_RAM to 1. Now J-Link will find the
correct RTT buffer, but only after calling the first SEGGER_RTT function in the
application. A call to SEGGER_RTT_Init() at the beginning of the application is rec-
ommended.
Q: Can this also be used on targets that do not have the SWO pin?
A: Yes, the debug interface is used. This can be JTAG or SWD (2pins only!) on most
Cortex-M devices, or even the FINE interface on some Renesas devices, just like
the Infineon SPD interface (single pin!).
Q: Can this also be used on Cortex-M0 and M0+?
A: Yes.
Q: Some terminal output (printf) Solutions "crash" program execution when executed
outside of the debug environment, because they use a Software breakpoint that
triggers a hardfault without debugger or halt because SWO is not initialized. That
makes it impossible to run a Debug-build in stand-alone mode.
What about SEGGER-RTT?
A: SEGGER-RTT uses non-blocking mode per default, which means it does not halt
program execution if no debugger is present and J-Link is not even connected. The
application program will continue to work.
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:
• Set ranges to be searched for RTT buffer: SetRTTSearchRanges <RangeStart
[Hex]> <RangeSize >[, <Range1Start [Hex]> <Range1Size>, ...] (e.g. "SetRTT-
SearchRanges 0x10000000 0x1000, 0x2000000 0x1000")
• Set address of the RTT buffer: SetRTTAddr <RTTBufferAddress [Hex]> (e.g. "Set-
RTTAddr 0x20000000")
• Set address of the RTT buffer via J-Link Control Panel -> RTTerminal
Note: J-Link exec commands can be executed in most applications, for example
in J-Link Commander via "exec <Command>", in J-Link GDB Server via "monitor
exec <Command>" or in IAR EW via "__jlinkExecCommand("<Command>");" from a
macro file.
Chapter 12
Device specifics
This chapter describes for which devices some special handling is necessary to use
them with J-Link.
12.1.1 ADuC7xxx
12.1.1.1 Software reset
A special reset strategy has been implemented for Analog Devices ADuC7xxx MCUs.
This special reset strategy is a software reset. "Software reset" means basically
RESET pin is used to perform the reset, the reset is initiated by writing special func-
tion registers via software.
The software reset for Analog Devices ADuC7xxxx executes the following sequence:
• The CPU is halted
• A software reset sequence is downloaded to RAM.
• A breakpoint at address 0 is set
• The software reset sequence is executed.
It is recommended to use this reset strategy. This sequence performs a reset of CPU
and peripherals and halts the CPU before executing instructions of the user program.
It is the recommended reset sequence for Analog Devices ADuC7xxx MCUs and works
with these devices only.
This information is applicable to the following devices:
• Analog ADuC7020x62
• Analog ADuC7021x32
• Analog ADuC7021x62
• Analog ADuC7022x32
• Analog ADuC7022x62
• Analog ADuC7024x62
• Analog ADuC7025x32
• Analog ADuC7025x62
• Analog ADuC7026x62
• Analog ADuC7027x62
• Analog ADuC7030
• Analog ADuC7031
• Analog ADuC7032
• Analog ADuC7033
• Analog ADuC7128
• Analog ADuC7129
• Analog ADuC7229x126
12.2 ATMEL
J-Link has been tested with the following ATMEL devices:
• AT91SAM3A2C
• AT91SAM3A4C
• AT91SAM3A8C
• AT91SAM3N1A
• AT91SAM3N1B
• AT91SAM3N1C
• AT91SAM3N2A
• AT91SAM3N2B
• AT91SAM3N2C
• AT91SAM3N4A
• AT91SAM3N4B
• AT91SAM3N4C
• AT91SAM3S1A
• AT91SAM3S1B
• AT91SAM3S1C
• AT91SAM3S2A
• AT91SAM3S2B
• AT91SAM3S2C
• AT91SAM3S4A
• AT91SAM3S4B
• AT91SAM3S4C
• AT91SAM3U1C
• AT91SAM3U2C
• AT91SAM3U4C
• AT91SAM3U1E
• AT91SAM3U2E
• AT91SAM3U4E
• AT91SAM3X2C
• AT91SAM3X2E
• AT91SAM3X2G
• AT91SAM3X2H
• AT91SAM3X4C
• AT91SAM3X4E
• AT91SAM3X4G
• AT91SAM3X4H
• AT91SAM3X8C
• AT91SAM3X8E
• AT91SAM3X8G
• AT91SAM3X8H
• AT91SAM7A3
• AT91SAM7L64
• AT91SAM7L128
• AT91SAM7S16
• AT91SAM7S161
• AT91SAM7S32
• AT91SAM7S321
• AT91SAM7S64
• AT91SAM7S128
• AT91SAM7S256
• AT91SAM7S512
• AT91SAM7SE32
• AT91SAM7SE256
• AT91SAM7SE512
• AT91SAM7X128
• AT91SAM7X256
• AT91SAM7X512
• AT91SAM7XC128
• AT91SAM7XC256
• AT91SAM7XC512
• AT91SAM9XE128
• AT91SAM9XE256
12.2.1 AT91SAM7
12.2.1.1 Reset strategy
The reset pin of the device is per default disabled. This means that the reset strate-
gies which rely on the reset pin (low pulse on reset) do not work per default. For this
reason a special reset strategy has been made available.
It is recommended to use this reset strategy. This special reset strategy resets the
peripherals by writing to the RSTC_CR register. Resetting the peripherals puts all
peripherals in the defined reset state. This includes memory mapping register, which
means that after reset flash is mapped to address 0. It is also possible to achieve the
same effect by writing 0x4 to the RSTC_CR register located at address 0xfffffd00.
This information is applicable to the following devices:
• AT91SAM7S (all devices)
• AT91SAM7SE (all devices)
• AT91SAM7X (all devices)
• AT91SAM7XC (all devices)
• AT91SAM7A (all devices)
Samples
GDB Sample
# connect to the J-Link gdb server
target remote localhost:2331
monitor flash device = AT91SAM7S256
monitor flash download = 1
monitor flash breakpoints = 1
# Set JTAG speed to 30 kHz
monitor endian little
monitor speed 30
# Reset the target
monitor reset 8
monitor sleep 10
# Perform peripheral reset
monitor long 0xFFFFFD00 = 0xA5000004
monitor sleep 10
# Disable watchdog
monitor long 0xFFFFFD44 = 0x00008000
monitor sleep 10
# Initialize PLL
monitor long 0xFFFFFC20 = 0x00000601
monitor sleep 10
monitor long 0xFFFFFC2C = 0x00480a0e
monitor sleep 10
monitor long 0xFFFFFC30 = 0x00000007
monitor sleep 10
monitor long 0xFFFFFF60 = 0x00480100
monitor sleep 100
monitor speed 12000
break main
load
continue
IAR Sample
/*******************************************************************
*
* _Init()
*/
_Init() {
__emulatorSpeed(30000); // Set JTAG speed to 30 kHz
__writeMemory32(0xA5000004,0xFFFFFD00,"Memory"); // Perform peripheral reset
__sleep(20000);
__writeMemory32(0x00008000,0xFFFFFD44,"Memory"); // Disable Watchdog
__sleep(20000);
__writeMemory32(0x00000601,0xFFFFFC20,"Memory"); // PLL
__sleep(20000);
__writeMemory32(0x10191c05,0xFFFFFC2C,"Memory"); // PLL
__sleep(20000);
__writeMemory32(0x00000007,0xFFFFFC30,"Memory"); // PLL
__sleep(20000);
__writeMemory32(0x002f0100,0xFFFFFF60,"Memory"); // Set 1 wait state for
__sleep(20000); // flash (2 cycles)
__emulatorSpeed(12000000); // Use full JTAG speed
}
/*******************************************************************
*
* execUserReset()
*/
execUserReset() {
__message "execUserReset()";
_Init();
}
/*******************************************************************
*
* execUserPreload()
*/
execUserPreload() {
__message "execUserPreload()";
_Init();
}
RDI Sample
SetJTAGSpeed(30); // Set JTAG speed to 30 kHz
Reset(0, 0);
Write32(0xFFFFFD00, 0xA5000004); // Perform peripheral reset
Write32(0xFFFFFD44, 0x00008000); // Disable watchdog
Write32(0xFFFFFC20, 0x00000601); // Set PLL
Delay(200);
Write32(0xFFFFFC2C, 0x00191C05); // Set PLL and divider
Delay(200);
Write32(0xFFFFFC30, 0x00000007); // Select master clock and processor clock
Write32(0xFFFFFF60, 0x00320300); // Set flash wait states
SetJTAGSpeed(12000);
12.2.2 AT91SAM9
12.2.2.1 JTAG settings
We recommend using adaptive clocking.
This information is applicable to the following devices:
• AT91RM9200
• AT91SAM9260
• AT91SAM9261
• AT91SAM9262
• AT91SAM9263
12.3 DSPGroup
J-Link has been tested with the following DSPGroup devices:
• DA56KLF
Currently, there are no specifics for these devices.
12.4 Ember
For more information, please refer to Silicon Labs on page 373.
12.6 Freescale
J-Link has been tested with the following Freescale devices:
• MAC7101
• MAC7106
• MAC7111
• MAC7112
• MAC7116
• MAC7121
• MAC7122
• MAC7126
• MAC7131
• MAC7136
• MAC7141
• MAC7142
• MK10DN512
• MK10DX128
• MK10DX256
• MK20DN512
• MK20DX128
• MK20DX256
• MK30DN512
• MK30DX128
• MK30DX256
• MK40N512
• MK40X128
• MK40X256
• MK50DN512
• MK50DX256
• MK50DN512
• MK50DX256
• MK51DX256
• MK51DN512
• MK51DX256
• MK51DN512
• MK51DN256
• MK51DN512
• MK52DN512
• MK53DN512
• MK53DX256
• MK60N256
• MK60N512
• MK60X256
12.6.1.2 Tracing
The first silicon of the Kinetis devices did not match the data setup and hold times
which are necessary for ETM-Trace. On these devices, a low drive strength should be
configured for the trace clock pin in order to match the timing requirements.
On later silicons, this has been corrected. This bug applies to all devices with mask
0M33Z from the 100MHz series.
The J-Link software and documentation package comes with a sample project for the
Kinetis K40 and K60 devices which is pre-configured for the TWR-40 and TWR-60 eval
boards and ETM / ETB Trace. This sample project can be found at \Sam-
ples\JLink\Projects .
void ConfigureDataFlash(void);
*******************************************************************
*
* ConfigureDataFlash
*
* Notes
* Needs to be located in RAM since it performs flash operations
* which make instruction fetching from flash temporarily not possible.
*/
void ConfigureDataFlash(void) {
unsigned char v;
//
// Read out current configuration first
//
FSTAT = 0x70; // Clear error flags in status register
FCCOB0 = 0x03; // Read resource
FCCOB1 = 0x80; // Read from data flash IFR area with offset 0xFC (0x8000FC)
FCCOB2 = 0x00;
FCCOB3 = 0xFC;
FCCOB8 = 0x00; // Select IFR area to be read
FSTAT = 0x80; // Start command execution
while((FSTAT & 0x80) == 0); // Wait until flash controller has finished
//
12.7 Fujitsu
J-Link has been tested with the following Fujitsu devices:
• MB9AF102N
• MB9AF102R
• MB9AF104N
• MB9AF104R
• MB9BF104N
• MB9BF104R
• MB9BF105N
• MB9BF105R
• MB9BF106N
• MB9BF106R
• MB9BF304N
• MB9BF304R
• MB9BF305N
• MB9BF305R
• MB9BF306N
• MB9BF306R
• MB9BF404N
• MB9BF404R
• MB9BF405N
• MB9BF405R
• MB9BF406N
• MB9BF406R
• MB9BF504N
• MB9BF504R
• MB9BF505N
• MB9BF505R
• MB9BF506N
• MB9BF506R
Currently, there are no specifics for these devices.
12.8 Itron
J-Link has been tested with the following Itron devices:
• TRIFECTA
Currently, there are no specifics for these devices.
12.9 Infineon
J-Link has been tested with the following Infineon devices:
• UMF1110
• UMF1120
• UMF5110
• UMF5120
• XMC1100-T016F00xx
• XMC1100-T038F00xx
• XMC1100-T038F0xxx
• XMC1201-T028F0xxx
• XMC1201-T038F0xxx
• XMC1202-T016X00xx
• XMC1202-T028X00xx
• XMC1202-T038X00xx
• XMC1203-T016X0xxx
• XMC1301-T016F00xx
• XMC1302-T038X0xxx
• XMC4100-128
• XMC4104-128
• XMC4104-64
• XMC4200-256
• XMC4400-256
• XMC4400-512
• XMC4402-256
• XMC4500-1024
• XMC4500-768
• XMC4502
• XMC4504
Currently, there are no specifics for these devices.
12.11 NXP
J-Link has been tested with the following NXP devices:
• LPC1111
• LPC1113
• LPC1311
• LPC1313
• LPC1342
• LPC1343
• LPC1751
• LPC1751
• LPC1752
• LPC1754
• LPC1756
• LPC1758
• LPC1764
• LPC1765
• LPC1766
• LPC1768
• LPC2101
• LPC2102
• LPC2103
• LPC2104
• LPC2105
• LPC2106
• LPC2109
• LPC2114
• LPC2119
• LPC2124
• LPC2129
• LPC2131
• LPC2132
• LPC2134
• LPC2136
• LPC2138
• LPC2141
• LPC2142
• LPC2144
• LPC2146
• LPC2148
• LPC2194
• LPC2212
• LPC2214
• LPC2292
• LPC2294
• LPC2364
• LPC2366
• LPC2368
• LPC2378
• LPC2468
• LPC2478
• LPC2880
• LPC2888
• LPC2917
• LPC2919
• LPC2927
• LPC2929
• PCF87750
• SJA2010
• SJA2510
With these additional commands the values of the fast GPIO registers in the C-SPY
debugger are correct and can be used for debugging. For more information about J-
Link command line options refer to subchapter Command strings on page 227.
12.11.1.2RDI
J-Link comes with a device-based RDI license for NXP LPC21xx-LPC24xx devices. This
means the J-Link RDI software can be used with LPC21xx-LPC24xx devices free of
charge. For more information about device-based licenses, please refer to License
types on page 67.
12.11.4 LPC43xx:
All devices of the LPC43xx are dual core devices (One Cortex-M4 core and one Cor-
tex-M0 core). For these devices, a J-Link script file is needed (exact file depends on if
the Cortex-M4 or the Cortex-M0 shall be debugged) in order to guarantee proper
functionality.
Script file can be found at $JLINK_INST_DIR$\Samples\JLink\Scripts
For more information about how to use J-Link script files, please refer to Executing J-
Link script files on page 225.
12.12 OKI
J-Link has been tested with the following OKI devices:
• ML67Q4002
• ML67Q4003
• ML67Q4050
• ML67Q4051
• ML67Q4060
• ML67Q4061
Currently, there are no specifics for these devices.
12.13 Renesas
J-Link has been tested with the following Renesas devices:
• R5F56104
• R5F56106
• R5F56107
• R5F56108
• R5F56216
• R5F56217
• R5F56218
• R5F562N7
• R5F562N8
• R5F562T6
• R5F562T7
• R5F562TA
Currently, there are no specifics for these devices.
12.14 Samsung
J-Link has been tested with the following Samsung devices:
• S3FN60D
12.14.1 S3FN60D
On the S3FN60D the watchdog may be running after reset (depends on the content
of the smart option bytes at addr. 0xC0). The watchdog keeps counting even if the
CPU is in debug mode (e.g. halted). So, please do not use the watchdog when debug-
ging to avoid unexpected behavior of the target application. A special reset strategy
has been implemented for this device which disables the watchdog right after a reset
has been performed. We recommend to use this reset strategy when debugging a
Samsung S3FN60D device.
12.16 ST Microelectronics
J-Link has been tested with the following ST Microelectronics devices:
• STR710FZ1
• STR710FZ2
• STR711FR0
• STR711FR1
• STR711FR2
• STR712FR0
• STR712FR1
• STR712FR2
• STR715FR0
• STR730FZ1
• STR730FZ2
• STR731FV0
• STR731FV1
• STR731FV2
• STR735FZ1
• STR735FZ2
• STR736FV0
• STR736FV1
• STR736FV2
• STR750FV0
• STR750FV1
• STR750FV2
• STR751FR0
• STR751FR1
• STR751FR2
• STR752FR0
• STR752FR1
• STR752FR2
• STR755FR0
• STR755FR1
• STR755FR2
• STR755FV0
• STR755FV1
• STR755FV2
• STR911FM32
• STR911FM44
• STR911FW32
• STR911FW44
• STR912FM32
• STR912FM44
• STR912FW32
• STR912FW44
• STM32F101C6
• STM32F101C8
• STM32F101R6
• STM32F101R8
• STM32F101RB
• STM32F101V8
• STM32F101VB
• STM32F103C6
• STM32F103C8
• STM32F103R6
• STM32F103R8
• STM32F103RB
• STM32F103V8
• STM32F103VB
12.16.1 STR91x
12.16.1.1JTAG settings
These device are ARM966E-S based. We recommend to use adaptive clocking for
these devices.
12.16.1.2Unlocking
The devices have 3 TAP controllers built-in. When starting J-Link.exe, it reports 3
JTAG devices. A special tool, J-Link STR9 Commander ( JLinkSTR91x.exe) is available
to directly access the flash controller of the device. This tool can be used to erase the
flash of the controller even if a program is in flash which causes the ARM core to
stall. For more information about the J-Link STR9 Commander, please refer to J-Link
STR91x Commander (Command line tool) on page 159.
When starting the STR91x commander, a command sequence will be performed
which brings MCU into Turbo Mode.
"While enabling the Turbo Mode, a dedicated test mode signal is set and controls the
GPIOs in output. The IOs are maintained in this state until a next JTAG instruction is
sent." (ST Microelectronics)
Enabling Turbo Mode is necessary to guarantee proper function of all commands in
the STR91x Commander.
12.16.2 STM32F10xxx
These devices are Cortex-M3 based.
All devices of this family are supported by J-Link.
12.16.2.1ETM init
The following sequence can be used to prepare STM32F10xxx devices for 4-bit ETM
tracing:
int v;
//
// DBGMCU_CR, enable trace I/O and configure pins for 4-bit trace.
//
v = *((volatile int *)(0xE0042004));
v &= ~(7 << 5); // Preserve all bits except the trace pin configuration
v |= (7 << 5); // Enable trace I/O and configure pins for 4-bit trace
*((volatile int *)(0xE0042004)) = v;
0x06000000 which represents the 8 option bytes and their complements. You do not
have to care about the option bytes’ complements since they are computated auto-
matically. The following table describes the structure of the option bytes sector:
Note: Writing a value of 0xFF inside option byte 0 will read-protect the STM32.
In order to keep the device unprotected you have to write the key value 0xA5 into
option byte 0.
Note: The address 0x06000000 is a virtual address only. The option bytes are
originally located at address 0x1FFFF800. The remap from 0x06000000 to
0x1FFFF800 is done automatically by J-Flash.
Example
To program the option bytes 2 and 3 with the values 0xAA and 0xBB, but leave the
device unprotected your option byte sector (at addr 0x06000000) should look like as
follows:
For a detailed description of each option byte, please refer to ST programming man-
ual PM0042, section "Option byte description".
12.16.2.4Hardware watchdog
The hardware watchdog of a STM32F10x device can be enabled by programming the
option bytes. If the hardware watchdog is enabled the device is reset periodically if
the watchdog timer is not refreshed and reaches 0. If the hardware watchdog is
enabled by an application which is located in flash and which does not refresh the
watchdog timer, the device can not be debugged anymore.
//
// Configure both watchdog timers to be halted if the CPU is halted by the debugger
//
*((volatile int *)(0xE0042004)) |= (1 << 8) | (1 << 9);
12.16.3 STM32F2xxx
These devices are Cortex-M3 based.
All devices of this family are supported by J-Link.
12.16.3.1ETM init
The following sequence can be used to prepare STM32F2xxx devices for 4-bit ETM
tracing:
int v;
//
// Enable GPIOE clock
//
*((volatile int *)(0x40023830)) = 0x00000010;
//
// Assign trace pins to alternate function in order
// to make them usable as trace pins
// PE2: Trace clock
// PE3: TRACE_D0
// PE4: TRACE_D1
// PE5: TRACE_D2
// PE6: TRACE_D3
//
*((volatile int *)(0x40021000)) = 0x00002AA0;
//
// DBGMCU_CR, enable trace I/O and configure pins for 4-bit trace.
//
v = *((volatile int *)(0xE0042004));
v &= ~(7 << 5); // Preserve all bits except the trace pin configuration
v |= (7 << 5); // Enable trace I/O and configure pins for 4-bit trace
*((volatile int *)(0xE0042004)) = v;
//
// Configure both watchdog timers to be halted if the CPU is halted by the debugger
//
*((volatile int *)(0xE0042008)) |= (1 << 11) | (1 << 12);
12.16.4 STM32F4xxx
These devices are Cortex-M4 based.
All devices of this family are supported by J-Link.
12.16.4.1ETM init
The following sequence can be used to prepare STM32F4xxx devices for 4-bit ETM
tracing:
int v;
//
// Enable GPIOE clock
//
*((volatile int *)(0x40023830)) = 0x00000010;
//
// Assign trace pins to alternate function in order
// to make them usable as trace pins
// PE2: Trace clock
// PE3: TRACE_D0
// PE4: TRACE_D1
// PE5: TRACE_D2
// PE6: TRACE_D3
//
*((volatile int *)(0x40021000)) = 0x00002AA0;
//
// DBGMCU_CR, enable trace I/O and configure pins for 4-bit trace.
//
v = *((volatile int *)(0xE0042004));
v &= ~(7 << 5); // Preserve all bits except the trace pin configuration
v |= (7 << 5); // Enable trace I/O and configure pins for 4-bit trace
*((volatile int *)(0xE0042004)) = v;
//
// Configure both watchdog timers to be halted if the CPU is halted by the debugger
//
*((volatile int *)(0xE0042008)) |= (1 << 11) | (1 << 12);
12.17.1 AM335x
The AM335x series devices need some special handling which requires the correct
device is selected in the J-Link DLL. When used out of a debugger, this is usually
done automatically (see Software reset on page 350). For J-Link Commander & J-
Link GDBServer this needs to be done manually.
-device <DeviceName>
Example: JLinkGDBServer -device AM3359
device <DeviceName>
Then J-Link Commander will perform a reconnect with the device name selected
before.
12.17.3 OMAP4430
Script is not needed. Refer to AM335x special handling. Same needs to be done for
AM35xx / AM37xx.
12.17.4 OMAP-L138
Needs a J-Link script file to guarantee proper functionality.
J-Link script file can be found at $JLINK_INST_DIR$\Samples\JLink\Scripts.
For more information about how to use J-Link script files, please refer to Executing J-
Link script files on page 225.
12.17.5 TMS470M
Needs a J-Link script file to guarantee proper functionality.
J-Link script file can be found at $JLINK_INST_DIR$\Samples\JLink\Scripts
For more information about how to use J-Link script files, please refer to Executing J-
Link script files on page 225.
12.17.6 OMAP3530
Needs a J-Link script file to guarantee proper functionality.
J-Link script file can be found at $JLINK_INST_DIR$\Samples\JLink\Scripts
For more information about how to use J-Link script files, please refer to Executing J-
Link script files on page 225.
12.17.7 OMAP3550
Needs a J-Link script file to guarantee proper functionality.
J-Link script file can be found at $JLINK_INST_DIR$\Samples\JLink\Scripts
For more information about how to use J-Link script files, please refer to Executing J-
Link script files on page 225.
12.18 Toshiba
J-Link has been tested with the following Toshiba devices:
• TMPM321F10FG
• TMPM322F10FG
• TMPM323F10FG
• TMPM324F10FG
• TMPM330FDFG
• TMPM330FWFG
• TMPM330FYFG
• TMPM332FWUG
• TMPM333FDFG
• TMPM333FWFG
• TMPM333FYFG
• TMPM341FDXBG
• TMPM341FYXBG
• TMPM360F20FG
• TMPM361F10FG
• TMPM362F10FG
• TMPM363F10FG
• TMPM364F10FG
• TMPM366FDFG
• TMPM366FWFG
• TMPM366FYFG
• TMPM370FYDFG
• TMPM370FYFG
• TMPM372FWUG
• TMPM373FWDUG
• TMPM374FWUG
• TMPM380FWDFG
• TMPM380FWFG
• TMPM380FYDFG
• TMPM380FYFG
• TMPM382FSFG
• TMPM382FWFG
• TMPM395FWXBG
Currently, there are no specifics for these devices.
Chapter 13
This chapter gives an overview about J-Link / J-Trace specific hardware details, such
as the pinouts and available adapters.
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.
19** 19 Voltage
5V supply Regulator VCC
1 1
VTref
3* 3 VCC
nTRST nTRST
5 5
TDI TDI
7 7
TMS TMS
J-Link TCK 9 9
TCK CPU
11* 11
RTCK RTCK
13 13
TDO TDO
15 15
RESET nRST
GND
20 20
GND
Command Explanation
power on Switch target power on
power off Switch target power off
power on perm Set target power supply default to "on"
power off perm Set target power supply default to "off"
Table 13.2: Command List
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.
19* 19 Voltage
5V supply Regulator VCC
1 1
VTref
100 k
7 7 VCC
SWDIO SWDIO
9 9
SWCLK SWCLK
J-Link 13 13
CPU
SWO SWO
15 15
RESET nRST
GND
20 20
GND
Command Explanation
power on Switch target power on
power off Switch target power off
power on perm Set target power supply default to "on"
power off perm Set target power supply default to "off"
Table 13.4: Command List
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.
Pins 4, 6, 8, 10, 12 are GND pins connected to GND in J-Link. They should also be
connected to GND in the target system.
38 37
Target
system
2 1 Pin 1
chamfer
JTAG cable
Trace cable
Trace cable
Target board Target board Target board Target board Target board Target board
Trace JTAG Trace ARM JTAG Trace ARM JTAG
ARM
connector connector connector connector connector connector
13.2.2 Pinout
The following table lists the JTAG+Trace connector pinout. It is compatible to the
"Trace Port Physical Interface" described in [ETM], 8.2.2 "Single target connector
pinout".
The diagram below shows the TRACECLK frequencies and the setup and hold timing
of the trace signals with respect to TRACECLK.
Tperiod
Full
TRACECLK Tch Tcl
DATA
Half-rate
TRACECLK
Note: J-Trace supports half-rate clocking mode. Data is output on each edge of
the TRACECLK signal and TRACECLK (max) <= 100MHz. For half-rate clocking, the
setup and hold times at the JTAG+Trace connector must be observed.
Pins 3, 5, 15, 17, 19 are GND pins connected to GND in J-Trace CM3. They should
also be connected to GND in the target system.
Command Explanation
power on Switch target power on
power off Switch target power off
power on perm Set target power supply default to "on"
power off perm Set target power supply default to "off"
Table 13.11: Command List
The following table lists the output of the 9-pin Cortex-M connector.
Pins 3 and 5 are GND pins connected to GND on the Cortex-M adapter. They should
also be connected to GND in the target system.
13.6 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
http://www.segger.com/jlink-adapters.html.
Chapter 14
Background information
This chapter provides background information about JTAG and ARM. The ARM7 and
ARM9 architecture is based on Reduced Instruction Set Computer (RISC) principles.
The instruction set and the related decode mechanism are greatly simplified com-
pared with microprogrammed Complex Instruction Set Computer (CISC).
14.1 JTAG
JTAG is the acronym for Joint Test Action Group. In the scope of this document,
"the JTAG standard" means compliance with IEEE Standard 1149.1-2001.
The test clock input (TCK) provides the clock for the test
TCK Input
logic.
Serial test instructions and data are received by the test
TDI Input
logic at test data input (TDI).
tm s=0
tm s=1 tm s=1
Capture-DR Capture-IR
tm s=0 tm s=0
Shift-DR Shift-IR
Exit1-DR Exit1-IR
tm s=1 tm s=1
tm s=0 tm s=0
Pause-DR Pause-IR
tm s=0 tm s=0
Exit2-DR Exit2-IR
tm s=1 tm s=1
Update-DR Update-IR
Exit1-DR
Temporary controller state.
Pause-DR
The shifting of the test data register between TDI and TDO is temporarily halted.
Exit2-DR
Temporary controller state. Allows to either go back into Shift-DR state or go on to
Update-DR.
Update-DR
Data contained in the currently selected data register is loaded into a latched parallel
output (for registers that have such a latch). The parallel latch prevents changes at
the parallel output of these registers from occurring during the shifting process.
Capture-IR
Instructions may be loaded in parallel into the instruction register.
Shift-IR
The instruction register shifts the values in the instruction register towards TDO with
each clock.
Exit1-IR
Temporary controller state.
Pause-IR
Wait state that temporarily halts the instruction shifting.
Exit2-IR
Temporary controller state. Allows to either go back into Shift-IR state or go on to
Update-IR.
Update-IR
The values contained in the instruction register are loaded into a latched parallel out-
put from the shift-register path. Once latched, this new instruction becomes the cur-
rent one. The parallel latch prevents changes at the parallel output of the instruction
register from occurring during the shifting process.
The result of the limited buffer size is that not more data can be traced than the
buffer can hold. Because of this limitation, an ETB is not a fully- alternative to the
direct access to an ETM via J-Trace.
14.4.4.2 RDI flash loader: Allows flash download from any RDI-compliant
tool chain
RDI (Remote debug interface) is a standard for "debug transfer agents" such as J-
Link. It allows using J-Link from any RDI compliant debugger. RDI by itself does not
include download to flash. To debug in flash, you need to somehow program your
application program (debuggee) into the flash. You can use J-Flash for this purpose,
use the flash loader supplied by the debugger company (if they supply a matching
flash loader) or use the flash loader integrated in the J-Link RDI software. The RDI
software as well as the RDI flash loader require licenses from SEGGER.
In the screenshot:
• The red box identifies the new firmware.
• The green box identifies the old firmware which has been replaced.
In the screenshot, the red box contains information about the formerly used J-Link /
J-Trace firmware version.
Use an application (for example JLink.exe) which uses the desired version of
JLinkARM.dll. This automatically replaces the invalidated firmware with its embedded
firmware.
In the screenshot:
• "Updating firmware" identifies the new firmware.
• "Replacing firmware" identifies the old firmware which has been replaced.
Chapter 15
This chapter describes the hardware requirements which have to be met by the tar-
get board.
Signal Value
Fmax 200MHz
Ts setup time (min.) 2.0ns
Th hold time (min.) 1.0ns
TRACECLK high pulse width (min.) 1.5ns
TRACECLK high pulse width (min.) 1.5ns
Table 15.1: Signal requirements
Chapter 16
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 contacting support. Performing these steps can solve many problems and
often eliminates the need for assistance. This chapter also contains a collection of
frequently asked questions (FAQs) with answers.
16.2 Troubleshooting
16.2.1 General procedure
If you experience problems with J-Link / J-Trace, you should follow the steps below to
solve these problems:
1. Close all running applications on your host system.
2. Disconnect the J-Link / J-Trace device from USB.
3. Disable power supply on the target.
4. Re-connect J-Link / J-Trace with the host system (attach USB cable).
5. Enable power supply on the target.
6. Try your target application again. If the problem remains continue the following
procedure.
7. Close all running applications on your host system again.
8. Disconnect the J-Link / J-Trace device from USB.
9. Disable power supply on the target.
10. Re-connect J-Link / J-Trace with the host system (attach the USB cable).
11. Enable power supply on the target.
12. Start JLink.exe.
13. If JLink.exe displays the J-Link / J-Trace serial number and the target proces-
sor’s core ID, the J-Link / J-Trace is working properly and cannot be the cause of
your problem.
14. If the problem persists and you own an original product (not an OEM version),
see section Contacting support on page 423.
Chapter 17
Glossary
Adaptive clocking
A technique in which a clock signal is sent out by J-Link / J-Trace. J-Link / J-Trace
waits for the returned clock before generating the next clock pulse. The technique
allows the J-Link / J-Trace interface unit to adapt to differing signal drive capabilities
and differing cable lengths.
Application Program Interface
A specification of a set of procedures, functions, data structures, and constants that
are used to interface two or more software components together.
Big-endian
Memory organization where the least significant byte of a word is at a higher address
than the most significant byte. See Little-endian.
Cache cleaning
The process of writing dirty data in a cache to main memory.
Coprocessor
An additional processor that is used for certain operations, for example, for floating-
point math calculations, signal processing, or memory management.
Dirty data
When referring to a processor data cache, data that has been written to the cache
but has not been written to main memory is referred to as dirty data. Only write-back
caches can have dirty data because a write-through cache writes data to the cache
and to main memory simultaneously. See also cache cleaning.
Dynamic Linked Library (DLL)
A collection of programs, any of which can be called when needed by an executing
program. A small program that helps a larger program communicate with a device
such as a printer or keyboard is often packaged as a DLL.
Embedded Trace Macrocell (ETM)
ETM is additional hardware provided by debuggable ARM processors to aid debugging
with trace functionality.
Embedded Trace Buffer (ETB)
ETB is a small, circular on-chip memory area where trace information is stored during
capture.
EmbeddedICE
The additional hardware provided by debuggable ARM processors to aid debugging.
Halfword
A 16-bit unit of information. Contents are taken as being an unsigned integer
unless otherwise stated.
Host
A computer which provides data and other services to another computer. Especially, a
computer providing debugging services to a target being debugged.
ICache
Instruction cache.
ICE Extension Unit
A hardware extension to the EmbeddedICE logic that provides more breakpoint units.
ID
Identifier.
IEEE 1149.1
The IEEE Standard which defines TAP. Commonly (but incorrectly) referred to as
JTAG.
Image
An executable file that has been loaded onto a processor for execution.
In-Circuit Emulator (ICE)
A device enabling access to and modification of the signals of a circuit while that cir-
cuit is operating.
Instruction Register
When referring to a TAP controller, a register that controls the operation of the TAP.
IR
See Instruction Register.
Joint Test Action Group (JTAG)
The name of the standards group which created the IEEE 1149.1 specification.
Little-endian
Memory organization where the least significant byte of a word is at a lower address
than the most significant byte. See also Big-endian.
Memory coherency
A memory is coherent if the value read by a data read or instruction fetch is the
value that was most recently written to that location. Obtaining memory coherency is
difficult when there are multiple possible physical locations that are involved, such as
a system that has main memory, a write buffer, and a cache.
Memory management unit (MMU)
Hardware that controls caches and access permissions to blocks of memory, and
translates virtual to physical addresses.
Memory Protection Unit (MPU)
Hardware that controls access permissions to blocks of memory. Unlike an MMU, an
MPU does not translate virtual addresses to physical addresses.
Multi-ICE
Multi-processor EmbeddedICE interface. ARM registered trademark.
RESET
Abbreviation of System Reset. The electronic signal which causes the target system
other than the TAP controller to be reset. This signal is also known as "nSRST"
"nSYSRST", "nRST", or "nRESET" in some other manuals. See also nTRST.
nTRST
Abbreviation of TAP Reset. The electronic signal that causes the target system TAP
controller to be reset. This signal is known as nICERST in some other manuals. See
also nSRST.
Open collector
A signal that may be actively driven LOW by one or more drivers, and is otherwise
passively pulled HIGH. Also known as a "wired AND" signal.
Processor Core
The part of a microprocessor that reads instructions from memory and executes
them, including the instruction fetch unit, arithmetic and logic unit, and the register
bank. It excludes optional coprocessors, caches, and the memory management unit.
Program Status Register (PSR)
Contains some information about the current program and some information about
the current processor state. Therefore often referred to as Processor Status Register.
Also referred to as Current PSR (CPSR), to emphasize the distinction to the Saved
PSR (SPSR). The SPSR holds the value the PSR had when the current function was
called, and which will be restored when control is returned.
Remapping
Changing the address of physical memory or devices after the application has started
executing. This is typically done to make RAM replace ROM once the initialization has
been done.
Remote Debug Interface (RDI)
RDI is an open ARM standard procedural interface between a debugger and the
debug agent. The widest possible adoption of this standard is encouraged.
RTCK
Returned TCK. The signal which enables Adaptive Clocking.
RTOS
Real Time Operating System.
Scan Chain
A group of one or more registers from one or more TAP controllers connected
between TDI and TDO, through which test data is shifted.
Semihosting
A mechanism whereby the target communicates I/O requests made in the application
code to the host system, rather than attempting to support the I/O itself.
SWI
Software Interrupt. An instruction that causes the processor to call a programer-
specified subroutine. Used by ARM to handle semihosting.
TAP Controller
Logic on a device which allows access to some or all of that device for test purposes.
The circuit functionality is defined in IEEE1149.1.
Target
The actual processor (real silicon or simulated) on which the application program is
running.
TCK
The electronic clock signal which times data on the TAP data lines TMS, TDI, and
TDO.
TDI
The electronic signal input to a TAP controller from the data source (upstream). Usu-
ally, this is seen when connecting the J-Link / J-Trace Interface Unit to the first TAP
controller.
TDO
The electronic signal output from a TAP controller to the data sink (downstream).
Usually, this is seen connecting the last TAP controller to the J-Link / J-Trace Inter-
face Unit.
Test Access Port (TAP)
The port used to access a device's TAP Controller. Comprises TCK, TMS, TDI, TDO,
and nTRST (optional).
Transistor-Transistor logic (TTL)
A type of logic design in which two bipolar transistors drive the logic output to one or
zero. LSI and VLSI logic often used TTL with HIGH logic level approaching +5V and
LOW approaching 0V.
Watchpoint
A location within the image that will be monitored and that will cause execution to
stop when it changes.
Word
A 32-bit unit of information. Contents are taken as being an unsigned integer unless
otherwise stated.
Chapter 18
This chapter lists documents, which we think may be useful to gain deeper under-
standing of technical details.
Index
A J-Link
Adaptive clocking ............................... 426 Adapters ........................................400
Application Program Interface .............. 426 Developer Pack DLL .........................163
Supported chips . 240–241, 256–257, 264
J-Link Commander .............................. 81
B J-Link GDB Server ..............................100
Big-endian ........................................ 426 J-Link RDI .........................................158
J-Link STR9 Commander .....................159
C J-Link TCP/IP Server ...........................133
Cache cleaning .................................. 426 J-Mem Memory Viewer ........................137
Coprocessor ...................................... 426 Joint Test Action Group (JTAG) .............427
JTAG ........................................ 280, 402
TAP controller ..................................403
D JTAGLoad ..........................................157
Dirty data ......................................... 426
Dynamic Linked Library (DLL) .............. 426
L
Little-endian ......................................427
E
Embedded Trace Buffer (ETB) .......409, 426
Embedded Trace Macrocell (ETM) ..405, 426 M
EmbeddedICE ................................... 426 Memory coherency .............................427
Memory management unit (MMU) ........427
Memory Protection Unit (MPU) .............427
G Menu structure ..................................275
General Query Packets ....................... 118 Multi-ICE ..........................................427
H N
Halfword ........................................... 426 nTRST ...................................... 384, 427
Host ................................................. 426
O
I Open collector ...................................427
ICache ............................................. 426
ICE Extension Unit ............................. 426
ID ................................................... 427 P
IEEE 1149.1 ...................................... 427 Processor Core ..................................428
Image .............................................. 427 Program Status Register (PSR) ............428
In-Circuit Emulator ............................ 427
Instruction Register ............................ 427 R
IR .................................................... 427 RDI Support ......................................158
Remapping ........................................428
J Remote Debug Interface (RDI) .............428
J-Flash ARM ...................................... 138 RESET ..............................................427
RTCK ................................................428
S
Scan Chain ....................................... 428
Semihosting ..................................... 428
Server command
clrbp ............................................. 108
cp15 ............................................. 108
DisableChecks ................................ 108
EnableChecks ................................. 109
flash breakpoints ............................ 109
go ................................................. 109
halt ............................................... 110
jtagconf ......................................... 110
memU16 ........................................ 111
memU8 ......................................... 110
reg ............................................... 111
reset ............................................. 112
setBP ..................................... 112–114
sleep ............................................. 115
speed ............................................ 115
step .............................................. 115
waithalt ......................................... 117
wice .............................................. 117
SetDbgPowerDownOnClose ................. 231
SetSysPowerDownOnIdle .................... 232
STRACE ........................................... 119
Support .................................... 419, 425
Supported flash devices 242–243, 249, 258
SWI ................................................. 428
Syntax, conventions used ..................... 13
T
Tabs ................................................ 201
TAP Controller ................................... 428
Target .............................................. 428
TCK .......................................... 384, 428
TCP/IP ............................................. 279
TDI .......................................... 384, 428
TDO ......................................... 384, 429
Test Access Port (TAP) ........................ 429
Transistor-transistor logic (TTL) ........... 429
U
USB ................................................. 279
W
Watchpoint ....................................... 429
Word ............................................... 429