J-Link / J-Trace
User Guide
Document: UM08001
Software Version: 6.44
Revision: 1
Date: March 21, 2019
A product of SEGGER Microcontroller GmbH
www.segger.com
2
Disclaimer
Specifications written in this document are believed to be accurate, but are not guaranteed 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 (SEG-
GER) assumes no responsibility for any errors or omissions. SEGGER makes and you receive no
warranties or conditions, express, implied, statutory or in any communication with you. SEGGER
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 SEGGER. The software described in this document is furnished under a
license and may only be used or copied in accordance with the terms of such a license.
© 2004-2018 SEGGER Microcontroller GmbH, Monheim am Rhein / Germany
Trademarks
Names mentioned in this manual may be trademarks of their respective companies.
Brand and product names are trademarks or registered trademarks of their respective holders.
Contact address
SEGGER Microcontroller GmbH
Ecolab-Allee 5
D-40789 Monheim am Rhein
Germany
Tel. +49-2173-99312-0
Fax. +49-2173-99312-28
E-mail: support@segger.com
Internet: www.segger.com
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
3
Manual versions
This manual describes the current software version. If you find an error in the manual or a
problem in the software, please report it to us and we will try to assist you as soon as possible.
Contact us for further information on topics or functions that are not yet documented.
Print date: March 21, 2019
Manual
version Revision Date By Description
6.44 1 180321 EL Chapter “J-Link software and documentation package”
* Section “J-Link GDB Server”: Command line options corrected.
6.44 0 180306 NV
Chapter “J-Link software and documentation package”
* Section “J-Link Commander”: Added memory zone example for com-
mand “mem”.
6.42 0 180215 NV
Chapter “Working with J-Link and J-Trace”
* Section “J-Link Script Files”: Added new Scripting functions for ETB ini-
tialization.
Chapter “Working with J-Link and J-Trace”
* Section “J-Link Command Strings”: Expanded “map region” documenta-
tion.
6.40 1 181217 SI
Chapter “J-Link software and documentation package”
* Section “ J-Link SWO Viewer: Added description of command line option
”-usb“”.
6.40 0 181120 AG
Chapter “ARM SWD specifics” added
Chapter “ARM SWD specifics”
* Section “SWD multi-drop” added
6.34 10 181025 NV Chapter “J-Link software and documentation package”
* Section “J-Link SWO Viewer”: Updated description and pictures.
6.34 9 181023 NV
Chapter “Working with J-Link and J-Trace”
* Section “J-Link Command Strings”: Added new J-Link command string
“RTTTelnetAllowNonLocalClient”.
6.34 8 101018 AG
Chapter “Target interfaces and adapters”
* Section “19-pin JTAG/SWD and Trace connector”: Added information
about pitch of connector.
6.34 7 180906 SI Chapter “J-Link Commander”
* Section “ Commands: Added description of ”VTREF“.
6.34 6 180905 NV
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Script files“: Added new Script file functions to replace
generic trace module initializations.
6.34 5 180816 LG
Chapter ”J-Link GDB Server“
* Section ”Supported remote (monitor) commands“: Added new monitor
command ”flash erase“.
6.34 4 180704 AG Chapter ”J-Link software and documentation package“
* Section ”J-Flash Lite“ added.
6.34 3 180524 LG
Chapter ”J-Link software and documentation package“
* Section ”J-Link Commander (Command line tool)“: Added new command
line option ”-Log“.
6.34 2 180517 LG
Chapter ”Open Flashloader“
* Section ”XML Tags and Attributes“: Added new <ChipInfo> attribute
”Aliases“.
6.34 1 180516 NV Chapter ”J-Link software and documentation package“
* Section ”J-Link SWO Viewer“: Refined CL option descriptions.
6.34 0 180511 AG
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“: Added new J-Link command string
”SetEnableMemCache“.
Chapter ”Environmental Conditions & Safety“ added
6.32 4 180417 NV
Chapter ”J-Flash SPI“
* Section ”Command Line Interface“: Updated description of CL option -
jflashlog.
* Section ”Command Line Interface“: Updated description of CL option -
jlinklog.
6.32 3 180409 NV Chapter ”Working with J-Link and J-Trace“
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
4
Manual
version Revision Date By Description
* Section ”Script file API functions“: Added new API functions
”JLINK_MEM_Preserve()“, ”JLINK_MEM_Restore()“, ”JLINK_MEM_Fill()“.
6.32 2 180327 LG
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“: Added new J-Link command string
”MemPreserveOnReset“.
6.32 1 180327 AG Moved contents of chapter ”Segger-specific GDB protocol extensions“ to
separate manual (UM08036)
6.32 0 180323 AG
Moved J-Link GDB Server to separate chapter
Added Segger specific GDB protocol extension qSeggerSTRACE:caps
Added Segger specific GDB protocol extension qSeggerSTRACE:GetInstS-
tats
6.30 2 180314 AG
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“: Added new J-Link command string
”SetAllowStopMode“.
6.30 1 180309 NV
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Script Files“:
     Added new function SWO_EnableTarget();.
* Section ”J-Link Script Files“:
     Renamed function GetSWOBaseClock() to SWO_GetSWOBaseClock();
     Added unit information of clock speed value.
6.30 0 180206 EL
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Script Files“:
     Added new function: HandleBeforeFlashProg();
* Section ”J-Link Script Files“:
     Added new function HandleAfterFlashProg();
6.24 1 180124 EL Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Comamnd Strings“: Updated.
6.24 0 180111 LG
Chapter ”J-Link software and documentation package“
* Section ”J-Link GDB Server“: Added new GDBServer monitor commands:
ReadAP, ReadDP, WriteAP and WriteDP.
6.22 0 171214 NV
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“: Added new J-Link Command String
to set base addresses of coresight components for tracing
e.g. CORESIGHT_SetETBBaseAddr.
* Section ”J-Link script files“: Added new function GetSWOBaseClock();.
Chapter ”J-Link software and documentation package“
* Section ”J-Link SWO Viewer“: Updated picture of new SWO Viewer GUI
interface with additional explanation of SWO clock setting.
6.20 8 171123 AG
Chapter ”Related Software“
* Section ”JTAGLoad“: PIO commands was listed as supported even though
it is not. Fixed.
* Section ”JTAGLoad“: PIOMAP commands was listed as supported even
though it is not. Fixed.
6.20 7 171025 EL Chapter ”Monitor Mode Debugging“
* Section ”Enable Monitor Debugging“: Updated
6.20 6 171013 EL
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link script files“: Updated
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“: Updated
6.20 5 171011 NG
Updated links to SEGGER wiki:
     Low power mode debugging
     J-Link script files
     J-Link Command Strings
6.20 4 171011 NG
Chapter ”Working with J-Link and J-Trace“
* Section ”Script file API functions“: Added the following functions:
     JLINK_C2_WriteData()
     JLINK_C2_ReadData()
     JLINK_C2_WriteAddr()
     JLINK_C2_ReadAddr()
     JLINK_CORESIGHT_ReadDAP()
     JLINK_GetPinState()
     JLINK_GetTime()
     JLINK_JTAG_ReadWriteBits()
     JLINK_JTAG_StartDR()
     JLINK_PIN_Override()
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
5
Manual
version Revision Date By Description
     JLINK_SelectTIF()
     JLINK_SetDevice()
     JLINK_SWD_ReadWriteBits()
     JLINK_TARGET_IsHalted()
     JLINK_TARGET_Halt()
     JLINK_TIF_ActivateTargetReset()
     JLINK_TIF_ReleaseTargetReset()
     JLINK_TIF_SetSpeed()
     JLINK_TIF_SetClrTCK()
     JLINK_TIF_SetClrTMS()
     JLINK_TIF_SetClrTDI()
6.20 3 171006 NG
Chapter ”Working with J-Link and J-Trace“
* Section ”Script file API functions“: Added return values for various func-
tions
6.20 2 171005 EL Chapter ”Open Flashloader“
* Section ”Add. Info / Considerations / Limitations“: Updated
6.20 1 170922 NG
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“: Updated
     Added new command string ”EnableLowPowerHandlingMode“
6.16 0 170320 EL Chapter ”Open Flashloader“
     Added ”AlwaysPresent“ as new attribute to the <FlashBankInfo>
6.14 6 170407 NV
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link scriptfiles“: Updated
     ”JLINK_ExecCommand()“ description
6.14 5 170320 EL Chapter ”J-Flash SPI“
     Updated screenshots
6.14 4 170317 NV
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link scriptfiles“:
     Added: ”JLINK_ExecCommand()“
     Section ”Keil MDK-ARM“ added for Command string execution
6.14 3 170220 NV
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link scriptfiles“:
     Added: ”OnTraceStart()“ and ”JLINK_TRACE_Portwidth“
Chapter ”Trace“
* Added crossreference to ”JLINK_TRACE_Portwidth“
6.14 2 170216 NV
Chapter ”Introduction“
*Added Subsubsection ”Software and Hardware
Features Overview“ to all device Subsections.
*Edited Subsection ”“J-Trace ARM.
*Section ”Target interfaces and adapters“:
     edited ”RESET“ to ”nRESET“ and updated description.
6.14 1 170210 NV
Chapter ”Working with J-Link and J-Trace“
* Section ”Exec Commands“: Updated
     SetResetPulseLen
     TraceSampleAdjust
Chapter ”Trace“
* Section ”Tracing via trace pins“: Updated
6.14 0 170201 AG
Chapter ”Working with J-Link“
* Section ”Exec Commands“: Updated
     SelectTraceSource
     SetRAWTRACEPinDelay
     ReadIntoTraceCache
Chapter ”Trace“ added.
6.10a 0 160820 EL Chapter ”Working With J-Link“
* Section ”Exec Commands“: Updated ExcludeFlashCacheRanges.
6.00i 0 160802 EL
Chapter ”Introduction“
* Removed ”Model Feature Lists“
Chapter ”Adding Support for New Devices“:
     renamed to ”Open Flash Loader“
Chapter ”Open Flash Loader“ updated.
6.00 1 160617 EL Chapter ”J-Flash SPI“
* Added chapter ”Custom Command Sequences“
6.00 0 160519 AG Chapter ”Adding Support for New Devices“ added.
5.12f 0 160503 AB Chapter ”Related Software“
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
6
Manual
version Revision Date By Description
* Section ”J-Link RTT Viewer“ updated and moved from section ”RTT“.
5.12d 1 160427 AG Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link script files“ updated.
5.12d 0 160425 AG Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link script files“ updated.
5.12c 0 160413 NG
Chapter ”Related Software“
* Section ”J-Link Commander“
     Typo fixed.
5.12c 1 160418 NG
Chapter ”Related Software“
* Section ”J-Link Commander“
     Commands and commandline options added.
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“
     Command ”SetRTTTelnetPort“ added.
Chapter ”Flash Download“
* Section ”Debugging applications that change flash contents at runtime“
added.
5.10u 0 160317 AG Chapter ”Monitor Mode Debugging“
* Section ”Target application performs reset“ added.
5.10t 0 160314 AG
Chapter ”Monitor Mode Debugging“
* Section ”Enable Monitor Debugging“ updated.
* Section ”Forwarding of Monitor Interrupts“ added.
5.10 3 160309 EL Chapter ”J-Flash SPI“ updated.
5.10 2 160215 AG Chapter ”RTT“ updated.
5.10 1 151204 AG Chapter ”RDI“ updated.
Chapter ”Semihosting“ added.
5.10 0 151127 NG Chapter ”Related Software“
* Section ”J-Scope“ removed.
5.02m 0 151125 AG
Chapter ”Working with J-Link and J-Trace“
* Section ”The J-Link settings file“ added.
Chapter ”Low Power Debugging“ added.
5.02l 0 151123 AG Various Chapters
* Some typos corrected.
5.02i 1 151106 RH Chapter ”J-Flash SPI“
* Section ”Send custom commands“ added.
5.02i 0 151105 RH
Chapter ”Related Software“
* Section ”J-Link Commander“
     exec command added.
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“
     New commands added.
5.02f 1 151022 NG Chapter ”Related Software“
* Section ”J-Scope“ updated.
5.02f 1 151022 EL Chapter ”Target interfaces and adapters“
* Section ”Reference voltage (VTref)“ added.
5.02f 0 151007 RH Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link script files“ updated.
5.02e 0 151001 AG Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link script files“ updated
5.02c 1 150925 NG
Chapter ”Licensing“
* Section ”Original SEGGER products“ updated.
Chapter ”Flash download“
* Section ”Setup for various debuggers (CFI flash)“ updated.
5.02c 0 150916 RH Chapter ”Flash download“
* Section ”Setup for various debuggers (SPIFI flash)“ added.
5.02c 0 150914 RH
Chapter ”Introduction“
* Section ”J-Link / J-Trace models“ updated.
* Section ”Supported OS“
     Added Windows 10
5.02a 0 150903 AG Chapter ”Monitor Mode Debugging“ added.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
7
Manual
version Revision Date By Description
5.02 0 150820 AG
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“
     ”DisableCortexMXPSRAutoCorrectTBit“ added.
5.02 0 150813 AG Chapter ”Monitor Mode Debugging“ added.
5.00 1 150728 NG
Chapter ”Related Software“
* Section ”J-Link Commander“
     Sub-Section ”Command line options“ updated.
5.00 0 150609 AG
Chapter ”Flash download“
* Section ”QSPI flash support“ added.
Chapter ”Flash breakpoints“
* Section ”Flash Breakpoints in QSPI flash“ added
5.00 0 150520 EL Chapter ”J-Flash SPI“
* Initial version added
4.99b 0 150520 EL
Chapter ”Related Software“
* Section ”J-Link STM32 Unlock“
     Added command line options
4.99a 0 150429 AG Chapter ”Target interfaces and Adapters“
Chapter ”20-pin J-Link connector“, section ”Pinout for SPI“ added.
4.98d 0 150427 EL Chapter ”Related Software“
* Section ”Configure SWO output after device reset“ updated.
4.98b 0 150410 AG Chapter ”Licensing“
* Section ”J-Trace for Cortex-M“ updated.
4.98 0 150320 NG
Chapter ”Related Software“
* Section ”J-Link Commander“
     Sub-Section ”Commands“ added.
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link script files“ updated
4.96f 0 150204 JL
Chapter ”Related Software“
* Section ”GDB Server“
     Exit code description added.
4.96 0 141219 JL
Chapter ”RTT“ added.
Chapter ”Related Software“
* Section ”GDB Server“
     Command line option ”-strict“ added.
     Command line option ”-timeout“ added.
4.90d 0 141112 NG
Chapter ”Related Software“
* Section ”J-Link Remote Server“ updated.
* Section ”J-Scope“ updated.
4.90c 0 140924 JL Chapter ”Related Software“
* Section ”JTAGLoad“ updated.
4.90b 1 140813 EL
Chapter ”Working with J-Link and J-Trace“
* Section ”Connecting multiple J-Links / J-Traces to your PC“ updated
Chapter ”J-Link software“
* Section ”J-Link Configurator“ updated.
4.90b 0 140813 NG Chapter ”Related Software“
* Section ”J-Scope“ added.
4.86 2 140606 AG Chapter ”Device specifics“
* Section ”Silicon Labs - EFM32 series devices“ added
4.86 1 140527 JL
Chapter ”Related Software“
* Section ”GDB Server“
Command line options -halt / -nohalt added.
Description for GDB Server CL version added.
4.86 0 140519 AG Chapter ”Flash download“
Section ”Mentor Sourcery CodeBench“ added.
4.84 0 140321 EL
Chapter ”Working with J-Link“
* Section ”Virtual COM Port (VCOM) improved.
Chapter “Target interfaces and adapters”
* Section “Pinout for SWD + Virtual COM Port (VCOM) added.
4.82 1 140228 EL
Chapter “Related Software”
* Section “Command line options”
     Extended command line option -speed.
Chapter “J-Link software and documentation package”
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
8
Manual
version Revision Date By Description
* Section “J-Link STR91x Commander”
     Added command line option parameter to specify a customized
     scan-chain.
Chapter “Working with J-Link”
* Section “Virtual COM Port (VCOM) added.
Chapter ”Setup“
* Section ”Getting started with J-Link and DS-5“
4.82 0 140218 JL
Chapter ”Related Software“
* Section ”GDB Server“
Command line option -notimeout added.
4.80f 0 140204 JL
Chapter ”Related Software“
* Section ”GDB Server“
     Command line options and remote commands added.
4.80 1 131219 JL/
NG
Chapter ”Related Software“
* Section ”GDB Server“
     Remote commands and command line options description improved.
Several corrections.
4.80 0 131105 JL
Chapter ”Related Software“
* Section ”GDB Server“
     SEGGER-specific GDB protocol extensions added.
4.76 3 130823 JL
Chapter ”Flash Download“
* Replaced references to GDB Server manual.
Chapter ”Working with J-Link“
* Replaced references to GDB Server manual.
4.76 2 130821 JL
Chapter ”Related Software“
* Section ”GDB Server“
     Remote commands added.
4.76 1 130819 JL
Chapter ”Related Software“
* Section ”SWO Viewer“
     Sample code updated.
4.76 0 130809 JL
Chapter ”Related Software“
* Sections reordered and updated.
Chapter ”Setup“
* Section ”Using JLinkARM.dll moved here.
4.71b 0 130507 JL
Chapter “Related Software”
* Section “SWO Viewer”
     Added new command line options.
4.66 0 130221 JL
Chapter “Introduction”
* Section “Supported OS”
     Added Linux and Mac OSX
4.62b 0 130219 EL
Chapter “Introduction”
* Section “J-Link / J-Trace models”
     Clock rise and fall times updated.
4.62 0 130129 JL
Chapter “Introduction”
* Section “J-Link / J-Trace models”
     Sub-section “J-link ULTRA” updated.
4.62 0 130124 EL
Chapter “Target interfaces and adapters”
* Section “9-pin JTAG/SWD connector”
     Pinout description corrected.
4.58 1 121206 AG Chapter “Introduction”
* Section “J-Link / J-Trace models” updated.
4.58 0 121126 JL
Chapter “Working with J-Link”
* Section “J-Link script files”
     Sub-section “Executing J-Link script files” updated.
4.56b 0 121112 JL
Chapter “Related Software”
* Section “J-Link SWO Viewer”
     Added sub-section “Configure SWO output after device reset”
4.56a 0 121106 JL
Chapter “Related Software”
* Section “J-Link Commander”
     Renamed “Commander script files” to “Commander files” and
     “script mode” to “batch mode”.
4.56 0 121022 AG Renamed “J-Link TCP/IP Server” to “J-Link Remote Server”
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
9
Manual
version Revision Date By Description
4.54 1 121009 JL Chapter “Related Software”
* Section “TCP/IP Server”, subsection “Tunneling Mode” added.
4.54 0 120913 EL
Chapter “Flash Breakpoints”
* Section “Licensing” updated.
Chapter “Device specifics”
* Section “Freescale”, subsection “Data flash support” added.
4.53c 0 120904 EL Chapter “Licensing”
* Section “Device-based license” updated.
4.51h 0 120717 EL
Chapter “Flash download”
* Section “J-Link commander” updated.
Chapter “Support and FAQs”
* Section “Frequently asked questions” updated.
Chapter “J-Link and J-Trace related software”
* Section “J-Link Commander” updated.
4.51e 1 120704 EL Chapter “Working with J-Link”
* Section “Reset strategies” updated and corrected. Added reset type 8.
4.51e 0 120704 AG Chapter “Device specifics”
* Section “ST” updated and corrected.
4.51b 0 120611 EL Chapter “J-Link and J-Trace related software”
* Section “SWO Viewer” added.
4.51a 0 120606 EL
Chapter “Device specifics”
* Section “ST”, subsection “ETM init” for some STM32 devices added.
* Section “Texas Instruments” updated.
Chapter “Target interfaces and adapters”
* Section “Pinout for SWD” updated.
4.47a 0 120419 AG Chapter “Device specifics”
* Section “Texas Instruments” updated.
4.46 0 120416 EL Chapter “Support” updated.
4.42 0 120214 EL Chapter “Working with J-Link”
* Section “J-Link script files” updated.
4.36 1 110927 EL
Chapter “Flash download” added.
Chapter “Flash breakpoints” added.
Chapter “Target interfaces and adapters”
* Section “20-pin JTAG/SWD connector” updated.
Chapter “RDI” added.
Chapter “Setup” updated.
Chapter “Device specifics” updated.
4.36 0 110909 AG Chapter “Working with J-Link”
* Section “J-Link script files” updated.
4.26 1 110513 KN Chapter “Introduction”
* Section “J-Link / J-Trace models” corrected.
4.26 0 110427 KN Several corrections.
4.24 1 110228 AG
Chapter “Introduction”
* Section “J-Link / J-Trace models” corrected.
Chapter “Device specifics”
* Section “ST Microelectronics” updated.
4.24 0 110216 AG
Chapter “Device specifics”
* Section “Samsung” added.
Chapter “Working with J-Link”
* Section “Reset strategies” updated.
Chapter “Target interfaces and adapters”
* Section “9-pin JTAG/SWD connector” added.
4.23d 0 110202 AG
Chapter “J-Link and J-Trace related software”
* Section “J-Link software and documentation package in detail” updated.
Chapter “Introduction”
* Section “Built-in intelligence for supported CPU-cores” added.
4.21g 0 101130 AG
Chapter “Working with J-Link”
* Section “Reset strategies” updated.
Chapter “Device specifics”
* Section “Freescale” updated.
Chapter “Flash download and flash breakpoints
* Section ”Supported devices“ updated
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
10
Manual
version Revision Date By Description
* Section ”Setup for different debuggers (CFI flash)“ updated.
4.21 0 101025 AG Chapter ”Device specifics“
* Section ”Freescale“ updated.
4.20j 0 101019 AG Chapter ”Working with J-Link“
* Section ”Reset strategies“ updated.
4.20b 0 100923 AG Chapter ”Working with J-Link“
* Section ”Reset strategies“ updated.
0.00 90 100818 AG
Chapter ”Working with J-Link“
* Section ”J-Link script files“ updated.
* Section ”J-Link Command Strings“ updated.
Chapter ”Target interfaces and adapters“
* Section ”19-pin JTAG/SWD and Trace connector“ corrected.
Chapter ”Setup“
* Section ”J-Link Configurator added.“
0.00 89 100630 AG Several corrections.
0.00 88 100622 AG Chapter ”J-Link and J-Trace related software“
* Section ”SWO Analyzer“ added.
0.00 87 100617 AG Several corrections.
0.00 86 100504 AG
Chapter ”Introduction“
* Section ”J-Link / J-Trace models“ updated.
Chapter ”Target interfaces and adapters“
* Section ”Adapters“ updated.
0.00 85 100428 AG Chapter ”Introduction“
* Section ”J-Link / J-Trace models“ updated.
0.00 84 100324 KN
Chapter ”Working with J-Link and J-Trace“
* Several corrections
Chapter Flash download & flash breakpoints
* Section ”Supported devices“ updated
0.00 83 100223 KN Chapter ”Introduction“
* Section ”J-Link / J-Trace models“ updated.
0.00 82 100215 AG Chapter ”Working with J-Link“
* Section ”J-Link script files“ added.
0.00 81 100202 KN
Chapter ”Device Specifics“
* Section ”Luminary Micro“ updated.
Chapter ”Flash download and flash breakpoints“
* Section ”Supported devices“ updated.
0.00 80 100104 KN Chapter ”Flash download and flash breakpoints
* Section “Supported devices” updated
0.00 79 091201 AG
Chapter “Working with J-Link and J-Trace”
* Section “Reset strategies” updated.
Chapter “Licensing”
* Section “J-Link OEM versions” updated.
0.00 78 091023 AG Chapter “Licensing”
* Section “J-Link OEM versions” updated.
0.00 77 090910 AG Chapter “Introduction”
* Section “J-Link / J-Trace models” updated.
0.00 76 090828 KN
Chapter “Introduction”
* Section“ Specifications” updated
* Section “Hardware versions” updated
* Section “Common features of the J-Link product family” updated
Chapter “Target interfaces and adapters”
* Section “5 Volt adapter” updated
0.00 75 090729 AG
Chapter “Introduction”
* Section “J-Link / J-Trace models” updated.
Chapter “Working with J-Link and J-Trace”
* Section “SWD interface” updated.
0.00 74 090722 KN
Chapter “Introduction”
* Section “Supported IDEs” added
* Section “Supported CPU cores” updated
* Section “Model comparison chart” renamed to
     “Model comparison”
* Section “J-Link bundle comparison chart” removed
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
11
Manual
version Revision Date By Description
0.00 73 090701 KN
Chapter “Introduction”
* Section “J-Link and J-Trace models” added
* Sections “Model comparison chart” &
     “J-Link bundle comparison chart”added
Chapter “J-Link and J-Trace models” removed
Chapter “Hardware” renamed to “Target interfaces & adapters”
* Section “JTAG Isolator” added
Chapter “Target interfaces and adapters”
* Section “Target board design” updated
Several corrections
0.00 72 090618 AG
Chapter “Working with J-Link”
* Section “J-Link control panel” updated.
Chapter “Flash download and flash breakpoints”
* Section “Supported devices” updated.
Chapter “Device specifics”
* Section “NXP” updated.
0.00 71 090616 AG Chapter “Device specifics”
* Section “NXP” updated.
0.00 70 090605 AG
Chapter “Introduction”
* Section “Common features of the J-Link
product family” updated.
0.00 69 090515 AG
Chapter “Working with J-Link”
* Section “Reset strategies” updated.
* Section “Indicators” updated.
Chapter “Flash download and flash breakpoints”
* Section “Supported devices” updated.
0.00 68 090428 AG
Chapter “J-Link and J-Trace related software”
* Section “J-Link STM32 Commander” added.
Chapter “Working with J-Link”
* Section “Reset strategies” updated.
0.00 67 090402 AG Chapter “Working with J-Link”
* Section “Reset strategies” updated.
0.00 66 090327 AG
Chapter “Background information”
* Section “Embedded Trace Macrocell (ETM)” updated.
Chapter “J-Link and J-Trace related software”
* Section “Dedicated flash programming utilities for J-Link” updated.
0.00 65 090320 AG Several changes in the manual structure.
0.00 64 090313 AG Chapter “Working with J-Link”
* Section “Indicators” added.
0.00 63 090212 AG
Chapter “Hardware”
* Several corrections.
* Section “Hardware Versions” Version 8.0 added.
0.00 62 090211 AG
Chapter “Working with J-Link and J-Trace”
* Section “Reset strategies” updated.
Chapter J-Link and J-Trace related software
* Section “J-Link STR91x Commander (Command line tool)” updated.
Chapter “Device specifics”
* Section “ST Microelectronics” updated.
Chapter “Hardware” updated.
0.00 61 090120 TQ Chapter “Working with J-Link”
* Section “Cortex-M3 specific reset strategies”
0.00 60 090114 AG Chapter “Working with J-Link”
* Section “Cortex-M3 specific reset strategies”
0.00 59 090108 KN
Chapter Hardware
* Section “Target board design for JTAG” updated.
* Section “Target board design for SWD” added.
0.00 58 090105 AG Chapter “Working with J-Link Pro”
* Section “Connecting J-Link Pro the first time” updated.
0.00 57 081222 AG
Chapter “Working with J-Link Pro”
* Section “Introduction” updated.
* Section “Configuring J-Link Pro via web interface” updated.
Chapter “Introduction”
* Section “J-Link Pro overview” updated.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
12
Manual
version Revision Date By Description
0.00 56 081219 AG
Chapter “Working with J-Link Pro”
* Section “FAQs” added.
Chapter “Support and FAQs”
* Section “Frequently Asked Questions” updated.
0.00 55 081218 AG Chapter “Hardware” updated.
0.00 54 081217 AG Chapter “Working with J-Link and J-Trace”
* Section “J-Link Command Strings” updated.
0.00 53 081216 AG Chapter “Working with J-Link Pro” updated.
0.00 52 081212 AG
Chapter “Working with J-Link Pro” added.
Chapter “Licensing”
* Section “Original SEGGER products” updated.
0.00 51 081202 KN Several corrections.
0.00 50 081030 AG Chapter “Flash download and flash breakpoints”
* Section “Supported devices” corrected.
0.00 49 081029 AG Several corrections.
0.00 48 080916 AG
Chapter “Working with J-Link and J-Trace”
* Section “Connecting multiple J-Links /
     J-Traces to your PC” updated.
0.00 47 080910 AG Chapter “Licensing” updated.
0.00 46 080904 AG
Chapter “Licensing” added.
Chapter “Hardware”
     Section “J-Link OEM versions” moved to chapter “Licensing”
0.00 45 080902 AG
Chapter “Hardware”
     Section “JTAG+Trace connector” JTAG+Trace
     connector pinout corrected.
     Section “J-Link OEM versions” updated.
0.00 44 080827 AG Chapter “J-Link control panel” moved to chapter “Working with J-Link”.
Several corrections.
0.00 43 080826 AG Chapter “Flash download and flash breakpoints”
     Section “Supported devices” updated.
0.00 42 080820 AG Chapter “Flash download and flash breakpoints”
     Section “Supported devices” updated.
0.00 41 080811 AG
Chapter “Flash download and flash breakpoints” updated.
Chapter “Flash download and flash breakpoints”,
section “Supported devices” updated.
0.00 40 080630 AG
Chapter “Flash download and flash breakpoints” updated.
Chapter “J-Link status window” renamed to “J-Link control panel”
Various corrections.
0.00 39 080627 AG
Chapter “Flash download and flash breakpoints”
     Section “Licensing” updated.
     Section “Using flash download and flash
     breakpoints with different debuggers” updated.
Chapter “J-Link status window” added.
0.00 38 080618 AG
Chapter “Support and FAQs”
     Section “Frequently Asked Questions” updated
Chapter “Reset strategies”
     Section “Cortex-M3 specific reset strategies” updated.
0.00 37 080617 AG Chapter “Reset strategies”
     Section “Cortex-M3 specific reset strategies” updated.
0.00 36 080530 AG
Chapter “Hardware”
     Section “Differences between different versions” updated.
Chapter “Working with J-Link and J-Trace”
     Section “Cortex-M3 specific reset strategies” added.
0.00 35 080215 AG Chapter “J-Link and J-Trace related software”
     Section “J-Link software and documentation package in detail” updated.
0.00 34 080212 AG
Chapter “J-Link and J-Trace related software”
     Section “J-Link TCP/IP Server (Remote J-Link / J-Trace use)” updated.
Chapter “Working with J-Link and J-Trace”
     Section “J-Link Command Strings” updated.
Chapter “Flash download and flash breakpoints”
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
13
Manual
version Revision Date By Description
     Section “Introduction” updated.
     Section “Licensing” updated.
     Section “Using flash download and flash breakpoints with
     different debuggers” updated.
0.00 33 080207 AG
Chapter “Flash download and flash breakpoints” added
Chapter “Device specifics:”
     Section “ATMEL - AT91SAM7 - Recommended init sequence” added.
0.00 32 080129 SK Chapter “Device specifics”:
     Section “NXP - LPC - Fast GPIO bug” list of device enhanced.
0.00 31 080103 SK Chapter “Device specifics”:
     Section “NXP - LPC - Fast GPIO bug” updated.
0.00 30 071211 AG
Chapter “Device specifics”:
     Section “Analog Devices” updated.
     Section “ATMEL” updated.
     Section “Freescale” added.
     Section “Luminary Micro” added.
     Section “NXP” updated.
     Section “OKI” added.
     Section “ST Microelectronics” updated.
     Section “Texas Instruments” updated.
Chapter “Related software”:
     Section “J-Link STR91x Commander” updated
0.00 29 070912 SK Chapter “Hardware”, section “Target board design” updated.
0.00 28 070912 SK
Chapter “Related software”:
     Section “J-LinkSTR91x Commander” added.
Chapter “Device specifics”:
     Section “ST Microelectronics” added.
     Section “Texas Instruments” added.
     Subsection “AT91SAM9” added.
0.00 28 070912 AG Chapter “Working with J-Link/J-Trace”:
     Section “J-Link Command Strings” updated.
0.00 27 070827 TQ Chapter “Working with J-Link/J-Trace”:
     Section “J-Link Command Strings” updated.
0.00 26 070710 SK
Chapter “Introduction”:
     Section “Features of J-Link” updated.
Chapter “Background Information”:
     Section “Embedded Trace Macrocell” added.
     Section “Embedded Trace Buffer” added.
0.00 25 070516 SK
Chapter “Working with J-Link/J-Trace”:
     Section “Reset strategies in detail”
       - “Software, for Analog Devices ADuC7xxx MCUs” updated
       - “Software, for ATMEL AT91SAM7 MCUs” added.
Chapter “Device specifics”
     Section “Analog Devices” added.
     Section “ATMEL” added.
0.00 24 070323 SK
Chapter “Setup”:
     “Uninstalling the J-Link driver” updated.
     “Supported ARM cores” updated.
0.00 23 070320 SK Chapter “Hardware”:
     “Using the JTAG connector with SWD” updated.
0.00 22 070316 SK Chapter “Hardware”:
     “Using the JTAG connector with SWD” added.
0.00 21 070312 SK Chapter “Hardware”:
     “Differences between different versions” supplemented.
0.00 20 070307 SK Chapter “J-Link / J-Trace related software”:
     “J-Link GDB Server” licensing updated.
0.00 19 070226 SK
Chapter “J-Link / J-Trace related software” updated and reorganized.
Chapter “Hardware”
     “List of OEM products” updated
0.00 18 070221 SK Chapter “Device specifics” added
Subchapter “J-Link Command Strings” added
0.00 17 070131 SK Chapter “Hardware”:
     “Version 5.3”: Current limits added
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
14
Manual
version Revision Date By Description
     “Version 5.4” added
Chapter “Setup”:
     “Installing the J-Link USB driver” removed.
     “Installing the J-Link software and documentation pack” added.
Subchapter “List of OEM products” updated.
“OS support” updated
0.00 16 061222 SK Chapter “Preface”: “Company description” added.
J-Link picture changed.
0.00 15 060914 OO
Subchapter 1.5.1: Added target supply voltage and target supply current
to specifications.
Subchapter 5.2.1: Pictures of ways to connect J-Trace.
0.00 14 060818 TQ Subchapter 4.7 “Using DCC for memory reads” added.
0.00 13 060711 OO Subchapter 5.2.2: Corrected JTAG+Trace connector pinout table.
0.00 12 060628 OO Subchapter 4.1: Added ARM966E-S to List of supported ARM cores.
0.00 11 060607 SK Subchapter 5.5.2.2 changed.
Subchapter 5.5.2.3 added.
0.00 10 060526 SK
ARM9 download speed updated.
Subchapter 8.2.1: Screenshot “Start sequence” updated.
Subchapter 8.2.2 “ID sequence” removed.
Chapter “Support” and “FAQ” merged.
Various improvements
0.00 9 060324 OO
Chapter “Literature and references” added.
Chapter “Hardware”:
     Added common information trace signals.
     Added timing diagram for trace.
Chapter “Designing the target board for trace” added.
0.00 8 060117 OO Chapter “Related Software”: Added JLinkARM.dll.
Screenshots updated.
0.00 7 051208 OO Chapter Working with J-Link: Sketch added.
0.00 6 051118 OO
Chapter Working with J-Link: “Connecting multiple J-Links to your PC”
added.
Chapter Working with J-Link: “Multi core debugging” added.
Chapter Background information: “J-Link firmware” added.
0.00 5 051103 TQ Chapter Setup: “JTAG Speed” added.
0.00 4 051025 OO
Chapter Background information: “Flash programming” added.
Chapter Setup: “Scan chain configuration” added.
Some smaller changes.
0.00 3 051021 TQ Performance values updated.
0.00 2 051011 TQ Chapter “Working with J-Link” added.
0.00 1 050818 TW Initial Version
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
15
About this document
Assumptions
This document assumes that you already have a solid knowledge of the following:
The software tools used for building your application (assembler, linker, C compiler).
The C programming language.
The target processor.
DOS command line.
If you feel that your knowledge of C is not sufficient, we recommend The C Programming Lan-
guage by Kernighan and Richie (ISBN 0–13–1103628), which describes the standard in C pro-
gramming and, in newer editions, also covers the ANSI C standard.
How to use this manual
This manual explains all the functions and macros that the product offers. It assumes you have
a working knowledge of the C language. Knowledge of assembly programming is not required.
Typographic conventions for syntax
This manual uses the following typographic conventions:
Style Used for
Body Body text.
Keyword Text that you enter at the command prompt or that appears on
the display (that is system functions, file- or pathnames).
Parameter Parameters in API functions.
Sample Sample code in program examples.
Sample comment Comments in program examples.
Reference Reference to chapters, sections, tables and figures or other doc-
uments.
GUIElement Buttons, dialog boxes, menu names, menu commands.
Emphasis Very important sections.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
16
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
17
Table of contents
1 Introduction ..................................................................................................................26
1.1 Requirements .............................................................................................. 27
1.2 Supported OS ..............................................................................................28
1.3 Common features of the J-Link product family .................................................29
1.4 Supported CPU cores ....................................................................................30
1.5 Built-in intelligence for supported CPU-cores ....................................................31
1.5.1 Intelligence in the J-Link firmware ...................................................... 31
1.5.2 Intelligence on the PC-side (DLL) ........................................................31
1.5.3 Firmware intelligence per model ..........................................................32
1.6 Where to find further information ...................................................................33
1.6.1 SEGGER debug probes .......................................................................33
1.6.2 Using a feature in a specific development environment .......................... 33
2 Licensing .....................................................................................................................34
2.1 Components requiring a license ..................................................................... 35
2.2 Legal use of SEGGER J-Link software ............................................................. 36
2.2.1 Use of the software with 3rd party tools .............................................. 36
2.3 Illegal Clones ...............................................................................................37
3 J-Link software and documentation package ............................................................. 38
3.1 Software overview ........................................................................................39
3.2 J-Link Commander (Command line tool) ......................................................... 40
3.2.1 Commands ....................................................................................... 40
3.2.2 Command line options ....................................................................... 56
3.2.3 Using J-Link Command Files ............................................................... 59
3.3 J-Link Remote Server ................................................................................... 61
3.3.1 List of available commands ................................................................ 61
3.3.2 Tunneling mode ................................................................................ 61
3.4 J-Mem Memory Viewer ................................................................................. 65
3.5 J-Flash ........................................................................................................66
3.6 J-Flash Lite ................................................................................................. 67
3.6.1 Limitations in comparison to J-Flash .................................................... 67
3.6.2 Usage .............................................................................................. 67
3.7 J-Link RTT Viewer ........................................................................................ 69
3.7.1 RTT Viewer Startup ........................................................................... 69
3.7.2 Connection Settings ...........................................................................70
3.7.3 The Terminal Tabs ............................................................................. 70
3.7.4 Sending Input ...................................................................................71
3.7.5 Logging Terminal output .................................................................... 71
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
18
3.7.6 Logging Data ....................................................................................71
3.7.7 Command line options ....................................................................... 72
3.7.8 Menus and Shortcuts .........................................................................74
3.7.9 Using "virtual" Terminals in RTT .......................................................... 75
3.7.10 Using Text Control Codes ................................................................. 75
3.8 J-Link SWO Viewer .......................................................................................77
3.8.1 J-Link SWO Viewer CL ....................................................................... 77
3.8.2 Usage .............................................................................................. 78
3.8.3 List of available command line options .................................................78
3.8.4 Configure SWO output after device reset ..............................................80
3.8.5 Target example code for terminal output ..............................................81
3.9 SWO Analyzer ..............................................................................................83
3.10 JTAGLoad (Command line tool) .................................................................... 84
3.11 J-Link RDI (Remote Debug Interface) ........................................................... 85
3.11.1 Flash download and flash breakpoints ................................................ 85
3.12 Processor specific tools ............................................................................... 86
3.12.1 J-Link STR91x Commander (Command line tool) ................................. 86
3.12.2 J-Link STM32 Unlock (Command line tool) .......................................... 89
3.13 J-Link Software Developer Kit (SDK) .............................................................92
4 J-Link GDB Server ......................................................................................................93
4.1 J-Link GDB Server CL (Windows, Linux, Mac) .................................................. 95
4.2 Debugging with J-Link GDB Server .................................................................96
4.2.1 Setting up GDB Server GUI version .....................................................96
4.2.2 Setting up GDB Server CL version .......................................................96
4.2.3 GDB Server user interface ..................................................................97
4.2.4 Running GDB from different programs ................................................. 98
4.3 Supported remote (monitor) commands ........................................................101
4.3.1 clrbp .............................................................................................. 102
4.3.2 cp15 .............................................................................................. 103
4.3.3 device ............................................................................................ 103
4.3.4 DisableChecks ................................................................................. 103
4.3.5 EnableChecks ..................................................................................104
4.3.6 flash breakpoints .............................................................................104
4.3.7 flash erase ..................................................................................... 104
4.3.8 getargs .......................................................................................... 104
4.3.9 go ................................................................................................. 104
4.3.10 halt ..............................................................................................105
4.3.11 interface ....................................................................................... 105
4.3.12 jtagconf ........................................................................................105
4.3.13 memU8 ........................................................................................ 106
4.3.14 memU16 .......................................................................................106
4.3.15 memU32 .......................................................................................106
4.3.16 reg .............................................................................................. 107
4.3.17 regs ............................................................................................. 107
4.3.18 reset ............................................................................................ 107
4.3.19 semihosting breakOnError ...............................................................108
4.3.20 semihosting enable ........................................................................ 108
4.3.21 semihosting IOClient ...................................................................... 108
4.3.22 semihosting ARMSWI ..................................................................... 109
4.3.23 semihosting ThumbSWI .................................................................. 109
4.3.24 setargs .........................................................................................109
4.3.25 setbp ........................................................................................... 110
4.3.26 sleep ............................................................................................110
4.3.27 speed ...........................................................................................110
4.3.28 step ............................................................................................. 111
4.3.29 SWO DisableTarget .........................................................................111
4.3.30 SWO EnableTarget ......................................................................... 111
4.3.31 SWO GetMaxSpeed ........................................................................ 112
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
19
4.3.32 SWO GetSpeedInfo ........................................................................ 112
4.3.33 waithalt ........................................................................................ 112
4.3.34 wice ............................................................................................. 113
4.3.35 ReadAP .........................................................................................113
4.3.36 ReadDP ........................................................................................ 113
4.3.37 WriteAP ........................................................................................ 114
4.3.38 WriteDP ........................................................................................ 114
4.4 SEGGER-specific GDB protocol extensions ..................................................... 116
4.5 Command line options ................................................................................ 117
4.5.1 -cpu ...............................................................................................118
4.5.2 -device ...........................................................................................119
4.5.3 -endian .......................................................................................... 119
4.5.4 -if ..................................................................................................119
4.5.5 -ir ..................................................................................................120
4.5.6 -excdbg ..........................................................................................120
4.5.7 -jtagconf ........................................................................................ 120
4.5.8 -localhostonly ..................................................................................121
4.5.9 -log ............................................................................................... 121
4.5.10 -logtofile .......................................................................................121
4.5.11 -halt .............................................................................................122
4.5.12 -noir ............................................................................................ 122
4.5.13 -nolocalhostonly ............................................................................ 122
4.5.14 -nologtofile ................................................................................... 122
4.5.15 -nohalt ......................................................................................... 123
4.5.16 -nosilent ....................................................................................... 123
4.5.17 -nostayontop .................................................................................123
4.5.18 -notimeout ....................................................................................124
4.5.19 -novd ........................................................................................... 124
4.5.20 -port ............................................................................................ 124
4.5.21 -rtos ............................................................................................ 124
4.5.22 -jlinkscriptfile ................................................................................ 125
4.5.23 -select ..........................................................................................125
4.5.24 -settingsfile ...................................................................................125
4.5.25 -silent .......................................................................................... 125
4.5.26 -singlerun ..................................................................................... 126
4.5.27 -speed ..........................................................................................126
4.5.28 -stayontop .................................................................................... 126
4.5.29 -timeout ....................................................................................... 126
4.5.30 -strict ...........................................................................................127
4.5.31 -swoport .......................................................................................127
4.5.32 -telnetport .................................................................................... 127
4.5.33 -vd .............................................................................................. 128
4.5.34 -x ................................................................................................ 128
4.5.35 -xc ...............................................................................................128
4.6 Program termination ...................................................................................129
4.6.1 Exit codes ...................................................................................... 129
4.7 Semihosting ...............................................................................................130
5 Setup .........................................................................................................................131
5.1 Installing the J-Link software and documentation pack .................................... 132
5.1.1 Setup procedure ..............................................................................132
5.2 Setting up the USB interface ....................................................................... 133
5.2.1 Verifying correct driver installation .....................................................133
5.2.2 Uninstalling the J-Link USB driver ......................................................134
5.3 Setting up the IP interface .......................................................................... 136
5.3.1 Configuring J-Link using J-Link Configurator ........................................136
5.3.2 Configuring J-Link using the webinterface ...........................................136
5.4 FAQs .........................................................................................................138
5.5 J-Link Configurator ..................................................................................... 139
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
20
5.5.1 Configure J-Links using the J-Link Configurator ................................... 139
5.6 J-Link USB identification ..............................................................................141
5.6.1 Connecting to different J-Links connected to the same host PC via USB ... 141
5.7 Using the J-Link DLL ...................................................................................142
5.7.1 What is the JLink DLL? .................................................................... 142
5.7.2 Updating the DLL in third-party programs ...........................................142
5.7.3 Determining the version of JLink DLL .................................................142
5.7.4 Determining which DLL is used by a program ......................................143
6 Working with J-Link and J-Trace ..............................................................................144
6.1 Supported IDEs ..........................................................................................145
6.2 Connecting the target system ...................................................................... 146
6.2.1 Power-on sequence ..........................................................................146
6.2.2 Verifying target device connection ..................................................... 146
6.2.3 Problems ........................................................................................ 146
6.3 Indicators .................................................................................................. 147
6.3.1 Main indicator ................................................................................. 147
6.3.2 Input indicator ................................................................................ 147
6.3.3 Output indicator .............................................................................. 148
6.4 JTAG interface ............................................................................................149
6.4.1 Multiple devices in the scan chain ..................................................... 149
6.4.2 Sample configuration dialog boxes .....................................................149
6.4.3 Determining values for scan chain configuration .................................. 151
6.4.4 JTAG Speed .................................................................................... 152
6.5 SWD interface ............................................................................................153
6.5.1 SWD speed .....................................................................................153
6.5.2 SWO .............................................................................................. 153
6.6 Multi-core debugging .................................................................................. 155
6.6.1 How multi-core debugging works .......................................................155
6.6.2 Using multi-core debugging in detail ..................................................156
6.6.3 Things you should be aware of ......................................................... 157
6.7 Connecting multiple J-Links / J-Traces to your PC ........................................... 158
6.7.1 How does it work? .......................................................................... 158
6.8 J-Link control panel .................................................................................... 160
6.8.1 Tabs ...............................................................................................160
6.9 Reset strategies ......................................................................................... 166
6.9.1 Strategies for ARM 7/9 devices ......................................................... 166
6.9.2 Strategies for Cortex-M devices .........................................................167
6.10 Using DCC for memory access ................................................................... 171
6.10.1 What is required? .......................................................................... 171
6.10.2 Target DCC handler ........................................................................171
6.10.3 Target DCC abort handler ............................................................... 171
6.11 The J-Link settings file .............................................................................. 172
6.11.1 SEGGER Embedded Studio ..............................................................172
6.11.2 Keil MDK-ARM (uVision) ................................................................. 172
6.11.3 IAR EWARM .................................................................................. 172
6.11.4 Mentor Sourcery CodeBench for ARM ............................................... 172
6.12 J-Link script files ...................................................................................... 173
6.12.1 Actions that can be customized ....................................................... 173
6.12.2 Script file API functions .................................................................. 180
6.12.3 Global DLL variables ...................................................................... 203
6.12.4 Global DLL constants ..................................................................... 207
6.12.5 Script file language ........................................................................209
6.12.6 Script file writing example .............................................................. 210
6.12.7 Executing J-Link script files .............................................................211
6.13 J-Link Command Strings ............................................................................212
6.13.1 List of available commands ............................................................. 212
6.13.2 Using J-Link Command Strings ........................................................ 235
6.14 Switching off CPU clock during debug ......................................................... 236
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
21
6.15 Cache handling .........................................................................................237
6.15.1 Cache coherency ........................................................................... 237
6.15.2 Cache clean area ...........................................................................237
6.15.3 Cache handling of ARM7 cores ........................................................ 237
6.15.4 Cache handling of ARM9 cores ........................................................ 237
6.16 Virtual COM Port (VCOM) ...........................................................................238
6.16.1 Configuring Virtual COM Port ...........................................................238
7 Flash download .........................................................................................................240
7.1 Introduction ...............................................................................................241
7.2 Licensing ................................................................................................... 242
7.3 Supported devices ...................................................................................... 243
7.4 Setup for various debuggers (internal flash) .................................................. 244
7.5 Setup for various debuggers (CFI flash) ........................................................ 245
7.6 Setup for various debuggers (SPIFI flash) ..................................................... 246
7.7 QSPI flash support ..................................................................................... 247
7.7.1 Setup the DLL for QSPI flash download ..............................................247
7.8 Using the DLL flash loaders in custom applications ......................................... 248
7.9 Debugging applications that change flash contents at runtime .......................... 249
8 Flash breakpoints ......................................................................................................250
8.1 Introduction ...............................................................................................251
8.2 Licensing ................................................................................................... 252
8.2.1 Free for evaluation and non-commercial use ....................................... 252
8.3 Supported devices ...................................................................................... 253
8.4 Setup & compatibility with various debuggers ................................................ 254
8.4.1 Setup .............................................................................................254
8.4.2 Compatibility with various debuggers ................................................. 254
8.5 Flash Breakpoints in QSPI flash ....................................................................255
8.5.1 Setup .............................................................................................255
8.6 FAQ .......................................................................................................... 256
9 Monitor Mode Debugging ......................................................................................... 257
9.1 Introduction ...............................................................................................258
9.2 Enable Monitor Debugging ...........................................................................259
9.3 Availability and limitations of monitor mode ...................................................260
9.3.1 Cortex-M3 ...................................................................................... 260
9.3.2 Cortex-M4 ...................................................................................... 260
9.4 Monitor code ..............................................................................................261
9.5 Debugging interrupts .................................................................................. 262
9.6 Having servicing interrupts in debug mode .................................................... 263
9.7 Forwarding of Monitor Interrupts .................................................................. 264
9.8 Target application performs reset (Cortex-M) ................................................. 265
10 Low Power Debugging ............................................................................................266
10.1 Introduction ............................................................................................. 267
10.2 Activating low power mode handling for J-Link ............................................. 268
10.3 Restrictions .............................................................................................. 269
11 Open Flashloader ................................................................................................... 270
11.1 Introduction ............................................................................................. 271
11.2 General procedure .................................................................................... 272
11.3 Adding a new device .................................................................................273
11.4 Editing/Extending an Existing Device ...........................................................274
11.5 XML Tags and Attributes ............................................................................275
11.5.1 <Database> ..................................................................................275
11.5.2 <Device> ..................................................................................... 275
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
22
11.5.3 <ChipInfo> ...................................................................................275
11.5.4 <FlashBankInfo> ........................................................................... 277
11.6 Example XML file ......................................................................................279
11.7 Add. Info / Considerations / Limitations .......................................................280
11.7.1 CMSIS Flash Algorithms Compatibility .............................................. 280
11.7.2 Supported Cores ............................................................................280
11.7.3 Information for Silicon Vendors ....................................................... 280
11.7.4 Template Projects and How To's ...................................................... 280
12 J-Flash SPI ............................................................................................................. 281
12.1 Introduction ............................................................................................. 282
12.1.1 What is J-Flash SPI? ...................................................................... 282
12.1.2 J-Flash SPI CL (Windows, Linux, Mac) .............................................. 282
12.1.3 Features ....................................................................................... 283
12.1.4 Requirements ................................................................................ 283
12.2 Licensing ................................................................................................. 284
12.2.1 Introduction .................................................................................. 284
12.3 Getting Started ........................................................................................ 285
12.3.1 Setup ........................................................................................... 285
12.3.2 Using J-Flash SPI for the first time .................................................. 285
12.3.3 Menu structure ..............................................................................286
12.4 Settings ...................................................................................................289
12.4.1 Project Settings .............................................................................289
12.4.2 Global Settings ..............................................................................293
12.5 Command Line Interface ........................................................................... 295
12.5.1 Overview ...................................................................................... 295
12.5.2 Command line options ....................................................................295
12.5.3 Batch processing ........................................................................... 297
12.5.4 Programming multiple targets in parallel ...........................................297
12.6 Creating a new J-Flash SPI project ............................................................. 299
12.7 Custom Command Sequences .................................................................... 300
12.7.1 Init / Exit steps ............................................................................. 300
12.7.2 Example ....................................................................................... 300
12.7.3 J-Flash SPI Command Line Version .................................................. 301
12.8 Device specifics ........................................................................................ 304
12.8.1 SPI flashes with multiple erase commands ........................................304
12.9 Target systems .........................................................................................305
12.9.1 Which flash devices can be programmed? ......................................... 305
12.10 Performance ........................................................................................... 306
12.10.1 Performance values ...................................................................... 306
12.11 Background information ...........................................................................307
12.11.1 SPI interface connection ............................................................... 307
12.12 Support ................................................................................................. 308
12.12.1 Troubleshooting ........................................................................... 308
12.12.2 Contacting support .......................................................................308
13 RDI ..........................................................................................................................309
13.1 Introduction ............................................................................................. 310
13.1.1 Features ....................................................................................... 310
13.2 Licensing ................................................................................................. 311
13.3 Setup for various debuggers ...................................................................... 312
13.3.1 ARM AXD (ARM Developer Suite, ADS) .............................................312
13.3.2 ARM RVDS (RealView developer suite) ..............................................314
13.3.3 GHS MULTI ................................................................................... 319
13.4 Configuration ........................................................................................... 322
13.4.1 Configuration file JLinkRDI.ini ..........................................................322
13.4.2 Using different configurations .......................................................... 322
13.4.3 Using multiple J-Links simultaneously ...............................................322
13.4.4 Configuration dialog ....................................................................... 322
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
23
13.5 Semihosting ............................................................................................. 331
13.5.1 Unexpected / unhandled SWIs .........................................................331
14 ARM SWD specifics ................................................................................................332
14.1 Introduction ............................................................................................. 333
14.2 SWD multi-drop ....................................................................................... 334
14.2.1 How it works ................................................................................ 334
14.2.2 Setting up SWD multi-drop in the J-Link software .............................. 334
14.2.3 J-Link support ............................................................................... 334
15 RTT ......................................................................................................................... 335
15.1 Introduction ............................................................................................. 336
15.2 How RTT works ........................................................................................ 337
15.2.1 Target implementation ....................................................................337
15.2.2 Locating the Control Block .............................................................. 337
15.2.3 Internal structures ......................................................................... 337
15.2.4 Requirements ................................................................................ 338
15.2.5 Performance ..................................................................................338
15.2.6 Memory footprint ...........................................................................338
15.3 RTT Communication .................................................................................. 339
15.3.1 RTT Viewer ................................................................................... 339
15.3.2 RTT Client .....................................................................................339
15.3.3 RTT Logger ................................................................................... 339
15.3.4 RTT in other host applications ......................................................... 339
15.4 Implementation ........................................................................................ 340
15.4.1 API functions ................................................................................ 340
15.4.2 Configuration defines ..................................................................... 346
15.5 ARM Cortex - Background memory access ................................................... 348
15.6 Example code .......................................................................................... 349
15.7 FAQ ........................................................................................................ 350
16 Trace .......................................................................................................................351
16.1 Introduction ............................................................................................. 352
16.1.1 What is backtrace? ........................................................................ 352
16.1.2 What is streaming trace? ................................................................352
16.1.3 What is code coverage? ..................................................................352
16.1.4 What is code profiling? ...................................................................353
16.2 Tracing via trace pins ................................................................................354
16.2.1 Cortex-M specifics ..........................................................................354
16.2.2 Trace signal timing ........................................................................ 354
16.2.3 Adjusting trace signal timing on J-Trace ............................................354
16.2.4 J-Trace models with support for streaming trace ................................ 355
16.3 Tracing with on-chip trace buffer ................................................................ 356
16.3.1 CPUs that provide tracing via pins and on-chip buffer ......................... 356
16.4 Target devices with trace support ............................................................... 357
16.5 Streaming trace ....................................................................................... 358
16.5.1 Download and execution address differ .............................................358
16.5.2 Do streaming trace without prior download ....................................... 358
17 Target interfaces and adapters ...............................................................................359
17.1 20-pin J-Link connector ............................................................................. 360
17.1.1 Pinout for JTAG ............................................................................. 360
17.1.2 Pinout for SWD ............................................................................. 362
17.1.3 Pinout for SWD + Virtual COM Port (VCOM) ...................................... 364
17.1.4 Pinout for SPI ............................................................................... 365
17.2 19-pin JTAG/SWD and Trace connector ........................................................366
17.2.1 Target power supply ...................................................................... 367
17.3 9-pin JTAG/SWD connector ........................................................................ 368
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
24
17.4 Reference voltage (VTref) .......................................................................... 369
17.5 Adapters ..................................................................................................370
18 Background information ..........................................................................................371
18.1 JTAG ....................................................................................................... 372
18.1.1 Test access port (TAP) ....................................................................372
18.1.2 Data registers ............................................................................... 372
18.1.3 Instruction register ........................................................................ 372
18.1.4 The TAP controller ......................................................................... 372
18.2 Embedded Trace Macrocell (ETM) ................................................................375
18.2.1 Trigger condition ............................................................................375
18.2.2 Code tracing and data tracing ......................................................... 375
18.2.3 J-Trace integration example - IAR Embedded Workbench for ARM .........375
18.3 Embedded Trace Buffer (ETB) .................................................................... 379
18.4 Flash programming ................................................................................... 380
18.4.1 How does flash programming via J-Link / J-Trace work? ...................... 380
18.4.2 Data download to RAM ...................................................................380
18.4.3 Data download via DCC ..................................................................380
18.4.4 Available options for flash programming ........................................... 380
18.5 J-Link / J-Trace firmware ........................................................................... 382
18.5.1 Firmware update ........................................................................... 382
18.5.2 Invalidating the firmware ................................................................382
19 Designing the target board for trace .......................................................................384
19.1 Overview of high-speed board design ..........................................................385
19.1.1 Avoiding stubs ...............................................................................385
19.1.2 Minimizing Signal Skew (Balancing PCB Track Lengths) ....................... 385
19.1.3 Minimizing Crosstalk ...................................................................... 385
19.1.4 Using impedance matching and termination ...................................... 385
19.2 Terminating the trace signal .......................................................................386
19.2.1 Rules for series terminators ............................................................ 386
19.3 Signal requirements .................................................................................. 387
20 Semihosting .............................................................................................................388
20.1 Introduction ............................................................................................. 389
20.1.1 Advantages ................................................................................... 389
20.1.2 Disadvantages ...............................................................................389
20.2 Debugger support .....................................................................................390
20.3 Implementation ........................................................................................ 391
20.3.1 SVC instruction ............................................................................. 391
20.3.2 Breakpoint instruction .................................................................... 391
20.3.3 J-Link GDBServer optimized version .................................................391
20.4 Communication protocol ............................................................................ 394
20.4.1 Register R0 ...................................................................................394
20.4.2 Command SYS_OPEN (0x01) .......................................................... 394
20.4.3 Command SYS_CLOSE (0x02) ......................................................... 395
20.4.4 Command SYS_WRITEC (0x03) ....................................................... 395
20.4.5 Command SYS_WRITE0 (0x04) ....................................................... 396
20.4.6 Command SYS_WRITE (0x05) .........................................................396
20.4.7 Command SYS_READ (0x06) .......................................................... 396
20.4.8 Command SYS_READC (0x07) .........................................................397
20.4.9 Command SYS_ISTTY (0x09) .......................................................... 397
20.4.10 Command SYS_SEEK (0x0A) .........................................................397
20.4.11 Command SYS_FLEN (0x0C) ......................................................... 398
20.4.12 Command SYS_REMOVE (0x0E) .....................................................398
20.4.13 Command SYS_RENAME (0x0F) ..................................................... 398
20.4.14 Command SYS_GET_CMDLINE (0x15) ............................................ 399
20.4.15 Command SYS_EXIT (0x18) ..........................................................399
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
25
20.5 Enabling semihosting in J-Link GDBServer ................................................... 400
20.5.1 SVC variant .................................................................................. 400
20.5.2 Breakpoint variant ......................................................................... 400
20.5.3 J-Link GDBServer optimized variant ................................................. 400
20.6 Enabling Semihosting in J-Link RDI + AXD .................................................. 401
20.6.1 Using SWIs in your application ........................................................401
21 Environmental Conditions & Safety ........................................................................402
21.1 J-Link ......................................................................................................403
21.1.1 Affected models .............................................................................403
21.2 Flasher .................................................................................................... 404
21.2.1 Affected models .............................................................................404
21.3 J-Trace .................................................................................................... 405
21.3.1 Affected models .............................................................................405
22 Support and FAQs ..................................................................................................406
22.1 Measuring download speed ........................................................................ 407
22.2 Troubleshooting ........................................................................................ 408
22.2.1 General procedure ......................................................................... 408
22.3 Contacting support ................................................................................... 409
22.3.1 Contact Information ....................................................................... 409
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
Chapter 1
Introduction
This is the user documentation for owners of SEGGER debug probes, J-Link and J-Trace.
This manual documents the software which with the J-Link Software and Documentation
Package as well as advanced features of J-Link and J-Trace, like Real Time Transfer (RTT),
J-Link Script Files or Trace.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
27 CHAPTER 1 Requirements
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 28.
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 fea-
tures are supported by each emulator, please refer to SEGGER debug probes on page 33.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
28 CHAPTER 1 Supported OS
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 2003
Microsoft Windows 2003 x64
Microsoft Windows Vista
Microsoft Windows Vista x64
Microsoft Windows 7
Microsoft Windows 7 x64
Microsoft Windows 8
Microsoft Windows 8 x64
Microsoft Windows 10
Microsoft Windows 10 x64
Linux
macOS 10.5 and higher
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
29 CHAPTER 1 Common features of the J-Link product family
1.3 Common features of the J-Link product family
USB 2.0 interface (Full-Speed/Hi-Speed, depends on J-Link model)
Any ARM7/ARM9/ARM11 (including thumb mode), Cortex-A5/A7/A8/A9/A12/A15/A17,
Cortex-M0/M1/M3/M4/M7/M23/M33, Cortex-R4/R5 core supported
Automatic core recognition
Maximum interface speed 15/50 MHz (depends on J-Link model)
Seamless integration into all major IDEs ( List of supported IDEs )
No power supply required, powered through USB
Support for adaptive clocking
All JTAG signals can be monitored, target voltage can be measured
Support for multiple devices
Fully plug and play compatible
Standard 20-pin JTAG/SWD connector, 19-pin JTAG/SWD and Trace connector, standard
38-pin JTAG+Trace connector
USB and 20-pin ribbon cable included
Memory viewer (J-Mem) included
Remote server included, which allows using J-Trace via TCP/IP networks
RDI interface available, which allows using J-Link with RDI compliant software
Flash programming software (J-Flash) available
Flash DLL available, which allows using flash functionality in custom applications
Software Developer Kit (SDK) available
14-pin JTAG adapter available
J-Link 19-pin Cortex-M Adapter available
J-Link 9-pin Cortex-M Adapter available
Adapter for 5V JTAG targets available for hardware revisions up to 5.3
Optical isolation adapter for JTAG/SWD interface available
Target power supply via pin 19 of the JTAG/SWD interface (up to 300 mA to target
with overload protection), alternatively on pins 11 and 13 of the Cortex-M 19-pin trace
connector
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
30 CHAPTER 1 Supported CPU cores
1.4 Supported CPU cores
J-Link / J-Trace supports any common ARM Cortex core, ARM legacy core, Microchip PIC32
core and Renesas RX core. For a detailed list, please refer to:
SEGGER website: Supported Cores .
If you experience problems with a particular core, do not hesitate to contact SEGGER.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
31 CHAPTER 1 Built-in intelligence for supported CPU-cores
1.5 Built-in intelligence for supported CPU-cores
In general, there are two ways to support a CPU-core in the J-Link software:
1. Intelligence in the J-Link firmware
2. Intelligence on the PC-side (DLL)
Having the intelligence in the firmware is ideal since it is much more powerful and robust.
The J-Link PC software automatically detects which implementation level is supported for
the connected CPU-core. If intelligence in the firmware is available, it is used. If you are
using a J-Link that does not have intelligence in the firmware and only PC-side intelligence
is available for the connected CPU, a warning message is shown.
1.5.1 Intelligence in the J-Link firmware
On newer J-Links, the intelligence for a new CPU-core is also available in the J-Link firmware
which means that for these J-Links, the target sequences are no longer generated on the PC-
side but directly inside the J-Link. Having the intelligence in the firmware leads to improved
stability and higher performance.
1.5.2 Intelligence on the PC-side (DLL)
This is the basic implementation level for support of a CPU-core. This implementation is
not J-Link model dependent, since no intelligence for the CPU-core is necessary in the J-
Link firmware. This means, all target sequences (JTAG/SWD/…) are generated on the PC-
side and the J-Link simply sends out these sequences and sends the result back to the DLL.
Using this way of implementation also allows old J-Links to be used with new CPU cores as
long as a DLL-Version is used which has intelligence for the CPU.
But there is one big disadvantage of implementing the CPU core support on the DLL-side:
For every sequence which shall be sent to the target a USB or Ethernet transaction is
triggered. The long latency especially on a USB connection significantly affects the perfor-
mance of J-Link. This is true especially when performing actions where J-Link has to wait
for the CPU frequently. An example is a memory read/write operation which needs to be
followed by status read operations or repeated until the memory operation is completed.
Performing this kind of task with only PC-side intelligence requires to either make some
assumption like: Operation is completed after a given number of cycles. Or it requires to
make a lot of USB/Ethernet transactions. The first option (fast mode) will not work under
some circumstances such as low CPU speeds, the second (slow mode) will be more reliable
but very slow due to the high number of USB/Ethernet transactions. It simply boils down
to: The best solution is having intelligence in the emulator itself!
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
32 CHAPTER 1 Built-in intelligence for supported CPU-cores
1.5.2.1 Limitations of PC-side implementations
Instability, especially on slow targets
Due to the fact that a lot of USB transactions would cause a very bad performance of J-
Link, PC-side implementations are on the assumption that the CPU/Debug interface is
fast enough to handle the commands/requests without the need of waiting. So, when
using the PC-side-intelligence, stability cannot be guaranteed in all cases, especially if
the target interface speed (JTAG/SWD/…) is significantly higher than the CPU speed.
Poor performance
Since a lot more data has to be transferred over the host interface (typically USB),
the resulting download speed is typically much lower than for implementations with
intelligence in the firmware, even if the number of transactions over the host interface
is limited to a minimum (fast mode).
No support
Please understand that we cannot give any support if you are running into problems
when using a PC-side implementation.
Note
Due to these limitations, we recommend to use PC-side implementations for evaluation
only.
1.5.3 Firmware intelligence per model
There are different models of J-Link / J-Trace which have built-in intelligence for different
CPU-cores. Please refer to J-Link / J-Trace hardware revisions for further information.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
33 CHAPTER 1 Where to find further information
1.6 Where to find further information
The following items are not the scope of the J-Link / J-Trace User Guide (UM08001) and
therefore documented elsewhere in the respective place described/listed below.
1.6.1 SEGGER debug probes
1.6.1.1 J-Link / J-Trace current model overview
In order to compare features, performance specifications, capabilities and included licenses
of current J-Link / J-Trace or Flasher models, please refer to the SEGGER website:
J-Link Model overview
1.6.1.2 J-Link / J-Trace hardware revisions
For feature comparisons between different hardware revisions of J-Link / J-Trace or Flasher
models, please refer to:
SEGGER Wiki: J-Link / J-Trace / Flasher Software and Hardware features overview
1.6.1.3 J-Link / J-Trace hardware specifications
For detailed general, mechanical and electrical specifications of a specific J-Link / J-Trace
or Flasher model, please refer to:
SEGGER Wiki: J-Link / J-Trace / Flasher general, mechanical, electrical specifications
1.6.2 Using a feature in a specific development environment
For many features described in this manual, detailed explanations on how to use them
with popular debuggers, IDEs and other applications are available in the SEGGER wiki.
Therefore, for information on how to use a feature in a specific development environment,
please refer to:
SEGGER Wiki: Getting Started with Various IDEs .
If an explanation is missing for the IDE used or the IDE used is not listed at all, please
contact us. (see Contact Information )
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
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.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
35 CHAPTER 2 Components requiring a license
2.1 Components requiring a license
J-Link PLUS and higher are fully featured J-Links and come with all licenses included. Other
models may do not come with all features enabled. For a detailed overview of the included
licenses of the SEGGER debug probes, please refer to:
J-Link Model overview: Licenses
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
36 CHAPTER 2 Legal use of SEGGER J-Link software
2.2 Legal use of SEGGER J-Link software
The software consists of proprietary programs of SEGGER, protected under copyright and
trade secret laws. All rights, title and interest in the software are and shall remain with
SEGGER. For details, please refer to the license agreement which needs to be accepted
when installing the software. The text of the license agreement is also available as entry
in the start menu after installing the software.
Use of software
SEGGER J-Link software may only be used with original SEGGER products and authorized
OEM products. The use of the licensed software to operate SEGGER product clones is pro-
hibited and illegal.
2.2.1 Use of the software with 3rd party tools
For simplicity, some components of the J-Link software are also distributed by partners
with software tools designed to use J-Link. These tools are primarily debugging tools, but
also memory viewers, flash programming utilities as well as software for other purposes.
Distribution of the software components is legal for our partners, but the same rules as
described above apply for their usage: They may only be used with original SEGGER prod-
ucts and authorized OEM products. The use of the licensed software to operate SEGGER
product clones is prohibited and illegal.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
37 CHAPTER 2 Illegal Clones
2.3 Illegal Clones
Clones are copies of SEGGER products which use the copyrighted SEGGER Firmware with-
out a license. It is strictly prohibited to use SEGGER J-Link software with illegal clones of
SEGGER products. Manufacturing and selling these clones is an illegal act for various rea-
sons, amongst them trademark, copyright and unfair business practice issues. The use of
illegal J-Link clones with this software is a violation of US, European and other international
laws and is prohibited. If you are in doubt if your unit may be legally used with SEGGER
J-Link software, please get in touch with us. End users may be liable for illegal use of J-
Link software with clones.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
Chapter 3
J-Link software and
documentation package
This chapter describes the contents of the J-Link Software and Documentation Package
which can be downloaded from www.segger.com .
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
39 CHAPTER 3 Software overview
3.1 Software overview
The J-Link Software and Documentation Package, which is available for download from
segger.com/jlink-software.html , includes some applications to be used with J-Link. It also
comes with USB-drivers for J-Link and documentations in pdf format.
Software Description
J-Link Commander Command-line tool with basic functionality for target analysis.
J-Link GDB Server The J-Link GDB Server is a server connecting to the GNU De-
bugger (GDB) via TCP/IP. It is required for toolchains using the
GDB protocol to connect to J-Link.
J-Link GDB Server
command line version Command line version of the J-Link GDB Server. Same func-
tionality as the GUI version.
J-Link Remote Server Utility which provides the possibility to use J-Link / J-Trace re-
motely via TCP/IP.
J-Mem Target memory viewer. Shows the memory content of a run-
ning target and allows editing as well.
J-FlashaStand-alone flash programming application. For more infor-
mation about J-Flash please refer to J-Flash ARM User’s Guide
(UM08003).
J-Flash Lite Stand-alone flash programming application. Reduced feature
set of J-Flash
J-Link RTT Viewer Free-of-charge utility for J-Link. Displays the terminal output
of the target using RTT. Can be used in parallel with a debug-
ger or stand-alone.
J-Link SWO Viewer Free-of-charge utility for J-Link. Displays the terminal output
of the target using the SWO pin. Can be used in parallel with a
debugger or stand-alone.
J-Link SWO Analyzer Command line tool that analyzes SWO RAW output and stores
it into a file.
JTAGLoad Command line tool that opens an svf file and sends the data in
it via J-Link / J-Trace to the target.
J-Link Configurator
GUI-based configuration tool for J-Link. Allows configuration of
USB identification as well as TCP/IP identification of J-Link. For
more information about the J-Link Configurator, please refer
to J-Link Configurator .
RDI supportaProvides Remote Debug Interface (RDI) support. This allows
the user to use J-Link with any RDI-compliant debugger.
Processor specific tools Free command-line tools for handling specific processors.
Included are: STR9 Commander and STM32 Unlock.
a Full-featured J-Link (PLUS, PRO, ULTRA+) or an additional license for J-Link base model
required.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
40 CHAPTER 3 J-Link Commander (Command line tool)
3.2 J-Link Commander (Command line tool)
J-Link Commander (JLink.exe) is a tool that can be used for verifying proper installation
of the USB driver and to verify the connection to the target CPU, as well as for simple
analysis of the target system. It permits some simple commands, such as memory dump,
halt, step, go etc. to verify the target connection.
J-Link Commander: JTAG connection
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 descriptions of the
commands can be found in the sections that follow.
Command (short form) Explanation
Basic
clrBP Clear breakpoint.
clrWP Clear watchpoint.
device Selects a device.
erase Erase internal flash of selected device.
exec Execute J-Link Command String.
exit (qc, q) Closes J-Link Commander.
exitonerror (eoe) Commander exits after error.
fPrints firmware info.
go (g) Starts the CPU core.
halt (h) Halts the CPU core.
hwinfo Show hardware info.
is Scan chain select register length.
loadfile Load data file into target memory.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
41 CHAPTER 3 J-Link Commander (Command line tool)
Command (short form) Explanation
log Enables log to file.
mem Read memory.
mem8 Read 8-bit items.
mem16 Read 16-bit items.
mem32 Read 32-bit items.
mem64 Read 64-bit items.
mr Measures reaction time of RTCK pin.
ms Measures length of scan chain.
power Switch power supply for target.
rResets and halts the target.
readAP Reads from a CoreSight AP register.
readDP Reads from a CoreSight DP register.
regs Shows all current register values.
rnh Resets without halting the target.
rreg Shows a specific register value.
rx Reset target with delay.
savebin Saves target memory into binary file.
setBP Set breakpoint.
setPC Set the PC to specified value.
setWP Set watchpoint.
sleep Waits the given time (in milliseconds).
speed Set target interface speed.
st Shows the current hardware status.
step (s) Single step the target chip.
unlock Unlocks a device.
verifybin Compares memory with data file.
w1 Write 8-bit items.
w2 Write 16-bit items.
w4 Write 32-bit items.
writeAP Writes to a CoreSight AP register.
writeDP Writes to a CoreSight DP register.
wreg Write register.
Flasher I/O
fdelete (fdel) Delete file on emulator.
flist List directory on emulator.
fread (frd) Read file from emulator.
fshow Read and display file from emulator.
fsize (fsz) Display size of file on emulator.
fwrite (fwr) Write file to emulator.
Connection
ip Connect to J-Link Pro via TCP/IP.
usb Connect to J-Link via USB.
Configuration
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
42 CHAPTER 3 J-Link Commander (Command line tool)
Command (short form) Explanation
VTREF Sets a fixed value for VTref on J-Link.
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
DeviceName Valid device name: Device is selected.
?: 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
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
43 CHAPTER 3 J-Link Commander (Command line tool)
3.2.1.5 exec
Execute J-Link Command String. For more information about the usage of J-Link Command
Strings please refer to J-Link Command Strings .
Syntax
exec <Command>
Parameter Meaning
Command J-Link Command String to be executed.
Example
exec SupplyPower = 1
3.2.1.6 exit
This command closes the target connection, the connection to the J-Link and exits J-Link
Commander.
Syntax
q
3.2.1.7 exitonerror
This command toggles whether J-Link Commander exits on error or not.
Syntax
ExitOnError <1|0>
Parameter Meaning
<1|0> 1: J-Link Commander will now exit on Error.
0: J-Link Commander will no longer exit on Error.
Example
eoe 1
3.2.1.8 f
Prints firmware and hardware version info. Please notice that minor hardware revisions may
not be displayed, as they do not have any effect on the feature set.
Syntax
f
3.2.1.9 fdelete
On emulators which support file I/O this command deletes a specific file.
Syntax
fdelete <FileName>
Parameter Meaning
FileName File to delete from the Flasher.
Example
fdelete Flasher.dat
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
44 CHAPTER 3 J-Link Commander (Command line tool)
3.2.1.10 flist
On emulators which support file I/O this command shows the directory tree of the Flasher.
Syntax
flist
3.2.1.11 fread
On emulators which support file I/O this command reads a specific file. Offset applies to
both destination and source file.
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.12 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.
aIf 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
3.2.1.13 fsize
On emulators which support file I/O this command gets the size of a specific file. Currently,
only Flasher models support file I/O.
Syntax
fsize <FileName>]
Parameter Meaning
FileName Source file name to read from the Flasher.
Example
fsize Flasher.dat
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
45 CHAPTER 3 J-Link Commander (Command line tool)
3.2.1.14 fwrite
On emulators which support file I/O this command writes a specific file. Currently, only
Flasher models support file I/O. NumBytes is limited to 512 bytes at once.
This means, if you want to write e.g. 1024 bytes, you have to send the command twice,
using an appropriate offset when sending it the second time. Offset applies to both desti-
nation and source file.
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.15 go
Starts the CPU. In order to avoid setting breakpoints it allows to define a maximum num-
ber of instructions which can be simulated/emulated. This is particularly 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
Syntax
go [<NumSteps> [<Flags>]]
Parameter Meaning
NumSteps
Maximum number of instructions allowed to be simulated. Instruc-
tion simulation stops whenever a breakpointed instruction is hit,
an instruction which cannot be simulated/emulated is hit or when
NumSteps is reached.
Flags 0: Do not start the CPU if a BP is in range of NumSteps
1: Overstep BPs
Example
go //Simply starts the CPU
go 20, 1
3.2.1.16 halt
Halts the CPU Core. If successful, shows the current CPU registers.
Syntax
halt
3.2.1.17 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 overcurrent happened.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
46 CHAPTER 3 J-Link Commander (Command line tool)
Syntax
hwinfo
3.2.1.18 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
Addr
Valid values:
IP Address: Connects the J-Link with the specified IP-Address
Host Name: Resolves the host name and connects to it.
*: Invokes the Emulator selection dialog.
Example
ip 192.168.6.3
3.2.1.19 is
This command returns information about the length of the scan chain select register.
Syntax
is
3.2.1.20 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.21 log
Set path to logfile allowing the DLL to output logging information. If the logfile already
exists, the contents of the current logfile will be overwritten.
Syntax
log <Filename>
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
47 CHAPTER 3 J-Link Commander (Command line tool)
Parameter Meaning
Filename Log filename
Example
log C:\Work\log.txt
3.2.1.22 mem
The command reads memory from the target system. If necessary, the target CPU is halted
in order to read memory. Zone names will be displayed on first connect to target with J-
Link commander if available.
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 0x0, 0x100
or
mem AHB-AP (AP1):0x20000000, 0x100
3.2.1.23 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
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
mem8 0, 100
3.2.1.24 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
mem [<Zone>:]<Addr>, <NumBytes> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
Numbytes Number of halfwords to read. Maximum is 0x80000.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
48 CHAPTER 3 J-Link Commander (Command line tool)
Example
mem16 0, 100
3.2.1.25 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
mem [<Zone>:]<Addr>, <NumBytes> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
Numbytes Number of words to read. Maximum is 0x40000.
Example
mem32 0, 100
3.2.1.26 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
mem [<Zone>:]<Addr>, <NumBytes> (hex)
Parameter Meaning
Zone Name of memory zone to access.
Addr Start address.
Numbytes Number of double words to read. Maximum is 0x20000.
Example
mem64 0, 100
3.2.1.27 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.28 ms
Measures the number of bits in the specified scan chain.
Syntax
ms <ScanChain>
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
49 CHAPTER 3 J-Link Commander (Command line tool)
Parameter Meaning
ScanChain Scan chain to be measured.
Example
ms 1
3.2.1.29 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
power on perm
3.2.1.30 r
Resets and halts the target.
Syntax
r
3.2.1.31 readAP
Reads from a CoreSight AP register. This command performs a full-qualified read which
means that it tries to read until the read has been accepted or too many WAIT responses
have been received. In case actual read data is returned on the next read request (this is
the case for example with interface JTAG) this command performs the additional dummy
read request automatically.
Syntax
ReadAP <RegIndex>
Parameter Meaning
RegIndex Index of AP register to read
Example
//
// Read AP[0], IDR (register 3, bank 15)
//
WriteDP 2, 0x000000F0 // Select AP[0] bank 15
ReadAP 3 // Read AP[0] IDR
3.2.1.32 readDP
Reads from a CoreSight DP register. This command performs a full-qualified read which
means that it tries to read until the read has been accepted or too many WAIT responses
have been received. In case actual read data is returned on the next read request (this is
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
50 CHAPTER 3 J-Link Commander (Command line tool)
the case for example with interface JTAG) this command performs the additional dummy
read request automatically.
Syntax
ReadDP <RegIndex>
Parameter Meaning
RegIndex Index of DP register to read
Example
//
// Read DP-CtrlStat
//
ReadDP 1
3.2.1.33 regs
Shows all current register values.
Syntax
regs
3.2.1.34 rnh
This command performs a reset but without halting the device.
Syntax
rnh
3.2.1.35 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.36 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
DelayAfterRe-
set Delay in ms.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
51 CHAPTER 3 J-Link Commander (Command line tool)
Example
rx 10
3.2.1.37 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.38 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.
A/T Only for ARM7/9/11 and Cortex-R4 devices:
A: ARM mode
T: THUMB mode
W/H Only for MIPS devices:
W: MIPS32 mode (Word)
H: MIPS16 mode (Half-word)
S/H S: Force software BP
H: Force hardware BP
Example
setBP 0x8000036
3.2.1.39 setPC
Sets the PC to the specified value.
Syntax
setpc <Addr>
Parameter Meaning
Addr Address the PC should be set to.
Example
setpc 0x59C
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
52 CHAPTER 3 J-Link Commander (Command line tool)
3.2.1.40 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 auto-
matically 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.
Accesstype Specifies the control data on which data event has been set:
R: read access
W: write access
Size Valid values: S8 | S16 | S32
Specifies to monitor an n-bit access width at the selected address.
Data Specifies the Data on which watchpoint has been set.
DataMask
Specifies data mask used for comparison. Bits set to 1 are masked
out, so not taken into consideration during data comparison. Please
note that for certain cores not all Bit-Mask combinations are support-
ed by the core-debug logic. On some cores only complete bytes can
be masked out (e.g. PIC32) or similar.
AddrMask
Specifies the address mask used for comparison. Bits set to 1 are
masked out, so not taken into consideration during address compar-
ison. Please note that for certain cores not all Bit-Mask combinations
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.41 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.42 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.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
53 CHAPTER 3 J-Link Commander (Command line tool)
Parameter Meaning
auto Selects auto detection of the interface speed.
adaptive Selects adaptive clocking as JTAG speed.
Example
speed 4000
speed auto
3.2.1.43 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.44 step
Target needs to be halted before calling this command. Executes a single step on the target.
The instruction is overstepped even if it is breakpointed. Prints out the disassembly of the
instruction to be stepped.
Syntax
step
3.2.1.45 unlock
This command unlocks a device which has been accidentally locked by malfunction of user
software.
Syntax
unlock <DeviceName>
Parameter Meaning
DeviceName
Name of the device family to unlock. Supported Devices:
LM3Sxxx
Kinetis
EFM32Gxxx
Example
unlock Kinetis
3.2.1.46 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
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
54 CHAPTER 3 J-Link Commander (Command line tool)
Example
usb
3.2.1.47 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.48 VTREF
Sets a fixed value for VTref on J-Link. The Value of VTref can be set between 1200 mV
and 3300 mV all values that exceed 3300 mV will be limited to 3300 mV, values smaller
than 1200 mV deactivate fixed VTref. Settings of fixed VTref apply nonvolatile after power
cycling the probe.
Syntax
VTREF <ValuemV>
Parameter Meaning
ValuemV value in Millivolt
Example
VTREF 3300
3.2.1.49 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.50 w2
The command writes a unit of 16-bits to the target system.
Syntax
w2 [<Zone>:]<Addr>, <Data> (hex)
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
55 CHAPTER 3 J-Link Commander (Command line tool)
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.51 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.52 writeAP
Writes to a CoreSight AP register. This command performs a full-qualified write which means
that it tries to write until the write has been accepted or too many WAIT responses have
been received.
Syntax
WriteAP <RegIndex>, <Data32Hex>
Parameter Meaning
RegIndex Index of AP register to write
Data32Hex Data to write
Example
//
// Select AHB-AP and configure it
//
WriteDP 2, 0x00000000 // Select AP[0] (AHB-AP) bank 0
WriteAP 4, 0x23000010 // Auto-increment, Private access, Access size: word}
3.2.1.53 writeDP
Writes to a CoreSight DP register. This command performs a full-qualified write which means
that it tries to write until the write has been accepted or too many WAIT responses have
been received.
Syntax
WriteDP <RegIndex>, <Data32Hex>
Parameter Meaning
RegIndex Index of DP register to write
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
56 CHAPTER 3 J-Link Commander (Command line tool)
Parameter Meaning
Data32Hex Data to write
Example
//
// Write DP SELECT register: Select AP 0 bank 15
//
WriteDP 2, 0x000000F0
3.2.1.54 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
3.2.2 Command line options
J-Link Commander can be started with different command line options for test and automa-
tion purposes. In the following, the command line options which are available for J-Link
Commander are explained. All command line options are case insensitive.
Command Explanation
-AutoConnect Automatically start the target connect sequence
-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
-JTAGConf Sets IRPre and DRPre
-Log Sets logfile path
-RTTTelnetPort Sets the RTT Telnetport
-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
3.2.2.1 -AutoConnect
This command can be used to let J-Link Commander automatically start the connect se-
quence for connecting to the target when entering interactive mode.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
57 CHAPTER 3 J-Link Commander (Command line tool)
Syntax
-autoconnect <1|0>
Example
JLink.exe -autoconnect 1
3.2.2.2 -CommanderScript
Similar to -CommandFile.
3.2.2.3 -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 J-Link Command Files on page 59.
3.2.2.4 -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 List of supported
target devices .
Syntax
-Device <DeviceName>
Example
JLink.exe -Device STM32F103ZE
3.2.2.5 -ExitOnError
Similar to the exitonerror command.
3.2.2.6 -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
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
58 CHAPTER 3 J-Link Commander (Command line tool)
3.2.2.7 -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.8 -JLinkScriptFile
Passes the path of a J-Link script file to the J-Link Commander. J-Link scriptfiles are mainly
used to connect to targets which need a special connection sequence before communication
with the core is possible. For more information about J-Link script files, please refer to J-
Link Script Files .
Syntax
JLink.exe -JLinkScriptFile <File>
Example
JLink.exe -JLinkScriptFile “C:\My Projects\Default.JLinkScript”
3.2.2.9 -JTAGConf
Passes IRPre and DRPre in order to select a specific device in a JTAG-chain. “-1,-1” can be
used to let J-Link select a device automatically.
Syntax
-JTAGConf <IRPre>,<DRPre>
Example
JLink.exe -JTAGConf 4,1
JLink.exe -JTAGConf -1,-1
3.2.2.10 -Log
Set path to LogFilePath allowing the DLL to output logging information. If the logfile already
exists, the contents of the current logfile will be overwritten.
Syntax
-Log <LogFilePath>
Example
JLink.exe -Log C:\Work\log.txt
3.2.2.11 -RTTTelnetPort
This command alters the RTT telnet port. Default is 19021.
Syntax
-RTTTelnetPort <Port>
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
59 CHAPTER 3 J-Link Commander (Command line tool)
Example
JLink.exe -RTTTelnetPort 9100
3.2.2.12 -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.13 -SettingsFile
Select a J-Link settings file to be used for the target device. The settings file can contain
all configurable options of the Settings tab in J-Link Control panel.
Syntax
-SettingsFile <PathToFile>
Example
JLink.exe -SettingsFile “C:\Work\settings.txt”
3.2.2.14 -Speed
Starts J-Link Commander 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. Default interface speed is 100kHz.
Syntax
-Speed <Speed_kHz>
Example
JLink.exe -Speed 4000
3.2.3 Using J-Link Command Files
J-Link commander can also be used in batch mode which allows the user to use J-Link
commander for batch processing and without user interaction. Please do not confuse J-
Link Command Files file with J-Link Script Files (please refer to J-Link Script Files for more
information about J-Link script files). When using J-Link commander 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 -CommandFile C:\CommandFile.jlink
Contents of CommandFile.jlink:
si 1
speed 4000
r
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
60 CHAPTER 3 J-Link Commander (Command line tool)
h
loadbin C:\firmware.bin,0x08000000
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
61 CHAPTER 3 J-Link Remote Server
3.3 J-Link Remote Server
J-Link Remote Server allows using J-Link / J-Trace remotely via TCP/IP. This enables you
to connect to and fully use a J-Link / J-Trace from another computer. Performance is just
slightly (about 10%) lower than with direct USB connection.
J-Link Remote Server
3.3.1 List of available commands
The table below lists the commands line options accepted by the J-Link Remote Server
Command Description
-port Selects the IP port on which the J-Link Remote Server is lis-
tening.
-UseTunnel Starts J-Link Remote Server in tunneling mode
-SelectEmuBySN Selects the J-Link to connect to by its serial number.
3.3.2 Tunneling mode
The Remote server provides a tunneling mode which allows remote connection to a J-Link /
J-Trace from any computer, even from outside the local network.
To give access to a J-Link neither a remote desktop or VPN connection nor changing some
difficult firewall settings is necessary.
When started in tunneling mode the Remote server connects to the SEGGER tunnel server
via port 19020 and registers with its serial number. To connect to the J-Link from the
remote computer an also simple connection to tunnel:<SerialNo> can be established and
the debugger is connected to the J-Link.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
62 CHAPTER 3 J-Link Remote Server
J-Link Remote Server: Connected to SEGGER tunnel server
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. The serial number of the J-Link is then sent to a 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 the desk.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
63 CHAPTER 3 J-Link Remote Server
Start J-Link Remote Server in tunneling mode
Connect to the J-Link / J-Trace via J-Link Commander
J-Link Commander can be used to verify a connection to the J-Link can be established as
follows: Start J-Link Commander
From within J-Link Commander enter
ip tunnel:<SerialNo>
If the connection was successful it should look like in this screenshot.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
64 CHAPTER 3 J-Link Remote Server
Troubleshooting
Problem Solution
Remote server can-
not connect to tun-
nel server.
1. Make sure the Remote server is not blocked by any firewall.
2. Make sure port 19020 is not blocked by any firewall.
3. Contact network admin.
J-Link Commander
cannot connect to
tunnel server.
1. Make sure Remote server is started correctly.
2. Make sure the entered serial number is correct.
3. Make sure port 19020 is not blocked by any firewall. Contact
network admin.
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:
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
65 CHAPTER 3 J-Mem Memory Viewer
3.4 J-Mem Memory Viewer
J-Mem displays memory contents of target systems and allows modifications of RAM and
SFRs (Special Function Registers) while the target is running. This makes it possible to look
into the memory of a target system at run-time; RAM can be modified and SFRs can be
written. You can choose between 8/16/32-bit size for read and write accesses. J-Mem works
nicely when modifying SFRs, especially because it writes the SFR only after the complete
value has been entered.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
66 CHAPTER 3 J-Flash
3.5 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 www.segger.com or contact us directly.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
67 CHAPTER 3 J-Flash Lite
3.6 J-Flash Lite
J-Flash Lite is a flash programming application to program data images to the flash of a
target device. In comparison to J-Flash, J-Flash Lite has a reduced feature set but does not
require a J-Link PLUS or higher to operate. J-Flash Lite is also available for J-Link BASE
and EDU.
3.6.1 Limitations in comparison to J-Flash
No support for external CFI NOR flash
No support for custom Init steps
No support for automation via command line
No project management support (Only the settings from the last session are pre-
selected on startup)
3.6.2 Usage
J-Flash Lite is very simple to use. First, a configuration dialog shows up, in which the target
interface, target device etc. has to be selected. By clicking the O.K. button, the configuration
is applied and the actual main window is shown.
The main window of J-Flash Lite only consists of a few dialog elements that allow program-
ming of the target:
Dialog element Function
“…” button Selects the application image (bin, hex, mot, …) to program
“Erase chip”
button Erases all flash banks of the device
“Program De-
vice” button Programs the selected application image
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
68 CHAPTER 3 J-Flash Lite
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
69 CHAPTER 3 J-Link RTT Viewer
3.7 J-Link RTT Viewer
J-Link RTT Viewer is a Windows GUI application to use all features of RTT in one application.
It supports:
Displaying terminal output of Channel 0.
Up to 16 virtual Terminals on Channel 0.
Sending text input to Channel 0.
Interpreting text control codes for colored text and controlling the Terminal.
Logging terminal data into a file.
Logging data on Channel 1.
For general information about RTT, please refer to RTT on page 335.
3.7.1 RTT Viewer Startup
Make sure J-Link and target device are connected and powered up.
Start RTT Viewer by opening the executable (JLinkRTTViewer.exe) from the installation
folder of the J-Link Software or the start menu. Unless the command line parameter
autoconnect is set, the Configuration Dialog will pop up.
Configure the Connection Settings as described below and click OK. The connection settings
and all in app configuration will be saved for the next start of J-Link RTT Viewer.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
70 CHAPTER 3 J-Link RTT Viewer
3.7.2 Connection Settings
RTT Viewer can be used in two modes:
Stand-alone, opening an own connection to J-Link and target.
In attach mode, connecting to an existing J-Link connection of a debugger.
Stand-alone connection settings
In stand-alone mode RTT Viewer needs to know some settings of J-Link and target device.
Select USB or TCP/IP as the connection to J-Link. For USB a specific J-Link serial number
can optionally be entered, for TCP/IP the IP or hostname of the J-Link has to be entered.
Select the target device to connect to. This allows J-Link to search in the known RAM of
the target.
Select the target interface and its speed. The RTT Control Block can be searched for fully
automatically, it can be set to a fixed address or it can be searched for in one or more
specific memory ranges.
Attaching to a connection
In attach mode RTT Viewer does not need any settings. Select Existing Session. For attach
mode a connection to J-Link has to be opened and configured by another application like a
debugger or simply J-Link Commander. If the RTT Control Block cannot be found automat-
ically, configuration of its location has to be done by the debugger / application.
3.7.3 The Terminal Tabs
RTT Viewer allows displaying the output of Channel 0 in different “virtual” Terminals. The
target application can switch between terminals with SEGGER_RTT_SetTerminal() and SEG-
GER_RTT_TerminalOut(). RTT Viewer displays the Terminals in different tabs.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
71 CHAPTER 3 J-Link RTT Viewer
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 gray.
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 Terminal 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.
3.7.4 Sending Input
RTT Viewer supports sending user input to RTT Down Channel 0 which can be read by the
target application with SEGGER_RTT_GetKey() and SEGGER_RTT_Read().
Input can be entered in the text box below the Terminal Tabs.
RTT Viewer can be configured to directly send each character while typing or buffer it until
Enter is pressed (Menu Input -> Sending…).
In stand-alone mode RTT Viewer can retry to send input, in case the target input buffer is
full, until all data could be sent to the target via Input -> Sending… -> Block if FIFO full.
3.7.5 Logging Terminal output
The output of Channel 0 can be logged into a text file. The format is the same as used in the
All Terminals tab. Terminal Logging can be started via Logging -> Start Terminal Logging…
3.7.6 Logging Data
Additionally to displaying output of Channel 0, RTT Viewer can log data which is sent on
RTT Channel 1 into a file. This can for example be used to sent instrumented event tracing
data. The data log file contains header and footer and the binary data as received from
the application.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
72 CHAPTER 3 J-Link RTT Viewer
Data Logging can be started via Logging -> Start Data Logging…
Note
Data Logging is only available in stand-alone mode.
3.7.7 Command line options
J-Link RTT Viewer can be configured via command line parameters. In the following, the
command line options which are available for J-Link RTT Viewer are explained. All command
line options are case insensitive. Short and long command names have the same syntax.
Command line option Explanation
-d, –device Select the connected target device.
-ct, –connection Sets the connection type
-if, –interface Sets the interface type
-ip, –host The IP address of the J-Link
-s, –speed Interface speed in kHz
-sn, –serialnumber Select the J-Link with a specific S/N
-ra, –rttaddr Sets the address of the RTT control block
-rr, –rttrange Specify RTT search range
-a, –autoconnect Automatically connect to target, suppress settings dialog
3.7.7.1 --device
Selects the device J-Link RTT Viewer shall connect to.
Syntax
–device <DeviceName>
Example
JLinkRTTViewer.exe –device STM32F103ZE
3.7.7.2 --connection
Sets the connection type. The connection to the J-Link can either be made directly over
USB, IP or using an existing running session (e.g. the IDE’s debug session). In case of using
an existing session, no further configuration options are required.
Syntax
–connection <usb|ip|sess>
Example
JLinkRTTViewer.exe –connection ip
3.7.7.3 --interface
Sets the interface J-Link shall use to connect to the target. As interface types FINE, JTAG
and SWD are supported.
Syntax
–interface <fine|jtag|swd>
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
73 CHAPTER 3 J-Link RTT Viewer
Example
JLinkRTTViewer.exe –interface swd
3.7.7.4 --host
Enter the IP address or hostname of the J-Link. This option only applies, if connection type
IP is used. Use * as <IPAddr> for a list of available J-Links in the local subnet.
Syntax
–host <IPAddr>
Example
JLinkRTTViewer.exe –host 192.168.1.17
3.7.7.5 --speed
Sets the interface speed in kHz for target communication.
Syntax
–speed <speed>
Example
JLinkRTTViewer.exe –speed 4000
3.7.7.6 --serialnumber
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 RTT Viewer shall run and each
connects to another J-Link.
Syntax
–serialnumber <SerialNo>
Example
JLinkRTTViewer.exe –serialnumber 580011111
3.7.7.7 --rttaddr
Sets a fixed address as location of the RTT control block. Automatic searching for the RTT
control block is disabled.
Syntax
–rttaddr <RTTCBAddr>
Example
JLinkRTTViewer.exe -rttaddr 0x20000000
3.7.7.8 --rttrange
Sets one or more memory ranges, where the J-Link DLL shall search for the RTT control
block.
Syntax
–rttrange <RangeStart[Hex]> <RangeSize >[, <Range1Start [Hex]> <Range1Size>]>
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
74 CHAPTER 3 J-Link RTT Viewer
Example
JLinkRTTViewer.exe -rttrange “20000000 400”
3.7.7.9 --autoconnect
Let J-Link RTT Viewer connect automatically to the target without showing the Connection
Settings (see Connection Settings ).
Syntax
–autoconnect
Example
JLinkRTTViewer.exe –autoconnect
3.7.8 Menus and Shortcuts
File menu elements
Menu entry Contents Shortcut
-> Connect… Opens the connect dialog and connects to the tar-
gets F2
-> Disconnect Disconnects from the target F3
-> Exit Closes connection and exit RTT Viewer. Alt-F4
Terminals menu elements
Menu entry Contents Shortcut
-> Add next terminal Opens the next available Terminal Tab. Alt-A
-> Clear active terminal Clears the currently selected terminal tab. Alt-R
-> Close active terminal Closes the active Terminal Tab. Alt-W
-> Open Terminal on
output If selected, a terminal is automatically created, if
data for this terminal is received.
-> Show Log Opens or closes the Log Tab. Alt-L
Terminals -> Terminals…
–> Terminal 0 - 15 Opens or closes the Terminal Tab.
Alt-
Shift-0
Alt-
Shift-F
Input menu elements
Menu entry Contents Shortcut
-> Clear input field Clears the input field without sending entered da-
ta. Button
“Clear”
Input -> Sending…
–> Send on Input If selected, entered input will be sent directly to
the target while typing.
–> Send on Enter If selected, entered input will be sent when press-
ing Enter.
–> Block if FIFO full If checked, RTT Viewer will retry to send all input
to the target when the target buffer is full.
Input -> End of line…
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
75 CHAPTER 3 J-Link RTT Viewer
Menu entry Contents Shortcut
–> Windows format (CR
+LF)
–> Unix format (LF)
–> Mac format (CR)
–> None
Selects the end of line character to be sent on En-
ter.
Input -> Echo input…
–> Echo to “All Termi-
nals” If checked, sent input will be displayed in the All
Terminals Tab.
–> Echo to “Terminal 0” If checked, sent input will be displayed in the Ter-
minal Tab 0.
Logging menu elements
Menu entry Contents Shortcut
-> Start Terminal log-
ging… Starts logging terminal data to a file. F5
-> Stop Terminal logging Stops logging terminal data and closes the file. Shift-F5
-> Start Data logging… Starts logging data of Channel 1 to a file. F6
-> Stop Data logging Stops logging data and closes the file. Shift-F6
Help menu elements
Menu entry Contents Shortcut
-> About… Shows version info of RTT Viewer. F12
-> J-Link Manual… Opens the J-Link Manual PDF file. F11
-> RTT Webpage… Opens the RTT webpage. F10
Tab context menu elements
Menu entry Contents Shortcut
-> Close Terminal Closes this Terminal Tab Alt-W
-> Clear Terminal Clears the displayed output of this Terminal Tab. Alt-R
3.7.9 Using "virtual" Terminals in RTT
For virtual Terminals the target application needs only Up Channel 0. This is especially
important on targets with low RAM.
If nothing is configured, all data is sent to Terminal 0.
The Terminal to output all following via Write, WriteString or printf can be set with SEG-
GER_RTT_SetTerminal().
Output of only one string via a specific Terminal can be done with SEGGER_RTT_Termi-
nalOut().
The sequences sent to change the Terminal are interpreted by RTT Viewer. Other applica-
tions like a Telnet Client will ignore them.
3.7.10 Using Text Control Codes
RTT allows using Text Control Codes (ANSI escape codes) to configure the display of text.
RTT Viewer supports changing the text color and background color and can erase the Ter-
minal. These Control Codes are pre-defined in the RTT application and can easily be used
in the application.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
76 CHAPTER 3 J-Link RTT Viewer
Example 1
SEGGER_RTT_WriteString(0,
RTT_CTRL_RESET"Red: " \
RTT_CTRL_TEXT_BRIGHT_RED"This text is red. " \
RTT_CTRL_TEXT_BLACK"" \
RTT_CTRL_BG_BRIGHT_RED"This background is red. " \
RTT_CTRL_RESET"Normal text again."
);
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);
SEGGER_RTT_printf(0, "%sTime: %s%s%.7d\n",
RTT_CTRL_RESET,
RTT_CTRL_BG_BRIGHT_RED,
RTT_CTRL_TEXT_BRIGHT_WHITE,
2222222
);
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
77 CHAPTER 3 J-Link SWO Viewer
3.8 J-Link SWO Viewer
Free-of-charge utility for J-Link. Displays the terminal output of the target using the SWO
pin. The stimulus port(s) from which SWO data is received can be chosen by using the
port checkboxes 0 to 31. Can be used in parallel with a debugger or stand-alone. This is
especially useful when using debuggers which do not come with built-in support for SWO
such as most GDB / GDB+Eclipse based debug environments.
3.8.1 J-Link SWO Viewer CL
Command line-only version of SWO Viewer. All commands available for J-Link SWO Viewer
can be used with J-Link SWO Viewer Cl. Similar to the GUI Version, J-Link SWO Viewer Cl
asks for a device name or CPU clock speed at startup to be able to calculate the correct
SWO speed or to connect to a running J-Link GDB Server.
Using the syntax given below(see List of available command line options ), J-Link SWO
Viewer CL can be directly started with parameters.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
78 CHAPTER 3 J-Link SWO Viewer
3.8.2 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.
Optionally you can select the preferred SWO clock speed from a drop down list. If nothing
is selected for SWO clock speed then the debug probe will calculate the optimal value. To
populate the drop down list the device needs to be selected or CPU clock speed must be
measured once per session.
When running in normal mode J-Link SWO Viewer automatically performs the necessary
initialization to enable SWO output on the target, in GDB Server mode the initialization
has to be done by the debugger. Should you have a target connection already open e.g. a
debug session in your IDE we recommend defining the parameters device name, CPU clock
frequency and SWO clock frequency via CL to avoid connection errors.
3.8.3 List of available command line options
J-Link SWO Viewer can also be controlled from the command line if used in a automated
test environment etc. When passing all necessary information to the utility via command
line, the configuration dialog at startup is suppressed. Minimum information needed by J-
Link SWO Viewer is the device name (to enable CPU frequency auto detection) or the CPU
clock speed. The table below lists the commands accepted by the J-Link SWO View
Command Description
-cpufreq Select the CPU frequency.
-device Select the target device.
-itmmask Selects a set of itm stimulus ports which should be used to
listen to.
-itmport Selects a itm stimulus port which should be used to listen to.
-outputfile Print the output of SWO Viewer to the selected file.
-settingsfile Specify a J-Link settings file.
-swofreq Select the SWO frequency.
-usb Configure connection settings to USB S/N.
3.8.3.1 -cpufreq
Defines the current CPU speed in Hz that 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>
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
79 CHAPTER 3 J-Link SWO Viewer
Example
-cpufreq 96000000
3.8.3.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. For a
list of all supported device names, please refer to:
List of supported target devices
Syntax
-device <DeviceID>
Example
-device STM32F207IG
3.8.3.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.8.3.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.8.3.5 -outputfile
Define a file to which the output of SWO Viewer is printed.
Syntax
-outputfile <PathToFile>
Example
-outputfile “C:\Temp\Output.log”
3.8.3.6 -settingsfile
Select a J-Link settings file to use for the target device.
Syntax
-settingsfile <PathToFile>
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
80 CHAPTER 3 J-Link SWO Viewer
Example
-settingsfile “C:\Temp\Settings.jlink”
3.8.3.7 -swofreq
Defines 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. If the targeted
SWO speed is 6 MHz the command line should look as follows.
Syntax
-swofreq <SWOFreq>
Example
-swofreq 6000000
3.8.3.8 -usb
Configures the connection settings according to defined USB S/N. Usually not necessary to
define if only one debug device is connected to the PC.
Syntax
-usb <S/N>
Example
-usb 01234567
3.8.4 Configure SWO output after device reset
In some situations it might happen that the target application is reset and it is desired to log
the SWO output of the target after reset during the booting process. For such situations, the
target application itself needs to initialize the CPU for SWO output, since the SWO Viewer
is not restarted but continuously running.
Example code for enabling SWO out of the target application
#define ITM_ENA (*(volatile unsigned int*)0xE0000E00) // ITM Enable
#define ITM_TPR (*(volatile unsigned int*)0xE0000E40) // Trace Privilege
// Register
#define ITM_TCR (*(volatile unsigned int*)0xE0000E80) // ITM Trace Control Reg.
#define ITM_LSR (*(volatile unsigned int*)0xE0000FB0) // ITM Lock Status
// Register
#define DHCSR (*(volatile unsigned int*)0xE000EDF0) // Debug register
#define DEMCR (*(volatile unsigned int*)0xE000EDFC) // Debug register
#define TPIU_ACPR (*(volatile unsigned int*)0xE0040010) // Async Clock
// prescaler register
#define TPIU_SPPR (*(volatile unsigned int*)0xE00400F0) // Selected Pin Protocol
// Register
#define DWT_CTRL (*(volatile unsigned int*)0xE0001000) // DWT Control Register
#define FFCR (*(volatile unsigned int*)0xE0040304) // Formatter and flush
// Control Register
U32 _ITMPort = 0; // The stimulus port from which SWO data is received
// and displayed.
U32 TargetDiv = 1; // Has to be calculated according to
// the CPU speed and the output baud rate
static void _EnableSWO() {
U32 StimulusRegs;
//
// Enable access to SWO registers
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
81 CHAPTER 3 J-Link SWO Viewer
//
DEMCR |= (1 << 24);
ITM_LSR = 0xC5ACCE55;
//
// Initially disable ITM and stimulus port
// To make sure that nothing is transferred via SWO
// when changing the SWO prescaler etc.
//
StimulusRegs = ITM_ENA;
StimulusRegs &= ~(1 << _ITMPort);
ITM_ENA = StimulusRegs; // Disable ITM stimulus port
ITM_TCR = 0; // Disable ITM
//
// Initialize SWO (prescaler, etc.)
//
TPIU_SPPR = 0x00000002; // Select NRZ mode
TPIU_ACPR = TargetDiv - 1; // Example: 72/48 = 1,5 MHz
ITM_TPR = 0x00000000;
DWT_CTRL = 0x400003FE;
FFCR = 0x00000100;
//
// Enable ITM and stimulus port
//
ITM_TCR = 0x1000D; // Enable ITM
ITM_ENA = StimulusRegs | (1 << _ITMPort); // Enable ITM stimulus port
}
3.8.5 Target example code for terminal output
/*********************************************************************
* SEGGER Microcontroller GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
----------------------------------------------------------------------
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 guarantee that the
application does not hang.
-------- END-OF-HEADER ---------------------------------------------
*/
/*********************************************************************
*
* 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 Register
#define ITM_TCR (*(volatile unsigned int*)0xE0000E80) // ITM Trace Control
// Register
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
82 CHAPTER 3 J-Link SWO Viewer
/*********************************************************************
*
* 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 character 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++);
}
}
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
83 CHAPTER 3 SWO Analyzer
3.9 SWO Analyzer
SWO Analyzer (SWOAnalyzer.exe) is a tool that analyzes SWO output. Status and summary
of the analysis are output to standard out, the details of the analysis are stored in a file.
Usage
SWOAnalyzer.exe <SWOfile> This can be achieved by simply dragging the SWO output file
created by the J-Link DLL onto the executable.
Creating an SWO output file
In order to create the SWO output file, which is the input file for the SWO Analyzer, the J-
Link config file needs to be modified. It should contain the following lines:
[SWO]
SWOLogFile="C:\TestSWO.dat"
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
84 CHAPTER 3 JTAGLoad (Command line tool)
3.10 JTAGLoad (Command line tool)
JTAGLoad is a tool that can be used to open and execute an svf (Serial vector format) file for
JTAG boundary scan tests. The data in the file will be sent to the target via J-Link / J-Trace.
SVF is a standard format for boundary scan vectors to be used with different tools and
targets. SVF files contain human-readable ASCII SVF statements consisting of an SVF com-
mand, 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
RUNTEST
SDR
SIR
STATE
TDR
TIR
A simple SVF file to read the JTAG ID of the target can look like following:
! Set JTAG frequency
FREQUENCY 12000000HZ;
! Configure scan chain
! For a single device in chain, header and trailer data on DR and IR are 0
! Set TAP to IDLE state
STATE IDLE;
! Configure end state of DR and IR after scan operations
ENDDR IDLE;
ENDIR IDLE;
! Start of test
! 32 bit scan on DR, In: 32 0 bits, Expected out: Device ID (0x0BA00477)
SDR 32 TDI (0) TDO (0BA00477) MASK (0FFFFFFF);
! Set TAP to IDLE state
STATE IDLE;
! End of test
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.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
85 CHAPTER 3 J-Link RDI (Remote Debug Interface)
3.11 J-Link RDI (Remote Debug Interface)
The J-Link RDI software is a remote debug interface for J-Link. It makes it possible to use
J-Link with any RDI compliant debugger. The main part of the software is an RDI-compliant
DLL, which needs to be selected in the debugger. here are two additional features available
which build on the RDI software foundation. Each additional feature requires an RDI license
in addition to its own license. Evaluation licenses are available free of charge. For further
information go to our website or contact us directly.
Note
The RDI software (as well as flash breakpoints and flash downloads) do not require a
license if the target device is an LPC2xxx. In this case the software verifies that the
target device is actually an LPC 2xxx and have a device-based license.
3.11.1 Flash download and flash breakpoints
Flash download and flash breakpoints are supported by J-Link RDI. For more informa-
tion about flash download and flash breakpoints, please refer to J-Link RDI Users Guide
(UM08004) , chapter Flash download and chapter Breakpoints in flash memory .
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
86 CHAPTER 3 Processor specific tools
3.12 Processor specific tools
The J-Link Software and Documentation Package includes some tools which support proces-
sor specific functionalities, like unlocking a device.
3.12.1 J-Link STR91x Commander (Command line tool)
J-Link STR91x Commander (JLinkSTR91x.exe) is a tool that can be used to configure
STR91x cores. It permits some STR9 specific commands like:
Set the configuration register to boot from bank 0 or 1.
Erase flash sectors.
Read and write the OTP sector of the flash.
Write-protect single flash sectors by setting the sector protection bits.
Prevent flash from communicate via JTAG by setting the security bit.
All of the actions performed by the commands, excluding writing the OTP sector and erasing
the flash, can be undone. This tool can be used to erase the flash of the controller even if
a program is in flash which causes the CPU core to stall.
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.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
87 CHAPTER 3 Processor specific tools
Commands
Command Description
fsize
Set the size of the primary flash manually.
Syntax: fsize 0|1|2|3, where 0 selects a 256 Kbytes device,
1 a 512 Kbytes device, 2 a 1024 KBytes device
and 3 a 2048 Kbytes device
showconf Show configuration register content and security status
mem Read memory
Syntax: mem <Addr>, <NumBytes>
erase
Erase flash sectors (OTP can not be erased).
Syntax: erase <SectorMaskL>, <SectorMaskH>
SectorMaskL = Bits 0-%d mask sectors 0-%d of bank 0
SectorMaskH = Bits 0-%d mask sectors 0-%d of bank 1
Bit 17 masks the configuration sector
Bit 18 masks the User-Code sector
All other bits are ignored
erase bank0 Erase flash bank 0
erase bank1 Erase flash bank 1
erase all Perform a full chip erase
setb Boot from flash bank x (0 and 1 are available)
Syntax: setb <int>
setLVDth Set the LVD threshold to 2.7 V.
clrLVDth Set the LVD threshold to 2.4 V.
setLVDreset LVD Reset Out is generated by VDD or VDDQ inputs.
clrLVDreset LVD Reset Out is generated by VDD input only.
setLVDwarn LVD warning is generated by VDD or VDDQ inputs.
clrLVDwarn LVD warning is generated by VDD input only.
blank Blank check all flash sectors
secure Set the security bit. Protects device from read or debug access
through the JTAG port (can only be cleared by a full chip erase).
unsecure Unsecure the device. Content of configuration register is saved.
protect
Protect flash sectors.
Syntax: protect <Bank0SectorMask>, <Bank1SectorMask>
Bank0SectorMask: Bits 0-%d mask flash sectors 0-%d of bank 0
Bank1SectorMask: Bits 0-%d mask flash sectors 0-%d of bank 1
unprotect
Unprotect flash sectors.
Syntax: unprotect <Bank0SectorMask>, <Bank1SectorMask>
Bank0SectorMask: Bits 0-%d mask flash sectors 0-%d of bank 0
Bank1SectorMask: Bits 0-%d mask flash sectors 0-%d of bank 1
readotp Read OTP sectors
writeotp Write words to the OTP sectors.
Syntax: writeotp <Word1>, [<Word2>, …, <Word8>]
q Quit
Command line options
J-Link STR91x Commander can be started with different command line options for test and
automation purposes. In the following, the command line options which are available for
J-Link Commander are explained. All command line options are case insensitive.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
88 CHAPTER 3 Processor specific tools
Command Explanation
-CommanderScript Passes a CommandFile to J-Link
-CommandFile Passes a CommandFile to J-Link
-IP Selects IP as host interface
-SelectEmuBySN Connects to a J-Link with a specific S/N over USB
-IRPre Scan-Chain Configuration
-IRPost Scan-Chain Configuration
-DRPre Scan-Chain Configuration
-DRPost Scan-Chain Configuration
3.12.1.1 -CommanderScript
Similar to -CommandFile .
3.12.1.2 -CommandFile
Selects a command file and starts J-Link STR91x Commander in batch mode. The batch
mode of J-Link STR91x Commander is similar to the execution of a batch file. The command
file is parsed line by line and one command is executed at a time.
Syntax
-CommandFile <CommandFilePath>
Example
See Using J-Link Command Files .
3.12.1.3 -DRPre, -DRPost, -IRPre and -IRPost (Scan-Chain Configura-
tion )
STR91x allows to configure a specific scan-chain via command-line. To use this feature four
command line options have to be specified in order to allow a proper connection to the prop-
er device. In case of passing an incomplete configuration, the utility tries to auto-detect.
Syntax
-DRPre <DRPre>
-DRPost <DRPost>
-IRPre <IRPre>
-IRPost <IRPost>
Example
JLinkSTR91x.exe -DRPre 1 -DRPost 4 -IRPre 16 -IRPost 20
3.12.1.4 -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> .
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
89 CHAPTER 3 Processor specific tools
3.12.1.5 -SelectEmuBySN
Connect to a J-Link with a specific serial number via USB. Useful if multiple J-Links are
connected to the same PC and multiple instances of J-Link Commander shall run and each
connects to another J-Link.
Syntax
-SelectEmuBySN <SerialNo>
Example
JLinkSTR91x.exe -SelectEmuBySN 580011111
3.12.2 J-Link STM32 Unlock (Command line tool)
J-Link STM32 Unlock (JLinkSTM32.exe) is a free command line tool which can be used
to disable the hardware watchdog of STM32 devices which can be activated by program-
ming the option bytes. Moreover the J-Link STM32 Commander unsecures a read-protected
STM32 device by re-programming the option bytes.
Note
Unprotecting a secured device or will cause a mass erase of the flash memory.
Command Line Options
Command line option Explanation
-IP Selects IP as host interface to connect to J-Link. Default host
interface is USB.
-SelectEmuBySN Connects to a J-Link with a specific S/N over USB
-Speed Starts the J-Link STM32 Unlock Utility with a given initial in-
terface speed.
-SetPowerTarget Enables target power supply via pin 19.
-SetDeviceFamily Specifies a device family
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
90 CHAPTER 3 Processor specific tools
Command line option Explanation
-Exit J-Link STM32 Unlock will close automatically
3.12.2.1 -IP
Selects IP as host interface to connect to J-Link. Default host interface is USB.
Syntax
-IP <IPAddr>
Example
JLinkSTM32.exe -IP 192.168.1.17
Note
To select from a list of all available emulators on Ethernet, please use * as <IPAddr>.
3.12.2.2 -SelectEmuBySN
Connect to a J-Link with a specific serial number via USB. Useful if multiple J-Links are
connected to the same PC.
Syntax
-SelectEmuBySN <SerialNo>
Example
JLinkSTM32.exe -SelectEmuBySN 580011111
3.12.2.3 -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 recommended 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>
Example
-Speed 1000
3.12.2.4 -SetPowerTarget
The connected debug probe will power the target via pin 19 of the debug connector.
Syntax
-SetPowerTarget <Mode>
Example
JLinkSTM32.exe -SetPowerTarget 1 // Target power will be set
3.12.2.5 -SetDeviceFamily
This command allows to specify a device family, so that no user input is required to start
the unlocking process.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
91 CHAPTER 3 Processor specific tools
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 families on start up
b) Pass the defined device name
ID Device
1 STM32F0xxxx
2 STM32F1xxxx
3 STM32F2xxxx
4 STM32F3xxxx
5 STM32F4xxxx
6 STM32F72_F73xxx
7 STM32F74_F75xxx
8 STM32F76_F77xxx
9 STM32L0xxxx
10 STM32L1xxxx
11 STM32L4x6xx
Example
JLinkSTM32.exe -SetDeviceFamily 10 // Selects STM32L1 series
JLinkSTM32.exe -SetDeviceFamily STM32F2xxxx // Selects STM32F2 series
3.12.2.6 -Exit
In general, the J-Link STM32 utility waits at the end of the unlock process for any user
input before application closes. This option allows to skip this step, so that the utility closes
automatically.
Syntax
-Exit <Mode>
Example
JLinkSTM32.exe -Exit 1 // J-Link STM32 utility closes automatically
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
92 CHAPTER 3 J-Link Software Developer Kit (SDK)
3.13 J-Link Software Developer Kit (SDK)
The J-Link Software Developer Kit is needed if you want to write your own program with J-
Link / J-Trace. The J-Link DLL is a standard Windows DLL typically used from C programs
(Visual Basic or Delphi projects are also possible). It makes the entire functionality of J-
Link / J-Trace available through its exported functions, such as halting/stepping the CPU
core, reading/writing CPU and ICE registers and reading/writing memory. Therefore it can
be used in any kind of application accessing a CPU core. The standard DLL does not have
API functions for flash programming. However, the functionality offered can be used to
program flash. In this case, a flash loader is required. The table below lists some of the
included files and their respective purpose.
Further information can be found on the SEGGER website:
J-Link SDK
The J-Link SDK requires an additional license and is available upon request from www.seg-
ger.com .
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
Chapter 4
J-Link GDB Server
The GNU Project Debugger (GDB) is a freely available and open source debugger. It can
be used in command line mode, but is also integrated in many IDEs like emIDE or Eclipse.
J-Link GDB Server is a remote server for GDB making it possible for GDB to connect to and
communicate with the target device via J-Link. GDB Server and GDB communicate via a
TCP/IP connection, using the standard GDB remote protocol. GDB Server receives the GDB
commands, does the J-Link communication and replies with the answer to GDB.
With J-Link GDB Server debugging in ROM and Flash of the target device is possible and the
Unlimited Flash Breakpoints can be used. It also comes with some functionality not directly
implemented in the GDB. These can be accessed via monitor commands, sent directly via
GDB, too.
J-Link GDB Server
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
94 CHAPTER 4
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/
J-Link GDB Server is distributed free of charge.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
95 CHAPTER 4 J-Link GDB Server CL (Windows, Linux, Mac)
4.1 J-Link GDB Server CL (Windows, Linux, Mac)
J-Link GDB Server CL is a commandline-only version of the GDB Server. The command
line version is part of the Software and Documentation Package and also included in the
Linux and MAC versions.
Except for the missing GUI, J-Link GDB Server CL is identical to the normal version. All
sub-chapters apply to the command line version, too.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
96 CHAPTER 4 Debugging with J-Link GDB Server
4.2 Debugging with J-Link GDB Server
With J-Link GDB Server programs can be debugged via GDB directly on the target device
like a normal application. The application can be loaded into RAM or flash of the device.
Before starting GDB Server make sure a J-Link and the target device are connected.
4.2.1 Setting up GDB Server GUI version
The GUI version of GDB Server is part of the Windows J-Link Software Package
(JLinkGDBServer.exe).
When starting GDB Server a configuration dialog pops up, letting you select the needed
configurations to connect to J-Link and the target.
J-Link GDB Server: Configuration
All configurations can optionally be given in the command line options.
Note
To make sure the connection to the target device can be established correctly, the
device, as well as the interface and interface speed have to be given on start of GDB
Server, either via command line options or the configuration dialog. If the target device
option (-device) is given, the configuration dialog will not pop up.
4.2.2 Setting up GDB Server CL version
The command line version of GDB Server is part of the J-Link Software Package for all
supported platforms. On Windows its name is JLinkGDBServerCL.exe, on Linux and Mac
it is JLinkGDBServer.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
97 CHAPTER 4 Debugging with J-Link GDB Server
Starting GDB Server on Windows
To start GDB Server CL on Windows, open the ’Run’ prompt (Windows-R) or a command
terminal (cmd) and enter
<PathToJLinkSoftware>\JLinkGDBServerCL.exe <CommandLineOptions>.
Starting GDB Server on Linux / Mac
To start GDB Server CL on Linux / Mac, open a terminal and call JLinkGDBServer <Com-
mandLineOptions>
Command Line Options
When using GDB Server CL, at least the mandatory command line options have to be
given. Additional command line options can be given to change the default behavior of GDB
Server. For more information about the available command line options, please refer to
Command line options .
4.2.3 GDB Server user interface
The J-Link GDB Server’s user interface shows information about the debugging process and
the target and allows to configure some settings during execution.
J-Link GDB Server: UI
It shows following information:
The IP address of host running debugger.
Connection status of J-Link.
Information about the target core.
Measured target voltage.
Bytes that have been downloaded.
Status of target.
Log output of the GDB Server (optional, if Show log window is checked).
Initial and current target interface speed.
Target endianness.
These configurations can be made from inside GDB Server:
Localhost only: If checked only connections from 127.0.0.1 are accepted.
Stay on top
Show log window.
Generate logfile: If checked, a log file with the GDB <-> GDB Server <-> J-Link
communication will be created.
Verify download: If checked, the memory on the target will be verified after download.
Init regs on start: If checked, the register values of the target will be set to a reasonable
value before on start of GDB Server.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
98 CHAPTER 4 Debugging with J-Link GDB Server
4.2.4 Running GDB from different programs
We assume that you already have a solid knowledge of the software tools used
for building your application (assembler, linker, C compiler) and especially the
debugger and the debugger frontend of your choice. We do not answer questions
about how to install and use the chosen toolchain.
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, endianness and speed and enter the additional GDB start
commands. The typically required GDB commands are:
#Initially reset the target
monitor reset
#Load the application
load
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 information
about emIDE, please refer to http://emide.org .
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
99 CHAPTER 4 Debugging with J-Link GDB Server
Console
GDB can be used stand-alone as a console application.
To connect GDB to GDB Server enter target remote localhost:2331 into the running
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:
(gdb) file C:/temp/Blinky.elf
Reading symbols from C:/temp/Blinky.elf...done.
(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0x00000000 in ?? ()
(gdb) monitor reset
Resetting target
(gdb) load
Loading section .isr_vector, size 0x188 lma 0x8000000
Loading section .text, size 0x568 lma 0x8000188
Loading section .init_array, size 0x8 lma 0x80006f0
Loading section .fini_array, size 0x4 lma 0x80006f8
Loading section .data, size 0x428 lma 0x80006fc
Start address 0x8000485, load size 2852
Transfer rate: 146 KB/sec, 570 bytes/write.
(gdb) break main
Breakpoint 1 at 0x800037a: file Src\main.c, line 38.
(gdb) continue
Continuing.
Breakpoint 1, main () at Src\main.c:38
38 Cnt = 0;
(gdb)
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH
100 CHAPTER 4 Debugging with J-Link GDB Server
Eclipse (CDT)
Eclipse is an open source platform-independent software framework, which has typically
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.e-
clipse.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.
J-Link / J-Trace (UM08001) © 2004-2018 SEGGER Microcontroller GmbH