JLink ARM
JLink ARM
JLink ARM
User Guide
Document: UM08001
Software Version: 6.44
Revision: 2
Date: April 25, 2019
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-2019 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
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: April 25, 2019
Manual
Revision Date By Description
version
Chapter “Target interfaces and adapters”
6.44 4 190424 AG * Section “20-pin J-Link connector”: Corrected information for pins 14, 16,
18, 20.
Chapter “J-Link software and documentation pacakge”
6.44 3 190415 LG * Updated J-Mem screenshot.
Added Chapter “J-Mem”
Chapter “Target interfaces and adapters”
6.44 2 190408 NV
* Added diagram showing J-Trace PRO connection with target device.
Chapter “J-Link software and documentation package”
6.44 1 190321 EL
* Section “J-Link GDB Server”: Command line options corrected.
Chapter “J-Link software and documentation package”
6.44 0 190306 NV * Section “J-Link Commander”: Added memory zone example for com-
mand “mem”.
Chapter “Working with J-Link and J-Trace”
* Section “J-Link Script Files”: Added new Scripting functions for ETB ini-
tialization.
6.42 0 190215 NV
Chapter “Working with J-Link and J-Trace”
* Section “J-Link Command Strings”: Expanded “map region” documenta-
tion.
Chapter “J-Link software and documentation package”
6.40 1 181217 SI * Section “ J-Link SWO Viewer: Added description of command line option
”-usb“”.
Chapter “ARM SWD specifics” added
6.40 0 181120 AG Chapter “ARM SWD specifics”
* Section “SWD multi-drop” added
Chapter “J-Link software and documentation package”
6.34 10 181025 NV
* Section “J-Link SWO Viewer”: Updated description and pictures.
Chapter “Working with J-Link and J-Trace”
6.34 9 181023 NV * Section “J-Link Command Strings”: Added new J-Link command string
“RTTTelnetAllowNonLocalClient”.
Chapter “Target interfaces and adapters”
6.34 8 101018 AG * Section “19-pin JTAG/SWD and Trace connector”: Added information
about pitch of connector.
Chapter “J-Link Commander”
6.34 7 180906 SI
* Section “ Commands: Added description of ”VTREF“.
Chapter ”Working with J-Link and J-Trace“
6.34 6 180905 NV * Section ”J-Link Script files“: Added new Script file functions to replace
generic trace module initializations.
Chapter ”J-Link GDB Server“
6.34 5 180816 LG * Section ”Supported remote (monitor) commands“: Added new monitor
command ”flash erase“.
Chapter ”J-Link software and documentation package“
6.34 4 180704 AG
* Section ”J-Flash Lite“ added.
Chapter ”J-Link software and documentation package“
6.34 3 180524 LG * Section ”J-Link Commander (Command line tool)“: Added new command
line option ”-Log“.
Chapter ”Open Flashloader“
6.34 2 180517 LG * Section ”XML Tags and Attributes“: Added new <ChipInfo> attribute
”Aliases“.
Chapter ”J-Link software and documentation package“
6.34 1 180516 NV
* Section ”J-Link SWO Viewer“: Refined CL option descriptions.
Chapter ”Working with J-Link and J-Trace“
6.34 0 180511 AG * Section ”J-Link Command Strings“: Added new J-Link command string
”SetEnableMemCache“.
Manual
Revision Date By Description
version
Chapter ”Environmental Conditions & Safety“ added
Chapter ”J-Flash SPI“
* Section ”Command Line Interface“: Updated description of CL option -
6.32 4 180417 NV jflashlog.
* Section ”Command Line Interface“: Updated description of CL option -
jlinklog.
Chapter ”Working with J-Link and J-Trace“
6.32 3 180409 NV * Section ”Script file API functions“: Added new API functions
”JLINK_MEM_Preserve()“, ”JLINK_MEM_Restore()“, ”JLINK_MEM_Fill()“.
Chapter ”Working with J-Link and J-Trace“
6.32 2 180327 LG * Section ”J-Link Command Strings“: Added new J-Link command string
”MemPreserveOnReset“.
Moved contents of chapter ”Segger-specific GDB protocol extensions“ to
6.32 1 180327 AG
separate manual (UM08036)
Moved J-Link GDB Server to separate chapter
Added Segger specific GDB protocol extension qSeggerSTRACE:caps
6.32 0 180323 AG
Added Segger specific GDB protocol extension qSeggerSTRACE:GetInstS-
tats
Chapter ”Working with J-Link and J-Trace“
6.30 2 180314 AG * Section ”J-Link Command Strings“: Added new J-Link command string
”SetAllowStopMode“.
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Script Files“:
Added new function SWO_EnableTarget();.
6.30 1 180309 NV
* Section ”J-Link Script Files“:
Renamed function GetSWOBaseClock() to SWO_GetSWOBaseClock();
Added unit information of clock speed value.
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Script Files“:
6.30 0 180206 EL Added new function: HandleBeforeFlashProg();
* Section ”J-Link Script Files“:
Added new function HandleAfterFlashProg();
Chapter ”Working with J-Link and J-Trace“
6.24 1 180124 EL
* Section ”J-Link Comamnd Strings“: Updated.
Chapter ”J-Link software and documentation package“
6.24 0 180111 LG * Section ”J-Link GDB Server“: Added new GDBServer monitor commands:
ReadAP, ReadDP, WriteAP and WriteDP.
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.
6.22 0 171214 NV
* 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.
Chapter ”Related Software“
* Section ”JTAGLoad“: PIO commands was listed as supported even though
6.20 8 171123 AG it is not. Fixed.
* Section ”JTAGLoad“: PIOMAP commands was listed as supported even
though it is not. Fixed.
Chapter ”Monitor Mode Debugging“
6.20 7 171025 EL
* Section ”Enable Monitor Debugging“: Updated
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link script files“: Updated
6.20 6 171013 EL
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link Command Strings“: Updated
Updated links to SEGGER wiki:
Low power mode debugging
6.20 5 171011 NG
J-Link script files
J-Link Command Strings
Chapter ”Working with J-Link and J-Trace“
* Section ”Script file API functions“: Added the following functions:
6.20 4 171011 NG
JLINK_C2_WriteData()
JLINK_C2_ReadData()
Manual
Revision Date By Description
version
JLINK_C2_WriteAddr()
JLINK_C2_ReadAddr()
JLINK_CORESIGHT_ReadDAP()
JLINK_GetPinState()
JLINK_GetTime()
JLINK_JTAG_ReadWriteBits()
JLINK_JTAG_StartDR()
JLINK_PIN_Override()
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()
Chapter ”Working with J-Link and J-Trace“
6.20 3 171006 NG * Section ”Script file API functions“: Added return values for various func-
tions
Chapter ”Open Flashloader“
6.20 2 171005 EL
* Section ”Add. Info / Considerations / Limitations“: Updated
Chapter ”Working with J-Link and J-Trace“
6.20 1 170922 NG * Section ”J-Link Command Strings“: Updated
Added new command string ”EnableLowPowerHandlingMode“
Chapter ”Open Flashloader“
6.16 0 170320 EL
Added ”AlwaysPresent“ as new attribute to the <FlashBankInfo>
Chapter ”Working with J-Link and J-Trace“
6.14 6 170407 NV * Section ”J-Link scriptfiles“: Updated
”JLINK_ExecCommand()“ description
Chapter ”J-Flash SPI“
6.14 5 170320 EL
Updated screenshots
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link scriptfiles“:
6.14 4 170317 NV
Added: ”JLINK_ExecCommand()“
Section ”Keil MDK-ARM“ added for Command string execution
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link scriptfiles“:
6.14 3 170220 NV Added: ”OnTraceStart()“ and ”JLINK_TRACE_Portwidth“
Chapter ”Trace“
* Added crossreference to ”JLINK_TRACE_Portwidth“
Chapter ”Introduction“
*Added Subsubsection ”Software and Hardware
Features Overview“ to all device Subsections.
6.14 2 170216 NV
*Edited Subsection ”“J-Trace ARM.
*Section ”Target interfaces and adapters“:
edited ”RESET“ to ”nRESET“ and updated description.
Chapter ”Working with J-Link and J-Trace“
* Section ”Exec Commands“: Updated
SetResetPulseLen
6.14 1 170210 NV
TraceSampleAdjust
Chapter ”Trace“
* Section ”Tracing via trace pins“: Updated
Chapter ”Working with J-Link“
* Section ”Exec Commands“: Updated
SelectTraceSource
6.14 0 170201 AG
SetRAWTRACEPinDelay
ReadIntoTraceCache
Chapter ”Trace“ added.
Chapter ”Working With J-Link“
6.10a 0 160820 EL
* Section ”Exec Commands“: Updated ExcludeFlashCacheRanges.
Chapter ”Introduction“
6.00i 0 160802 EL * Removed ”Model Feature Lists“
Chapter ”Adding Support for New Devices“:
Manual
Revision Date By Description
version
renamed to ”Open Flash Loader“
Chapter ”Open Flash Loader“ updated.
Chapter ”J-Flash SPI“
6.00 1 160617 EL
* Added chapter ”Custom Command Sequences“
6.00 0 160519 AG Chapter ”Adding Support for New Devices“ added.
Chapter ”Related Software“
5.12f 0 160503 AB
* Section ”J-Link RTT Viewer“ updated and moved from section ”RTT“.
Chapter ”Working with J-Link and J-Trace“
5.12d 1 160427 AG
* Section ”J-Link script files“ updated.
Chapter ”Working with J-Link and J-Trace“
5.12d 0 160425 AG
* Section ”J-Link script files“ updated.
Chapter ”Related Software“
5.12c 0 160413 NG * Section ”J-Link Commander“
Typo fixed.
Chapter ”Related Software“
* Section ”J-Link Commander“
Commands and commandline options added.
Chapter ”Working with J-Link and J-Trace“
5.12c 1 160418 NG * Section ”J-Link Command Strings“
Command ”SetRTTTelnetPort“ added.
Chapter ”Flash Download“
* Section ”Debugging applications that change flash contents at runtime“
added.
Chapter ”Monitor Mode Debugging“
5.10u 0 160317 AG
* Section ”Target application performs reset“ added.
Chapter ”Monitor Mode Debugging“
5.10t 0 160314 AG * Section ”Enable Monitor Debugging“ updated.
* Section ”Forwarding of Monitor Interrupts“ added.
5.10 3 160309 EL Chapter ”J-Flash SPI“ updated.
Manual
Revision Date By Description
version
* Section ”Setup for various debuggers (SPIFI flash)“ added.
Chapter ”Introduction“
* Section ”J-Link / J-Trace models“ updated.
5.02c 0 150914 RH
* Section ”Supported OS“
Added Windows 10
5.02a 0 150903 AG Chapter ”Monitor Mode Debugging“ added.
Chapter ”Working with J-Link and J-Trace“
5.02 0 150820 AG * Section ”J-Link Command Strings“
”DisableCortexMXPSRAutoCorrectTBit“ added.
5.02 0 150813 AG Chapter ”Monitor Mode Debugging“ added.
Chapter ”Related Software“
5.00 1 150728 NG * Section ”J-Link Commander“
Sub-Section ”Command line options“ updated.
Chapter ”Flash download“
* Section ”QSPI flash support“ added.
5.00 0 150609 AG
Chapter ”Flash breakpoints“
* Section ”Flash Breakpoints in QSPI flash“ added
Chapter ”J-Flash SPI“
5.00 0 150520 EL
* Initial version added
Chapter ”Related Software“
4.99b 0 150520 EL * Section ”J-Link STM32 Unlock“
Added command line options
Chapter ”Target interfaces and Adapters“
4.99a 0 150429 AG
Chapter ”20-pin J-Link connector“, section ”Pinout for SPI“ added.
Chapter ”Related Software“
4.98d 0 150427 EL
* Section ”Configure SWO output after device reset“ updated.
Chapter ”Licensing“
4.98b 0 150410 AG
* Section ”J-Trace for Cortex-M“ updated.
Chapter ”Related Software“
* Section ”J-Link Commander“
4.98 0 150320 NG Sub-Section ”Commands“ added.
Chapter ”Working with J-Link and J-Trace“
* Section ”J-Link script files“ updated
Chapter ”Related Software“
4.96f 0 150204 JL * Section ”GDB Server“
Exit code description added.
Chapter ”RTT“ added.
Chapter ”Related Software“
4.96 0 141219 JL * Section ”GDB Server“
Command line option ”-strict“ added.
Command line option ”-timeout“ added.
Chapter ”Related Software“
4.90d 0 141112 NG * Section ”J-Link Remote Server“ updated.
* Section ”J-Scope“ updated.
Chapter ”Related Software“
4.90c 0 140924 JL
* Section ”JTAGLoad“ updated.
Chapter ”Working with J-Link and J-Trace“
* Section ”Connecting multiple J-Links / J-Traces to your PC“ updated
4.90b 1 140813 EL
Chapter ”J-Link software“
* Section ”J-Link Configurator“ updated.
Chapter ”Related Software“
4.90b 0 140813 NG
* Section ”J-Scope“ added.
Chapter ”Device specifics“
4.86 2 140606 AG
* Section ”Silicon Labs - EFM32 series devices“ added
Chapter ”Related Software“
* Section ”GDB Server“
4.86 1 140527 JL
Command line options -halt / -nohalt added.
Description for GDB Server CL version added.
Chapter ”Flash download“
4.86 0 140519 AG
Section ”Mentor Sourcery CodeBench“ added.
4.84 0 140321 EL Chapter ”Working with J-Link“
Manual
Revision Date By Description
version
* Section ”Virtual COM Port (VCOM) improved.
Chapter “Target interfaces and adapters”
* Section “Pinout for SWD + Virtual COM Port (VCOM) added.”
Chapter “Related Software”
* Section “Command line options”
Extended command line option -speed.
Chapter “J-Link software and documentation package”
* Section “J-Link STR91x Commander”
4.82 1 140228 EL 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“
Chapter ”Related Software“
4.82 0 140218 JL * Section ”GDB Server“
Command line option -notimeout added.
Chapter ”Related Software“
4.80f 0 140204 JL * Section ”GDB Server“
Command line options and remote commands added.
Chapter ”Related Software“
JL/ * Section ”GDB Server“
4.80 1 131219
NG Remote commands and command line options description improved.
Several corrections.
Chapter ”Related Software“
4.80 0 131105 JL * Section ”GDB Server“
SEGGER-specific GDB protocol extensions added.
Chapter ”Flash Download“
* Replaced references to GDB Server manual.
4.76 3 130823 JL
Chapter ”Working with J-Link“
* Replaced references to GDB Server manual.
Chapter ”Related Software“
4.76 2 130821 JL * Section ”GDB Server“
Remote commands added.
Chapter ”Related Software“
4.76 1 130819 JL * Section ”SWO Viewer“
Sample code updated.
Chapter ”Related Software“
* Sections reordered and updated.
4.76 0 130809 JL
Chapter ”Setup“
* Section ”Using JLinkARM.dll moved here.
Chapter “Related Software”
4.71b 0 130507 JL * Section “SWO Viewer”
Added new command line options.
Chapter “Introduction”
4.66 0 130221 JL * Section “Supported OS”
Added Linux and Mac OSX
Chapter “Introduction”
4.62b 0 130219 EL * Section “J-Link / J-Trace models”
Clock rise and fall times updated.
Chapter “Introduction”
4.62 0 130129 JL * Section “J-Link / J-Trace models”
Sub-section “J-link ULTRA” updated.
Chapter “Target interfaces and adapters”
4.62 0 130124 EL * Section “9-pin JTAG/SWD connector”
Pinout description corrected.
Chapter “Introduction”
4.58 1 121206 AG
* Section “J-Link / J-Trace models” updated.
Chapter “Working with J-Link”
4.58 0 121126 JL * Section “J-Link script files”
Sub-section “Executing J-Link script files” updated.
Chapter “Related Software”
4.56b 0 121112 JL * Section “J-Link SWO Viewer”
Added sub-section “Configure SWO output after device reset”
Manual
Revision Date By Description
version
Chapter “Related Software”
* Section “J-Link Commander”
4.56a 0 121106 JL
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”
Chapter “Related Software”
4.54 1 121009 JL
* Section “TCP/IP Server”, subsection “Tunneling Mode” added.
Chapter “Flash Breakpoints”
* Section “Licensing” updated.
4.54 0 120913 EL
Chapter “Device specifics”
* Section “Freescale”, subsection “Data flash support” added.
Chapter “Licensing”
4.53c 0 120904 EL
* Section “Device-based license” updated.
Chapter “Flash download”
* Section “J-Link commander” updated.
Chapter “Support and FAQs”
4.51h 0 120717 EL
* Section “Frequently asked questions” updated.
Chapter “J-Link and J-Trace related software”
* Section “J-Link Commander” updated.
Chapter “Working with J-Link”
4.51e 1 120704 EL
* Section “Reset strategies” updated and corrected. Added reset type 8.
Chapter “Device specifics”
4.51e 0 120704 AG
* Section “ST” updated and corrected.
Chapter “J-Link and J-Trace related software”
4.51b 0 120611 EL
* Section “SWO Viewer” added.
Chapter “Device specifics”
* Section “ST”, subsection “ETM init” for some STM32 devices added.
4.51a 0 120606 EL * Section “Texas Instruments” updated.
Chapter “Target interfaces and adapters”
* Section “Pinout for SWD” updated.
Chapter “Device specifics”
4.47a 0 120419 AG
* Section “Texas Instruments” updated.
4.46 0 120416 EL Chapter “Support” updated.
Chapter “Working with J-Link”
4.42 0 120214 EL
* Section “J-Link script files” updated.
Chapter “Flash download” added.
Chapter “Flash breakpoints” added.
Chapter “Target interfaces and adapters”
4.36 1 110927 EL * Section “20-pin JTAG/SWD connector” updated.
Chapter “RDI” added.
Chapter “Setup” updated.
Chapter “Device specifics” updated.
Chapter “Working with J-Link”
4.36 0 110909 AG
* Section “J-Link script files” updated.
Chapter “Introduction”
4.26 1 110513 KN
* Section “J-Link / J-Trace models” corrected.
4.26 0 110427 KN Several corrections.
Chapter “Introduction”
* Section “J-Link / J-Trace models” corrected.
4.24 1 110228 AG
Chapter “Device specifics”
* Section “ST Microelectronics” updated.
Chapter “Device specifics”
* Section “Samsung” added.
Chapter “Working with J-Link”
4.24 0 110216 AG
* Section “Reset strategies” updated.
Chapter “Target interfaces and adapters”
* Section “9-pin JTAG/SWD connector” added.
Chapter “J-Link and J-Trace related software”
* Section “J-Link software and documentation package in detail” updated.
4.23d 0 110202 AG
Chapter “Introduction”
* Section “Built-in intelligence for supported CPU-cores” added.
Manual
Revision Date By Description
version
Chapter “Working with J-Link”
* Section “Reset strategies” updated.
Chapter “Device specifics”
4.21g 0 101130 AG * Section “Freescale” updated.
Chapter “Flash download and flash breakpoints
* Section ”Supported devices“ updated
* Section ”Setup for different debuggers (CFI flash)“ updated.
Chapter ”Device specifics“
4.21 0 101025 AG
* Section ”Freescale“ updated.
Chapter ”Working with J-Link“
4.20j 0 101019 AG
* Section ”Reset strategies“ updated.
Chapter ”Working with J-Link“
4.20b 0 100923 AG
* Section ”Reset strategies“ updated.
Chapter ”Working with J-Link“
* Section ”J-Link script files“ updated.
* Section ”J-Link Command Strings“ updated.
0.00 90 100818 AG 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.
Chapter ”J-Link and J-Trace related software“
0.00 88 100622 AG
* Section ”SWO Analyzer“ added.
0.00 87 100617 AG Several corrections.
Chapter ”Introduction“
* Section ”J-Link / J-Trace models“ updated.
0.00 86 100504 AG
Chapter ”Target interfaces and adapters“
* Section ”Adapters“ updated.
Chapter ”Introduction“
0.00 85 100428 AG
* Section ”J-Link / J-Trace models“ updated.
Chapter ”Working with J-Link and J-Trace“
* Several corrections
0.00 84 100324 KN
Chapter Flash download & flash breakpoints
* Section ”Supported devices“ updated
Chapter ”Introduction“
0.00 83 100223 KN
* Section ”J-Link / J-Trace models“ updated.
Chapter ”Working with J-Link“
0.00 82 100215 AG
* Section ”J-Link script files“ added.
Chapter ”Device Specifics“
* Section ”Luminary Micro“ updated.
0.00 81 100202 KN
Chapter ”Flash download and flash breakpoints“
* Section ”Supported devices“ updated.
Chapter ”Flash download and flash breakpoints
0.00 80 100104 KN
* Section “Supported devices” updated
Chapter “Working with J-Link and J-Trace”
* Section “Reset strategies” updated.
0.00 79 091201 AG
Chapter “Licensing”
* Section “J-Link OEM versions” updated.
Chapter “Licensing”
0.00 78 091023 AG
* Section “J-Link OEM versions” updated.
Chapter “Introduction”
0.00 77 090910 AG
* Section “J-Link / J-Trace models” updated.
Chapter “Introduction”
* Section“ Specifications” updated
* Section “Hardware versions” updated
0.00 76 090828 KN
* Section “Common features of the J-Link product family” updated
Chapter “Target interfaces and adapters”
* Section “5 Volt adapter” updated
Chapter “Introduction”
* Section “J-Link / J-Trace models” updated.
0.00 75 090729 AG
Chapter “Working with J-Link and J-Trace”
* Section “SWD interface” updated.
Manual
Revision Date By Description
version
Chapter “Introduction”
* Section “Supported IDEs” added
* Section “Supported CPU cores” updated
0.00 74 090722 KN
* Section “Model comparison chart” renamed to
“Model comparison”
* Section “J-Link bundle comparison chart” removed
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
0.00 73 090701 KN
Chapter “Hardware” renamed to “Target interfaces & adapters”
* Section “JTAG Isolator” added
Chapter “Target interfaces and adapters”
* Section “Target board design” updated
Several corrections
Chapter “Working with J-Link”
* Section “J-Link control panel” updated.
Chapter “Flash download and flash breakpoints”
0.00 72 090618 AG
* Section “Supported devices” updated.
Chapter “Device specifics”
* Section “NXP” updated.
Chapter “Device specifics”
0.00 71 090616 AG
* Section “NXP” updated.
Chapter “Introduction”
0.00 70 090605 AG * Section “Common features of the J-Link
product family” updated.
Chapter “Working with J-Link”
* Section “Reset strategies” updated.
0.00 69 090515 AG * Section “Indicators” updated.
Chapter “Flash download and flash breakpoints”
* Section “Supported devices” updated.
Chapter “J-Link and J-Trace related software”
* Section “J-Link STM32 Commander” added.
0.00 68 090428 AG
Chapter “Working with J-Link”
* Section “Reset strategies” updated.
Chapter “Working with J-Link”
0.00 67 090402 AG
* Section “Reset strategies” updated.
Chapter “Background information”
* Section “Embedded Trace Macrocell (ETM)” updated.
0.00 66 090327 AG
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.
Chapter “Working with J-Link”
0.00 64 090313 AG
* Section “Indicators” added.
Chapter “Hardware”
0.00 63 090212 AG * Several corrections.
* Section “Hardware Versions” Version 8.0 added.
Chapter “Working with J-Link and J-Trace”
* Section “Reset strategies” updated.
Chapter J-Link and J-Trace related software
0.00 62 090211 AG * Section “J-Link STR91x Commander (Command line tool)” updated.
Chapter “Device specifics”
* Section “ST Microelectronics” updated.
Chapter “Hardware” updated.
Chapter “Working with J-Link”
0.00 61 090120 TQ
* Section “Cortex-M3 specific reset strategies”
Chapter “Working with J-Link”
0.00 60 090114 AG
* Section “Cortex-M3 specific reset strategies”
Chapter Hardware
0.00 59 090108 KN * Section “Target board design for JTAG” updated.
* Section “Target board design for SWD” added.
Chapter “Working with J-Link Pro”
0.00 58 090105 AG
* Section “Connecting J-Link Pro the first time” updated.
Manual
Revision Date By Description
version
Chapter “Working with J-Link Pro”
* Section “Introduction” updated.
0.00 57 081222 AG * Section “Configuring J-Link Pro via web interface” updated.
Chapter “Introduction”
* Section “J-Link Pro overview” updated.
Chapter “Working with J-Link Pro”
* Section “FAQs” added.
0.00 56 081219 AG
Chapter “Support and FAQs”
* Section “Frequently Asked Questions” updated.
0.00 55 081218 AG Chapter “Hardware” updated.
Chapter “Working with J-Link and J-Trace”
0.00 54 081217 AG
* Section “J-Link Command Strings” updated.
0.00 53 081216 AG Chapter “Working with J-Link Pro” updated.
Chapter “Working with J-Link Pro” added.
0.00 52 081212 AG Chapter “Licensing”
* Section “Original SEGGER products” updated.
0.00 51 081202 KN Several corrections.
Chapter “Flash download and flash breakpoints”
0.00 50 081030 AG
* Section “Supported devices” corrected.
0.00 49 081029 AG Several corrections.
Chapter “Working with J-Link and J-Trace”
0.00 48 080916 AG * Section “Connecting multiple J-Links /
J-Traces to your PC” updated.
0.00 47 080910 AG Chapter “Licensing” updated.
Chapter “Licensing” added.
0.00 46 080904 AG Chapter “Hardware”
Section “J-Link OEM versions” moved to chapter “Licensing”
Chapter “Hardware”
Section “JTAG+Trace connector” JTAG+Trace
0.00 45 080902 AG
connector pinout corrected.
Section “J-Link OEM versions” updated.
Chapter “J-Link control panel” moved to chapter “Working with J-Link”.
0.00 44 080827 AG
Several corrections.
Chapter “Flash download and flash breakpoints”
0.00 43 080826 AG
Section “Supported devices” updated.
Chapter “Flash download and flash breakpoints”
0.00 42 080820 AG
Section “Supported devices” updated.
Chapter “Flash download and flash breakpoints” updated.
0.00 41 080811 AG Chapter “Flash download and flash breakpoints”,
section “Supported devices” updated.
Chapter “Flash download and flash breakpoints” updated.
0.00 40 080630 AG Chapter “J-Link status window” renamed to “J-Link control panel”
Various corrections.
Chapter “Flash download and flash breakpoints”
Section “Licensing” updated.
0.00 39 080627 AG Section “Using flash download and flash
breakpoints with different debuggers” updated.
Chapter “J-Link status window” added.
Chapter “Support and FAQs”
Section “Frequently Asked Questions” updated
0.00 38 080618 AG
Chapter “Reset strategies”
Section “Cortex-M3 specific reset strategies” updated.
Chapter “Reset strategies”
0.00 37 080617 AG
Section “Cortex-M3 specific reset strategies” updated.
Chapter “Hardware”
Section “Differences between different versions” updated.
0.00 36 080530 AG
Chapter “Working with J-Link and J-Trace”
Section “Cortex-M3 specific reset strategies” added.
Chapter “J-Link and J-Trace related software”
0.00 35 080215 AG
Section “J-Link software and documentation package in detail” updated.
Manual
Revision Date By Description
version
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.
0.00 34 080212 AG Chapter “Flash download and flash breakpoints”
Section “Introduction” updated.
Section “Licensing” updated.
Section “Using flash download and flash breakpoints with
different debuggers” updated.
Chapter “Flash download and flash breakpoints” added
0.00 33 080207 AG Chapter “Device specifics:”
Section “ATMEL - AT91SAM7 - Recommended init sequence” added.
Chapter “Device specifics”:
0.00 32 080129 SK
Section “NXP - LPC - Fast GPIO bug” list of device enhanced.
Chapter “Device specifics”:
0.00 31 080103 SK
Section “NXP - LPC - Fast GPIO bug” updated.
Chapter “Device specifics”:
Section “Analog Devices” updated.
Section “ATMEL” updated.
Section “Freescale” added.
Section “Luminary Micro” added.
0.00 30 071211 AG 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.
Chapter “Related software”:
Section “J-LinkSTR91x Commander” added.
Chapter “Device specifics”:
0.00 28 070912 SK
Section “ST Microelectronics” added.
Section “Texas Instruments” added.
Subsection “AT91SAM9” added.
Chapter “Working with J-Link/J-Trace”:
0.00 28 070912 AG
Section “J-Link Command Strings” updated.
Chapter “Working with J-Link/J-Trace”:
0.00 27 070827 TQ
Section “J-Link Command Strings” updated.
Chapter “Introduction”:
Section “Features of J-Link” updated.
0.00 26 070710 SK Chapter “Background Information”:
Section “Embedded Trace Macrocell” added.
Section “Embedded Trace Buffer” added.
Chapter “Working with J-Link/J-Trace”:
Section “Reset strategies in detail”
- “Software, for Analog Devices ADuC7xxx MCUs” updated
0.00 25 070516 SK - “Software, for ATMEL AT91SAM7 MCUs” added.
Chapter “Device specifics”
Section “Analog Devices” added.
Section “ATMEL” added.
Chapter “Setup”:
0.00 24 070323 SK “Uninstalling the J-Link driver” updated.
“Supported ARM cores” updated.
Chapter “Hardware”:
0.00 23 070320 SK
“Using the JTAG connector with SWD” updated.
Chapter “Hardware”:
0.00 22 070316 SK
“Using the JTAG connector with SWD” added.
Chapter “Hardware”:
0.00 21 070312 SK
“Differences between different versions” supplemented.
Chapter “J-Link / J-Trace related software”:
0.00 20 070307 SK
“J-Link GDB Server” licensing updated.
Chapter “J-Link / J-Trace related software” updated and reorganized.
0.00 19 070226 SK Chapter “Hardware”
“List of OEM products” updated
Manual
Revision Date By Description
version
Chapter “Device specifics” added
0.00 18 070221 SK
Subchapter “J-Link Command Strings” added
Chapter “Hardware”:
“Version 5.3”: Current limits added
“Version 5.4” added
Chapter “Setup”:
0.00 17 070131 SK
“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
Chapter “Preface”: “Company description” added.
0.00 16 061222 SK
J-Link picture changed.
Subchapter 1.5.1: Added target supply voltage and target supply current
0.00 15 060914 OO 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 12 060628 OO Subchapter 4.1: Added ARM966E-S to List of supported ARM cores.
Subchapter 5.5.2.2 changed.
0.00 11 060607 SK
Subchapter 5.5.2.3 added.
ARM9 download speed updated.
Subchapter 8.2.1: Screenshot “Start sequence” updated.
0.00 10 060526 SK Subchapter 8.2.2 “ID sequence” removed.
Chapter “Support” and “FAQ” merged.
Various improvements
Chapter “Literature and references” added.
Chapter “Hardware”:
0.00 9 060324 OO Added common information trace signals.
Added timing diagram for trace.
Chapter “Designing the target board for trace” added.
Chapter “Related Software”: Added JLinkARM.dll.
0.00 8 060117 OO
Screenshots updated.
0.00 7 051208 OO Chapter Working with J-Link: Sketch added.
Chapter Working with J-Link: “Connecting multiple J-Links to your PC”
added.
0.00 6 051118 OO
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.
Chapter Background information: “Flash programming” added.
0.00 4 051025 OO Chapter Setup: “Scan chain configuration” added.
Some smaller changes.
0.00 3 051021 TQ Performance values updated.
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.
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
21 Semihosting .............................................................................................................399
21.1 Introduction ............................................................................................. 400
21.1.1 Advantages ................................................................................... 400
21.1.2 Disadvantages ............................................................................... 400
21.2 Debugger support .....................................................................................401
21.3 Implementation ........................................................................................ 402
21.3.1 SVC instruction ............................................................................. 402
21.3.2 Breakpoint instruction .................................................................... 402
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.
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.
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
Note
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.
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.
This chapter describes the contents of the J-Link Software and Documentation Package
which can be downloaded from www.segger.com .
Software Description
J-Link Commander Command-line tool with basic functionality for target analysis.
The J-Link GDB Server is a server connecting to the GNU De-
J-Link GDB Server 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 of the J-Link GDB Server. Same func-
command line version tionality as the GUI version.
Utility which provides the possibility to use J-Link / J-Trace re-
J-Link Remote Server
motely via TCP/IP.
Target memory viewer. Shows the memory content of a run-
J-Mem
ning target and allows editing as well.
Stand-alone flash programming application. For more infor-
J-Flasha mation about J-Flash please refer to J-Flash ARM User’s Guide
(UM08003).
Stand-alone flash programming application. Reduced feature
J-Flash Lite
set of J-Flash
Free-of-charge utility for J-Link. Displays the terminal output
J-Link RTT Viewer of the target using RTT. Can be used in parallel with a debug-
ger or stand-alone.
Free-of-charge utility for J-Link. Displays the terminal output
J-Link SWO Viewer of the target using the SWO pin. Can be used in parallel with a
debugger or stand-alone.
Command line tool that analyzes SWO RAW output and stores
J-Link SWO Analyzer
it into a file.
Command line tool that opens an svf file and sends the data in
JTAGLoad
it via J-Link / J-Trace to the target.
GUI-based configuration tool for J-Link. Allows configuration of
USB identification as well as TCP/IP identification of J-Link. For
J-Link Configurator
more information about the J-Link Configurator, please refer
to J-Link Configurator .
Provides Remote Debug Interface (RDI) support. This allows
RDI supporta
the user to use J-Link with any RDI-compliant debugger.
Free command-line tools for handling specific processors.
Processor specific tools
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.
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.
3.2.1.1 clrBP
This command removes a breakpoint set by J-Link.
Syntax
clrBP <BP_Handle>
Parameter Meaning
BP_Handle Handle of breakpoint to be removed.
Example
clrBP 1
3.2.1.2 clrWP
This command removes a watchpoint set by J-Link.
Syntax
clrWP <WP_Handle>
Parameter Meaning
WP_Handle Handle of watchpoint to be removed.
Example
clrWP 0x2
3.2.1.3 device
Selects a specific device J-Link shall connect to and performs a reconnect. In most cases
explicit selection of the device is not necessary. Selecting a device enables the user to make
use of the J-Link flash programming functionality as well as using unlimited breakpoints
in flash memory. For some devices explicit device selection is mandatory in order to allow
the DLL to perform special handling needed by the device. Some commands require that
a device is set prior to use them.
Syntax
device <DeviceName>
Parameter Meaning
Valid device name: Device is selected.
DeviceName
?: Shows a device selection dialog.
Example
device stm32f407ig
3.2.1.4 erase
Erases all flash sectors of the current device. A device has to be specified previously.
Syntax
erase
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: J-Link Commander will now exit on Error.
<1|0>
0: J-Link Commander will no longer exit on Error.
Example
eoe 1
3.2.1.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
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.
a If set, Input will be parsed as text instead of being shown as hex.
Offset Specifies the offset in the file, at which data reading is started.
NumBytes Maximum number of bytes to read.
Example
fshow Flasher.dat
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
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
Maximum number of instructions allowed to be simulated. Instruc-
tion simulation stops whenever a breakpointed instruction is hit,
NumSteps
an instruction which cannot be simulated/emulated is hit or when
NumSteps is reached.
0: Do not start the CPU if a BP is in range of NumSteps
Flags
1: Overstep BPs
Example
go //Simply starts the CPU
go 20, 1
3.2.1.16 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.
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
Valid values:
IP Address: Connects the J-Link with the specified IP-Address
Addr
Host Name: Resolves the host name and connects to it.
*: Invokes the Emulator selection dialog.
Example
ip 192.168.6.3
3.2.1.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>
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.
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>
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
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-
Delay in ms.
set
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.
Only for ARM7/9/11 and Cortex-R4 devices:
A/T A: ARM mode
T: THUMB mode
Only for MIPS devices:
W/H W: MIPS32 mode (Word)
H: MIPS16 mode (Half-word)
S: Force software BP
S/H
H: Force hardware BP
Example
setBP 0x8000036
3.2.1.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
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.
Specifies the control data on which data event has been set:
Accesstype R: read access
W: write access
Valid values: S8 | S16 | S32
Size
Specifies to monitor an n-bit access width at the selected address.
Data Specifies the Data on which watchpoint has been set.
Specifies data mask used for comparison. Bits set to 1 are masked
out, so not taken into consideration during data comparison. Please
DataMask note that for certain cores not all Bit-Mask combinations are support-
ed by the core-debug logic. On some cores only complete bytes can
be masked out (e.g. PIC32) or similar.
Specifies the address mask used for comparison. Bits set to 1 are
masked out, so not taken into consideration during address compar-
AddrMask ison. Please note that for certain cores not all Bit-Mask 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.
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
Name of the device family to unlock. Supported Devices:
LM3Sxxx
DeviceName
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
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)
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
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
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
USB 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.
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
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>
Example
JLink.exe -RTTTelnetPort 9100
3.2.2.12 USB
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
USB <SerialNo>
Example
JLink.exe USB 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
Example
JLink.exe -device STM32F103ZE -CommandFile C:\CommandFile.jlink
Contents of CommandFile.jlink:
si 1
speed 4000
r
h
loadbin C:\firmware.bin,0x08000000
Command Description
Selects the IP port on which the J-Link Remote Server is lis-
-port
tening.
-UseTunnel Starts J-Link Remote Server in tunneling mode
-SelectEmuBySN Selects the J-Link to connect to by its serial number.
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.
Troubleshooting
Problem Solution
Remote server can- 1. Make sure the Remote server is not blocked by any firewall.
not connect to tun- 2. Make sure port 19020 is not blocked by any firewall.
nel server. 3. Contact network admin.
1. Make sure Remote server is started correctly.
J-Link Commander
2. Make sure the entered serial number is correct.
cannot connect to
3. Make sure port 19020 is not blocked by any firewall. Contact
tunnel server.
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:
For more information on how to use J-Mem, please refer to J-Mem on page 134
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.
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:
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 344.
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.
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.
Data Logging can be started via Logging -> Start Data Logging…
Note
3.7.7.1 --bright
Starts the RTT Viewer in bright theme
Syntax
--bright
Example
JLinkRTTViewer.exe --bright
3.7.7.2 --device
Selects the device J-Link RTT Viewer shall connect to.
Syntax
--device <DeviceName>
Example
JLinkRTTViewer.exe --device STM32F103ZE
3.7.7.3 --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.4 --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>
Example
JLinkRTTViewer.exe --interface swd
3.7.7.5 --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.6 --speed
Sets the interface speed in kHz for target communication.
Syntax
--speed <speed>
Example
JLinkRTTViewer.exe --speed 4000
3.7.7.7 --scriptfile
Executes a JLink command script on startup, setting options in advance (e.g. Device =
AT91SAM7S256)
Syntax
--scriptfile <FilePath>
Example
JLinkRTTViewer.exe --scriptfile C:\tmp\<Scriptfilename>
3.7.7.8 --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.9 --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.10 --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>]>
Example
JLinkRTTViewer.exe -rttrange “20000000 400”
3.7.7.11 --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
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
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.
Command Description
-cpufreq Select the CPU frequency.
-device Select the target device.
-ip Configure connection settings to IP IPAddress.
Selects a set of itm stimulus ports which should be used to
-itmmask
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>
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 -ip
Selects IP as host interface to connect to J-Link. Default host interface is USB.
Syntax
-ip <IPAddr>
Example
-ip 192.168.1.17
3.8.3.4 -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.5 -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.6 -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.7 -settingsfile
Select a J-Link settings file to use for the target device.
Syntax
-settingsfile <PathToFile>
Example
-settingsfile “C:\Temp\Settings.jlink”
3.8.3.8 -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.9 -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
----------------------------------------------------------------------
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.
/*********************************************************************
*
* Prototypes (to be placed in a header file such as SWO.h)
*/
/*********************************************************************
*
* 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
/*********************************************************************
*
* 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++);
}
}
Usage
SWOAnalyzer.exe <SWOfile> This can be achieved by simply dragging the SWO output file
created by the J-Link DLL onto the executable.
[SWO]
SWOLogFile="C:\TestSWO.dat"
SVF is a standard format for boundary scan vectors to be used with different tools and
targets. SVF files contain human-readable ASCII SVF statements consisting of an SVF 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:
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.
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.
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.
Commands
Command Description
Set the size of the primary flash manually.
Syntax: fsize 0|1|2|3, where 0 selects a 256 Kbytes device,
fsize
1 a 512 Kbytes device, 2 a 1024 KBytes device
and 3 a 2048 Kbytes device
showconf Show configuration register content and security status
Read memory
mem
Syntax: mem <Addr>, <NumBytes>
Erase flash sectors (OTP can not be erased).
Syntax: erase <SectorMaskL>, <SectorMaskH>
SectorMaskL = Bits 0-%d mask sectors 0-%d of bank 0
erase 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
Boot from flash bank x (0 and 1 are available)
setb
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
Set the security bit. Protects device from read or debug access
secure
through the JTAG port (can only be cleared by a full chip erase).
unsecure Unsecure the device. Content of configuration register is saved.
Protect flash sectors.
Syntax: protect <Bank0SectorMask>, <Bank1SectorMask>
protect
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 flash sectors.
Syntax: unprotect <Bank0SectorMask>, <Bank1SectorMask>
unprotect
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
Write words to the OTP sectors.
writeotp
Syntax: writeotp <Word1>, [<Word2>, …, <Word8>]
q Quit
Command Explanation
-CommandFile Passes a CommandFile to J-Link
-IP Selects IP as host interface
-USB 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 -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 .
Syntax
-DRPre <DRPre>
-DRPost <DRPost>
-IRPre <IRPre>
-IRPost <IRPost>
Example
JLinkSTR91x.exe -DRPre 1 -DRPost 4 -IRPre 16 -IRPost 20
3.12.1.3 -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> .
3.12.1.4 -USB
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
-USB <SerialNo>
Example
JLinkSTR91x.exe -USB 580011111
Note
Unprotecting a secured device or will cause a mass erase of the flash memory.
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.
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
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
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.
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.
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.
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:
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 .
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:
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.
The Following remote commands are deprecated and only available for backward compat-
ibility:
Note
Note
Note
4.3.1 clrbp
Removes an instruction breakpoint, where <BPHandle> is the handle of breakpoint to be
removed. If no handle is specified this command removes all pending breakpoints.
Syntax
ClrBP [<BPHandle>]
or
ci [<BPHandle>]
Example
4.3.2 cp15
Reads or writes from/to cp15 register. If <data> is specified, this command writes the data
to the cp15 register. Otherwise this command reads from the cp15 register. For further
information please refer to the ARM reference manual.
Syntax
cp15 <CRn>, <CRm>, <op1>, <op2> [= <data>]
The parameters of the function are equivalent to the MCR instructions described in the ARM
documents.
Example
#Read:
> monitor cp15 1, 2, 6, 7
< Reading CP15 register (1,2,6,7 = 0x0460B77D)
#Write:
> monitor cp15 1, 2, 6, 7 = 0xFFFFFFFF
4.3.3 device
Note
Selects the specified target device. This is necessary for the connection and some special
handling of the device.
Note
The device should be selected via commandline option -device when starting GDB
Server.
Syntax
device <DeviceName>
Example
4.3.4 DisableChecks
Disables checking if a memory read caused an abort (ARM7/9 devices only). On some CPUs
during the init sequence for enabling access to the internal memory (for example on the
TMS470) some dummy reads of memory are required which will cause an abort as long as
the access-init is not completed.
Syntax
DisableChecks
4.3.5 EnableChecks
Enables checking if a memory read caused an abort (ARM7/9 devices only). On some CPUs
during the init sequence for enabling access to the internal memory (for example on the
TMS470) some dummy reads of memory are required which will cause an abort as long as
the access-init is not completed. The default state is: Checks enabled.
Syntax
EnableChecks
Syntax
monitor flash breakpoints = <Value>
Example
Syntax
flash erase
4.3.8 getargs
Get the currently set argument list which will be given to the application when calling
semihosting command SYS_GET_CMDLINE (0x15). The argument list is given as one string.
Syntax
getargs
Example
4.3.9 go
Starts the target CPU.
Syntax
go
Example
> monitor go
4.3.10 halt
Halts the target CPU.
Syntax
halt
Example
4.3.11 interface
Note
Syntax
interface <InterfaceIdentifier>
4.3.12 jtagconf
Configures a JTAG scan chain with multiple devices on it. <IRPre> is the sum of IRLens of all
devices closer to TDI, where IRLen is the number of bits in the IR (Instruction Register) of
one device. <DRPre> is the number of devices closer to TDI. For more detailed information
of how to configure a scan chain with multiple devices please refer to Determining values
for scan chain configuration .
Note
To make sure the connection to the device can be established correctly, it is recom-
mended to configure the JTAG scan chain via command line options at the start of
GDB Server.
Syntax
jtagconf <IRPre> <DRPre>
Example
#Select the second device, where there is 1 device in front with IRLen 4
> monitor jtagconf 4 1
4.3.13 memU8
Reads or writes a byte from/to a given address. If <value> is specified, this command writes
the value to the given address. Otherwise this command reads from the given address.
Syntax
memU8 <address> [= <value>]
Example
#Read:
> monitor memU8 0x50000000
< Reading from address 0x50000000 (Data = 0x04)
#Write:
> monitor memU8 0x50000000 = 0xFF
< Writing 0xFF @ address 0x50000000
4.3.14 memU16
Reads or writes a halfword from/to a given address. If <value> is specified, this command
writes the value to the given address. Otherwise this command reads from the given ad-
dress.
Syntax
memU16 <address> [= <value>]
Example
#Read:
> monitor memU16 0x50000000
< Reading from address 0x50000000 (Data = 0x3004)
#Write:
> monitor memU16 0x50000000 = 0xFF00
< Writing 0xFF00 @ address 0x50000000
4.3.15 memU32
Reads or writes a word from/to a given address. If <value> is specified, this command writes
the value to the given address. Otherwise this command reads from the given address.
This command is similar to the long command.
Syntax
memU32 <address> [= <value>]
Example
#Read:
> monitor memU32 0x50000000
< Reading from address 0x50000000 (Data = 0x10023004)
#Write:
> monitor memU32 0x50000000 = 0x10023004
< Writing 0x10023004 @ address 0x50000000
4.3.16 reg
Reads or writes from/to given register. If <value> is specified, this command writes the
value into the given register. If <address> is specified, this command writes the memory
content at address <address> to register <RegName>. Otherwise this command reads the
given register.
Syntax
Example
4.3.17 regs
Reads all CPU registers.
Syntax
regs
Example
4.3.18 reset
Resets and halts the target CPU. Make sure the device is selected prior to using this com-
mand to make use of the correct reset strategy.
Note
There are different reset strategies for different CPUs. Moreover, the reset strategies
which are available differ from CPU core to CPU core. J-Link can perform various reset
strategies and always selects the best fitting strategy for the selected device.
Syntax
reset
Example
Syntax
semihosting breakOnerror <Value>
Example
#Enable breakOnError:
> monitor semihosting breakOnError 1
Syntax
semihosting enable [<VectorAddr>]
Example
Syntax
semihosting IOClient <ClientMask>
Example
Syntax
semihosting ARMSWI <Value>
Example
Syntax
semihosting ThumbSWI <Value>
Example
4.3.24 setargs
Set arguments for the application, where all arguments are in one <ArgumentString> sep-
arated by whitespaces. The argument string can be gotten by the application via semihost-
ing command SYS_GET_CMDLINE (0x15). Semihosting has to be enabled for getting the
argumentstring (see semihosting enable ). “monitor setargs” can be used before enabling
semihosting. The maximum length for <ArgumentString> is 512 characters.
Syntax
setargs <ArgumentString>
Example
4.3.25 setbp
Sets an instruction breakpoint at the given address, where <Mask> can be 0x03 for ARM
instruction breakpoints (Instruction width 4 Byte, mask out lower 2 bits) or 0x01 for THUMB
instruction breakpoints (Instruction width 2 Byte, mask out lower bit). If no mask is given,
an ARM instruction breakpoint will be set.
Syntax
setbp <Addr> [<Mask>]
Example
4.3.26 sleep
Sleeps for a given time, where <Delay> is the time period in milliseconds to delay. While
sleeping any communication is blocked until the command returns after the given period.
Syntax
sleep <Delay>
Example
4.3.27 speed
Note
Deprecated. For setting the initial connection speed, use command line option -speed
instead.
Sets the JTAG speed of J-Link / J-Trace. Speed can be either fixed (in kHz), automatic
recognition or adaptive. In general, Adaptive is recommended if the target has an RTCK
signal which is connected to the corresponding RTCK pin of the device (S-cores only). For
detailed information about the different modes, refer to JTAG Speed . The speed has to be
set after selecting the interface, to change it from its default value.
Syntax
speed <kHz>|auto|adaptive
Example
4.3.28 step
Performs one or more single instruction steps, where <NumSteps> is the number of in-
struction steps to perform. If <NumSteps> is not specified only one instruction step will
be performed.
Syntax
step [<NumSteps>]
or
si [<NumSteps>]
Example
Syntax
SWO DisableTarget <PortMask[0x01-0xFFFFFFFF]>
Example
Note
CPUFreq has to be the speed at which the target will be running when doing SWO. If
the speed is different from the current speed when issuing CPU speed auto-detection,
getting SWO data might fail. SWOFreq has to be a quotient of the CPU and SWO speeds
and their prescalers. To get available speed, use SWO GetSpeedInfo. PortMask can
be a decimal or hexadecimal Value. Values starting with the Prefix “0x” are handled
hexadecimal.
Syntax
SWO EnableTarget <CPUFreq[Hz]> <SWOFreq[Hz]> <PortMask[0x01-0xFFFFFFFF]
<Mode[0]>
Example
#Configure SWO for stimulus port 0, measure CPU frequency and calculate SWO
frequency
> monitor SWO EnableTarget 0 0 1 0
#Configure SWO for stimulus ports 0-2, fixed SWO frequency and measure CPU
frequency
> monitor SWO EnableTarget 0 1200000 5 0
< SWO enabled successfully.
#Configure SWO for stimulus ports 0-255, fixed CPU and SWO frequency
> monitor SWO EnableTarget 72000000 6000000 0xFF 0
< SWO enabled successfully.
Syntax
SWO GetMaxSpeed <CPUFrequency [Hz]>
Example
Syntax
SWO GetSpeedInfo
Example
4.3.33 waithalt
Waits for target to halt code execution, where <Timeout> is the maximum time period in
milliseconds to wait.
Syntax
waithalt <Timeout>
or
wh <Timeout>
Example
4.3.34 wice
Writes to given IceBreaker register, where <value> is the data to write.
Syntax
Example
4.3.35 ReadAP
Reads the specified CoreSight DAP-AP register.
Note
- ARM specifies register addresses for JTAG (0x0, 0x4, 0x8, …) and register indexes
for SWD (0, 1, 2, …).
This API always works with register indexes, so:
- Addr 0x0 = RegIndex 0
- Addr 0x4 = RegIndex 1
- Addr 0x8 = RegIndex 2
- Addr 0xC = RegIndex 3
- In case a WAIT response is received from the DAP, J-Link will retry the access until
OK/FAULT is received or the operation times out (100ms).
- Performs a fully qualified read. This means that for AP accesses which are “regis-
tered”, J-Link performs an implicit read of AP-RDBUFF after the AP access, to get the
actual value.
Syntax
ReadAP [<RegIndex>]
Example
4.3.36 ReadDP
Reads the specified CoreSight DAP-DP register.
Note
- ARM specifies register addresses for JTAG (0x0, 0x4, 0x8, …) and register indexes
for SWD (0, 1, 2, …).
This API always works with register indexes, so:
- Addr 0x0 = RegIndex 0
- Addr 0x4 = RegIndex 1
Syntax
ReadDP [<RegIndex>]
Example
4.3.37 WriteAP
Writes the specified CoreSight DAP-AP register.
Note
- ARM specifies register addresses for JTAG (0x0, 0x4, 0x8, …) and register indexes
for SWD (0, 1, 2, …).
This API always works with register indexes, so:
- Addr 0x0 = RegIndex 0
- Addr 0x4 = RegIndex 1
- Addr 0x8 = RegIndex 2
- Addr 0xC = RegIndex 3
- In case a WAIT response is received from the DAP, J-Link will retry the access until
OK/FAULT is received or the operation times out (100ms).
Syntax
Example
4.3.38 WriteDP
Writes the specified CoreSight DAP-DP register.
Note
- ARM specifies register addresses for JTAG (0x0, 0x4, 0x8, …) and register indexes
for SWD (0, 1, 2, …).
This API always works with register indexes, so:
- Addr 0x0 = RegIndex 0
Syntax
Example
Note
Using GDB Server CL, device, interface, endian and speed are mandatory options
to correctly connect to the target, and should be given before connection via GDB.
Using GDB Server GUI the mandatory options can also be selected in the configuration
dialog.
Note
Using multiple instances of GDB Server, setting custom values for port, SWOPort and
TelnetPort is necessary.
The GDB Server GUI version uses persistent settings which are saved across different in-
stances and sessions of GDB Server. These settings can be toggled via the checkboxes in
the GUI.
Note
For GUI and CL, the settings can be changed with following command line options. For all
persistent settings there is a pair of options to enable or disable the feature.
Following additional command line options are available. These options are temporary for
each start of GDB Server.
4.5.1 -cpu
Pre-select the CPU core of the connected device, so the GDB Server already knows the
register set, even before having established a connection to the CPU.
Note
Deprecated, please use -device instead. Anyhow, it does not hurt if this option is set,
too.
Syntax
-CPU <CPUCore>
Example
jlinkgdbserver -CPU ARM7_9
Add. information
The following table lists all valid values for <CPUCore> :
4.5.2 -device
Tells GDBServer to which device J-Link is connected before the connect sequence is actually
performed. It is recommended to use the command line option to select the device instead
of using the remote command since for some devices J-Link already needs to know the
device at the time of connecting to it since some devices need special connect sequences
(e.g. devices with TI ICEPick modules). In such cases, it is not possible to select the device
via remote commands since they are configured after the GDB client already connected
to GDBServer and requested the target registers which already requires a connection to
the target.
Note
Using GDB Server CL this option is mandatory to correctly connect to the target, and
should be given before connection via GDB.
Syntax
-device <DeviceName>
Example
jlinkgdbserver -device AT91SAM7SE256
Add. information
For a list of all valid values for <DeviceName> , please refer to List of supported target
devices .
4.5.3 -endian
Sets the endianness of the target where endianness can either be “little” or “big”.
Syntax
-endian <endianness>
Example
jlinkgdbserver -endian little
Note
When using GDB Server CL this option is mandatory to correctly connect to the target,
and should be given before connection via GDB.
4.5.4 -gui
Do not suppress DLL dialogs.
Syntax
-gui
Example
jlinkgdbserver -gui
4.5.5 -if
Selects the target interface which is used by J-Link to connect to the device. The default
value is JTAG.
Syntax
-if <Interface>
Example
jlinkgdbserver -if SWD
Add. information
Currently, the following values are accepted for <Interface> :
• JTAG
• SWD
• FINE
• 2-wire-JTAG-PIC32
4.5.6 -ir
Initializes the CPU register with default values on startup.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via -noir or the GUI.
Example
jlinkgdbserver -ir
4.5.7 -excdbg
Enables exception debugging. Exceptions on ARM CPUs are handled by exception handlers.
Exception debugging makes the debugging of exceptions more user-friendly by passing a
signal to the GDB client and returning to the causative instruction. In order to do this, a
special exception handler is required as follows:
The signal passed to the GDB client is the immediate value (10 in the example) of the
software breakpoint instruction. <nSteps> specifies, how many instructions need to be
executed until the exception return occurs. In most cases this will be 2 (which is the default
value), if the handler function is set as the exception handler. If it is called indirectly as a
subroutine from the exception handler, there may be more steps required. It is mandatory
to have the function declared with the “naked” attribute and to have the bx lr instruction
immediately after the software breakpoint instruction. Otherwise the software breakpoint
will be treated as a usual breakpoint.
Syntax
-excdbg <nSteps>
Example
jlinkgdbserver -excdbg 4
4.5.8 -jtagconf
Configures a JTAG scan chain with multiple devices on it. <IRPre> is the sum of IRLens of all
devices closer to TDI, where IRLen is the number of bits in the IR (Instruction Register) of
one device. <DRPre> is the number of devices closer to TDI. For more detailed information
of how to configure a scan chain with multiple devices please refer to Determining values
for scan chain configuration .
Syntax
-jtagconf <IRPre>,<DRPre>
Example
#Select the second device, where there is 1 device in front with IRLen 4
jlinkgdbserver -jtagconf 4,1
4.5.9 -localhostonly
Starts the GDB Server with the option to listen on localhost only (This means that only TCP/
IP connections from localhost are accepted) or on any IP address. To allow remote debug-
ging (connecting to GDBServer from another PC), deactivate this option. If no parameter
is given, it will be set to 1 (active).
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via command line option or the GUI.
Syntax
-LocalhostOnly <State>
Example
jlinkgdbserver -LocalhostOnly 0 //Listen on any IP address (Linux/MAC default)
jlinkgdbserver -LocalhostOnly 1 //Listen on localhost only (Windows default)
4.5.10 -log
Starts the GDB Server with the option to write the output into a given log file. The file
will be created if it does not exist. If it exists the previous content will be removed. Paths
including spaces need to be set between quotes.
Syntax
-log <LogFilePath>
Example
jlinkgdbserver -log “C:\my path\to\file.log”
4.5.11 -logtofile
Starts the GDB Server with the option to write the output into a log file. If no file is given
via -log , the log file will be created in the GDB Server application directory.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via -nologtofile or the GUI.
Syntax
logtofile
Example
jlinkgdbserver -logtofile
jlinkgdbserver -logtofile -log “C:\my path\to\file.log”
4.5.12 -halt
Halts the target after connecting to it on start of GDB Server. For most IDEs this option is
mandatory since they rely on the target to be halted after connecting to GDB Server.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via -nohalt or the GUI.
Syntax
-halt
Example
jlinkgdbserver -halt
4.5.13 -nogui
Suppresses DLL dialogs.
Syntax
-nogui
Example
jlinkgdbserver -nogui
4.5.14 -noir
Do not initialize the CPU registers on startup.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via -ir or the GUI.
Syntax
noir
4.5.15 -nolocalhostonly
Starts GDB Server with the option to allow remote connections (from outside localhost).
Same as -localhostonly 0
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via command line option or the GUI.
Syntax
-nolocalhostonly
4.5.16 -nologtofile
Starts the GDB Server with the option to not write the output into a log file.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via -nologtofile or the GUI. When this option is used after -log, no log file
will be generated, when -log is used after this option, a log file will be generated and
this setting will be overridden.
Syntax
-nologtofile
Example
jlinkgdbserver -nologtofile // Will not generate a log file
jlinkgdbserver -nologtofile -log “C:\pathto\file.log” // Will generate a log
file
jlinkgdbserver -log “C:\pathto\file.log” -nologtofile // Will not generate
a log file
4.5.17 -nohalt
When connecting to the target after starting GDB Server, the target is not explicitly halt-
ed and the CPU registers will not be inited. After closing all GDB connections the target
is started again and continues running. Some IDEs rely on the target to be halted after
connect. In this case do not use -nohalt, but -halt.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via -halt or the GUI.
Syntax
-nohalt
Example
jlinkgdbserver -nohalt
4.5.18 -noreset
Perform no reset on connect, just halt the CPU
Syntax
-noreset
Example
jlinkgdbserver -norest
4.5.19 -nosinglerun
Single run mode turned off. (Default)
Syntax
-nosinglerun
Example
jlinkgdbserver -nosinglerun
4.5.20 -nosilent
Starts the GDB Server in non-silent mode. All log window messages will be shown.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via command line option or the GUI.
Syntax
-nosilent
4.5.21 -nostayontop
Starts the GDB Server in non-topmost mode. All windows can be placed above it.
Note
For the CL version this setting has no effect. For the GUI version, this setting is per-
sistent for following uses of GDB Server until changed via command line option or
the GUI.
Syntax
-nostayontop
Example
4.5.22 -notimeout
GDB Server automatically closes after a timeout of 5 seconds when no target voltage can
be measured or connection to target fails. This command line option prevents GDB Server
from closing, to allow connecting a target after starting GDB Server.
Note
The recommended order is to power the target, connect it to J-Link and then start
GDB Server.
Syntax
-notimeout
4.5.23 -novd
Do not explicitly verify downloaded data.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via command line option or the GUI.
Syntax
-vd
4.5.24 -port
Starts GDB Server listening on a specified port. This option overrides the default listening
port of the GDB Server. The default port is 2331.
Note
Using multiple instances of GDB Server, setting custom values for this option is nec-
essary.
Syntax
-port <Port>
Example
jlinkgdbserver -port 2345
4.5.25 -rtos
Specifies a RTOS plug-in (.DLL file for Windows, .SO file for Linux and Mac). If the file-name
extension is not specified, it is automatically added depending on the PC’s operating system.
The J-Link Software and Documentation Package comes with RTOS plug-ins for embOS
and FreeRTOS pre-installed in the sub-directory “GDBServer”. A software development kit
(SDK) for creating your own plug-ins is also available upon request.
Syntax
-rtos <filename>[.dll|.so]
Example
jlinkgdbserver -rtos GDBServer\RTOSPlugin_embOS
4.5.26 -JLinkDevicesXMLPath
Passes JLinkDevices.xml file to the DLL.
Syntax
-JLinkDevicesXMLPath <filename>[.xml]
Example
jlinkgdbserver -JLinkDevicesXMLPath.xml
4.5.27 -jlinkscriptfile
Passes the path of a J-Link script file to the GDB Server. This scriptfile is executed before
the GDB Server starts the debugging / identifying communication with the target. J-Link
scriptfiles are mainly used to connect to targets which need a special connection sequence
before communication with the core is possible. For more information about J-Link script
files, please refer to J-Link script files .
Syntax
-jlinkscriptfile <ScriptFilePath>
Example
-jlinkscriptfile “C:\My Projects\Default.JLinkScript”
4.5.28 -powertarget
Power target after specified delay (1-9 ms). 0 turns off power.
Syntax
-powertarget <Value>
Value can can range from 0-9.
Example
jlinkgdbserver -powertarget 1
4.5.29 -select
Specifies the host interface to be used to connect to J-Link. Currently, USB and TCP/IP
are available.
Syntax
-select <Interface#<SerialNo>/<IPAddr>
Example
jlinkgdbserver -select usb=580011111
jlinkgdbserver -select ip=192.168.1.10
Additional information
For backward compatibility, when USB is used as interface serial numbers from 0-3 are
accepted as USB=0-3 to support the old method of connecting multiple J-Links to a PC.
This method is no longer recommended to be used. Please use the “connect via emulator
serial number” method instead.
4.5.30 -settingsfile
Select a J-Link settings file to be used for the target device. The settings fail can contain
all configurable options of the Settings tab in J-Link Control panel.
Syntax
-SettingsFile <PathToFile>
Example
jlinkgdbserver -SettingsFile “C:\Temp\GDB Server.jlink”
4.5.31 -silent
Starts the GDB Server in silent mode. No log window messages will be shown.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via command line option or the GUI.
Syntax
-silent
4.5.32 -singlerun
Starts GDB Server in single run mode. When active, GDB Server will close when all client
connections are closed. In normal run mode GDB Server will stay open and wait for new
connections. When started in single run mode GDB Server will close immediately when
connecting to the target fails. Make sure it is powered and connected to J-Link before
starting GDB Server.
Syntax
-s
-singlerun
4.5.33 -speed
Starts GDB Server with a given initial speed. Available parameters are “adaptive”, “auto”
or a freely selectable integer value in kHz. It is recommended to use either a fixed speed
or, if it is available on the target, adaptive speeds.
Note
Using GDB Server CL this option is mandatory to correctly connect to the target, and
should be given before connection via GDB.
Syntax
-speed <Speed_kHz>
Example
jlinkgdbserver -speed 2000
4.5.34 -stayontop
Starts the GDB Server in topmost mode. It will be placed above all non-topmost windows
and maintains it position even when it is deactivated.
Note
For the CL version this setting has no effect. For the GUI version, this setting is per-
sistent for following uses of GDB Server until changed via command line option or
the GUI.
Syntax
-stayontop
4.5.35 -timeout
Set the timeout after which the target connection has to be established. If no connection
could be established GDB Server will close. The default timeout is 5 seconds for the GUI
version and 0 for the command line version.
Note
The recommended order is to power the target, connect it to J-Link and then start
GDB Server.
Syntax
-timeout <Timeout[ms]>
Example
Allow target connection within 10 seconds.
jlinkgdbserver -timeout 10000
4.5.36 -strict
Starts GDB Server in strict mode. When strict mode is active GDB Server checks the cor-
rectness of settings and exits in case of a failure. Currently the device name is checked. If
no device name is given or the device is unknown to the J-Link, GDB Server exits instead
of selecting “Unspecified” as device or showing the device selection dialog.
Syntax
-strict
Example
Following executions of GDB Server (CL) will cause exit of GDB Server. jlinkgdbserver
-strict -device UnknownDeviceName
jlinkgdbservercl -strict
Following execution of GDB Server will show the device selection dialog under Windows or
select “Unspecified” directly under Linux / OS X.
jlinkgdbserver -device UnknownDeviceName
4.5.37 -swoport
Set up port on which GDB Server should listen for an incoming connection that reads the
SWO data from GDB Server. Default port is 2332.
Note
Using multiple instances of GDB Server, setting custom values for this option is nec-
essary.
Syntax
-SWOPort <Port>
Example
jlinkgdbserver -SWOPort 2553
4.5.38 -telnetport
Set up port on which GDB Server should listen for an incoming connection that gets target’s
printf data (Semihosting and analyzed SWO data). Default port is 2333.
Note
Using multiple instances of GDB Server, setting custom values for this option is nec-
essary.
Syntax
-TelnetPort <Port>
Example
jlinkgdbserver -TelnetPort 2554
4.5.39 -vd
Verifies the data after downloading it.
Note
For the GUI version, this setting is persistent for following uses of GDB Server until
changed via command line option or the GUI.
Syntax
-vd
4.5.40 -x
Starts the GDB Server with a gdbinit (configuration) file. In contrast to the -xc command
line option the GDB Server runs the commands in the gdbinit file once only direct after the
first connection of a client.
Syntax
-x <ConfigurationFilePath>
Example
jlinkgdbserver -x C:\MyProject\Sample.gdb
4.5.41 -xc
Starts the GDB Server with a gdbinit (configuration) file. GDB Server executes the com-
mands specified in the gdbinit file with every connection of a client / start of a debugging
session.
Syntax
-xc <ConfigurationFilePath>
Example
jlinkgdbserver -xc C:\MyProject\Sample.gdb
4.7 Semihosting
Semihosting can be used with J-Link GDBServer and GDB based debug environments but
needs to be explicitly enabled. For more information, please refer to Enabling semihosting
in J-Link GDBServer .
J-Mem
J-Mem is a GUI application to display and modify the RAM and SFRs (Special Function
Registers) of target systems while the target is running.
J-Mem: Configuration
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 J-Mem.
J-Mem: UI
The memory window provides a range of different options regarding the displayed memory.
5.2.1 Go To
Using the “Go To” field, the first address shown in the memory window can be set. The
button to the right of the edit-field returns to the previously selected address.
• 1s
• 2s
• 5s
• off
The time interval “off” is the default and does not refresh the displayed memory periodically.
Setup
This chapter describes the setup procedure required in order to work with J-Link / J-Trace.
Primarily this includes the installation of the J-Link Software and Documentation Package,
which also includes a kernel mode J-Link USB driver in your host system.
Note
The setup wizard will install the software and documentation pack that also includes the
certified J-Link USB driver. Before you plug your J-Link / J-Trace into your computer’s USB
port, start the setup by double clicking Setup_JLinkARM_V<VersionNumber>.exe .
In addition you can verify the driver installation by consulting the Windows device manager.
If the driver is installed and your J-Link / J-Trace is connected to your computer, the device
manager should list the J-Link USB driver as a node below “Universal Serial Bus controllers”
as shown in the following screenshot:
Right-click on the driver to open a context menu which contains the command Properties. If
you select this command, a J-Link driver Properties dialog box is opened and should report:
This device is working properly.
If you experience problems, refer to the chapter See Support and FAQs for help. You can
select the Driver tab for detailed information about driver provider, version, date and digital
signer.
The Network configuration page allows configuration of network related settings (IP ad-
dress, subnet mask, default gateway) of J-Link. The user can choose between automatic
IP assignment (settings are provided by a DHCP server in the network) and manual IP
assignment by selecting the appropriate radio button.
6.4 FAQs
Q: How can I use J-Link with GDB and Ethernet?
A: You have to use the J-Link GDB Server in order to connect to J-Link via GDB and
Ethernet.
In order to configure an old J-Link, which uses the old USB 0 - 3 USB identification method,
to use the new USB identification method (reporting the real serial number) simply select
“Real SN” as USB identification method and click the OK button. The same dialog also allows
configuration of the IP settings of the connected J-Link if it supports the Ethernet interface.
Background information
“USB address” really means changing the USB-Product ID (PID). The following table shows
how J-Links enumerate in the different identification modes.
So even in IDEs which do not have an selection option for the J-Link, it is possible to connect
to different J-Links.
6.7.2.1 Updating the J-Link DLL in the IAR Embedded Workbench for
ARM (EWARM)
Process Explorer is - at the time of writing - a free utility which can be downloaded from
www.sysinternals.com .
This chapter describes functionality and how to use J-Link and J-Trace.
7.2.3 Problems
If you experience problems with any of the steps described above, read the chapter Support
and FAQs for troubleshooting tips. If you still do not find appropriate help there and your J-
Link / J-Trace is an original SEGGER product, you can contact SEGGER support via e-mail.
Provide the necessary information about your target processor, board etc. and we will try
to solve your problem. A checklist of the required information together with the contact
information can be found in chapter Support and FAQs as well.
7.3 Indicators
J-Link uses indicators (LEDs) to give the user some information about the current status
of the connected J-Link. All J-Links feature the main indicator. Some newer J-Links such
as the J-Link Pro / Ultra come with additional input/output Indicators. In the following, the
meaning of these indicators will be explained.
Currently, up to 8 devices in the scan chain are supported. One or more of these devices
can be CPU cores; the other devices can be of any other type but need to comply with
the JTAG standard.
7.4.1.1 Configuration
The configuration of the scan chain depends on the application used. Read JTAG interface
for further instructions and configuration examples.
Sample configurations
The diagram below shows a scan chain configuration sample with 2 devices connected to
the JTAG port.
Examples
The following table shows a few sample configurations with 1,2 and 3 devices in different
configurations.
Note
On ARM cores without synchronization logic, this may not work reliably, because the
CPU core may be clocked slower than the maximum JTAG speed.
7.5.2 SWO
Serial Wire Output (SWO) support means support for a single pin output signal from the
core. The Instrumentation Trace Macrocell (ITM) and Serial Wire Output (SWO) can be used
to form a Serial Wire Viewer (SWV). The Serial Wire Viewer provides a low cost method of
obtaining information from inside the MCU. Usually it should not be necessary to configure
the SWO speed because this is usually done by the debugger.
Example 1
Example 2
Both debuggers share the same physical connection. The core to debug is selected through
the JTAG-settings as described below.
The sketch below shows a host, running two application programs. Each application com-
municates with one CPU core via a separate J-Link.
Older J-Links may report USB0-3 instead of unique serial number when enumerating via
USB. For these J-Links, we recommend to re-configure them to use the new enumeration
method (report real serial number) since the USB0-3 behavior is obsolete.
Re-configuration can be done by using the J-Link Configurator, which is part of the J-Link
Software and Documentation Package. For further information about the J-Link Configurator
and how to use it, please refer to J-Link Configurator .
7.8.1 Tabs
The J-Link status window supports different features which are grouped in tabs. The orga-
nization of each tab and the functionality which is behind these groups will be explained
in this section
7.8.1.1 General
In the General section, general information about J-Link and the target hardware are shown.
Moreover the following general settings can be configured:
• Show tray icon: If this checkbox is disabled the tray icon will not show from the next
time the DLL is loaded.
• Start minimized: If this checkbox is disabled the J-Link status window will show up
automatically each time the DLL is loaded.
• Always on top: If this checkbox is enabled the J-Link status window is always visible
even if other windows will be opened.
The general information about target hardware and J-Link which are shown in this section,
are:
• Process: Shows the path of the file which loaded the DLL.
• J-Link: Shows OEM of the connected J-Link, the hardware version and the Serial number.
If no J-Link is connected it shows “not connected” and the color indicator is red.
• Target interface: Shows the selected target interface (JTAG/SWD) and the current JTAG
speed. The target current is also shown. (Only visible if J-Link is connected)
• Endian: Shows the target endianness (Only visible if J-Link is connected)
• Device: Shows the selected device for the current debug session.
• License: Opens the J-Link license manager.
• About: Opens the about dialog.
7.8.1.2 Settings
In the Settings section project- and debug-specific settings can be set. It allows the con-
figuration of the use of flash download and flash breakpoints and some other target specific
settings which will be explained in this topic. Settings are saved in the configuration file.
This configuration file needs to be set by the debugger. If the debugger does not set it, set-
tings can not be saved. All settings which are modified during the debug session have to be
saved by pressing Save settings, otherwise they are lost when the debug session is closed.
• Auto: This is the default setting of J-Link FlashDL usage. If a license is found J-Link
FlashDL is enabled. Otherwise J-Link FlashDL will be disabled internally.
• On: Enables the J-Link FlashDL feature. If no license has been found an error message
appears.
• Off: Disables the J-Link FlashDL feature.
• Skip download on CRC match: J-Link checks the CRC of the flash content to determine if
the current application has already been downloaded to the flash. If a CRC match occurs,
the flash download is not necessary and skipped. (Only available if J-Link FlashDL usage
is configured as Auto or On )
• Verify download: If this checkbox is enabled J-Link verifies the flash content after the
download. (Only available if J-Link FlashDL usage is configured as Auto or On )
• Auto: This is the default setting of FlashBP usage. If a license has been found the FlashBP
feature will be enabled. Otherwise FlashBP will be disabled internally.
• On: Enables the FlashBP feature. If no license has been found an error message appears.
• Off: Disables the FlashBP feature.
• Show window during program : When this checkbox is enabled the “Programming flash”
window is shown when flash is re-programmed in order to set/clear flash breakpoints.
• Log file: Shows the path where the J-Link log file is placed. It is possible to override
the selection manually by enabling the Override checkbox. If the Override checkbox is
enabled a button appears which let the user choose the new location of the log file.
• Settings file: Shows the path where the configuration file is placed. This configuration
file contains all the settings which can be configured in the Settings tab.
• Override device selection: If this checkbox is enabled, a dropdown list appears, which
allows the user to set a device manually. This especially makes sense when J-Link can
not identify the device name given by the debugger or if a particular device is not yet
known to the debugger, but to the J-Link software.
• Allow caching of flash contents : If this checkbox is enabled, the flash contents are
cached by J-Link to avoid reading data twice. This speeds up the transfer between
debugger and target.
• Allow instruction set simulation: If this checkbox is enabled, instructions will be
simulated as far as possible. This speeds up single stepping, especially when FlashBPs
are used.
• Save settings: When this button is pushed, the current settings in the Settings tab will
be saved in a configuration file. This file is created by J-Link and will be created for each
project and each project configuration (e.g. Debug_RAM, Debug_Flash). If no settings
file is given, this button is not visible.
• Modify breakpoints during execution: This dropdown box allows the user to change
the behavior of the DLL when setting breakpoints if the CPU is running. The following
options are available:
Allow: Allows settings breakpoints while the CPU is running. If the CPU needs to be
halted in order to set the breakpoint, the DLL halts the CPU, sets the breakpoints and
restarts the CPU.
Allow if CPU does not need to be halted: Allows setting breakpoints while the CPU is
running, if it does not need to be halted in order to set the breakpoint. If the CPU has
to be halted the breakpoint is not set.
Ask user if CPU needs to be halted: If the user tries to set a breakpoint while the CPU
is running and the CPU needs to be halted in order to set the breakpoint, the user is
asked if the breakpoint should be set. If the breakpoint can be set without halting the
CPU, the breakpoint is set without explicit confirmation by the user.
Do not allow: It is not allowed to set breakpoints while the CPU is running.
7.8.1.3 Break/Watch
In the Break/Watch section all breakpoints and watchpoints which are in the DLL internal
breakpoint and watchpoint list are shown.
Section: Code
Lists all breakpoints which are in the DLL internal breakpoint list are shown.
• Handle: Shows the handle of the breakpoint.
• Address: Shows the address where the breakpoint is set.
• Mode: Describes the breakpoint type (ARM/THUMB)
• Permission: Describes the breakpoint implementation flags.
• Implementation: Describes the breakpoint implementation type. The breakpoint types
are: RAM, Flash, Hard. An additional TBC (to be cleared) or TBS (to be set) gives
information about if the breakpoint is (still) written to the target or if it’s just in the
breakpoint list to be written/cleared.
Note
It is possible for the debugger to bypass the breakpoint functionality of the J-Link soft-
ware by writing to the debug registers directly. This means for ARM7/ARM9 cores write
accesses to the ICE registers, for Cortex-M3 devices write accesses to the memory
mapped flash breakpoint registers and in general simple write accesses for software
breakpoints (if the program is located in RAM). In these cases, the J-Link software
cannot determine the breakpoints set and the list is empty.
Section: Data
In this section, all data breakpoints which are listed in the DLL internal breakpoint list are
shown.
• Handle: Shows the handle of the data breakpoint.
• Address: Shows the address where the data breakpoint is set.
• AddrMask: Specifies which bits of Address are disregarded during the comparison for a
data breakpoint match. (A 1 in the mask means: disregard this bit)
• Data: Shows on which data to be monitored at the address where the data breakpoint
is set.
• Data Mask: Specifies which bits of Data are disregarded during the comparison for a
data breakpoint match. (A 1 in the mask means: disregard this bit)
• Ctrl: Specifies the access type of the data breakpoint (read/write).
• CtrlMask: Specifies which bits of Ctrl are disregarded during the comparison for a data
breakpoint match.
7.8.1.4 Log
In this section the log output of the DLL is shown. The user can determine which function
calls should be shown in the log window. Available function calls to log: Register read/write,
Memory read/write, set/clear breakpoint, step, go, halt, is halted.
7.8.1.7 SWV
In this section SWV information are shown.
• Status: Shows the encoding and the baudrate of the SWV data received by the target
(Manchester/UART, currently J-Link only supports UART encoding).
• Bytes in buffer: Shows how many bytes are in the DLL SWV data buffer.
• Bytes transferred: Shows how many bytes have been transferred via SWV, since the
debug session has been started.
• Refresh counter: Shows how often the SWV information in this section has been updated
since the debug session has been started.
• Host buffer: Shows the reserved buffer size for SWV data, on the host side.
• Emulator buffer: Shows the reserved buffer size for SWV data, on the emulator side.
What is the problem if the core executes some instructions after RESET?
The instructions which are executed can cause various problems. Some cores can be com-
pletely “confused”, which means they can not be switched into debug mode (CPU can not be
halted). In other cases, the CPU may already have initialized some hardware components,
causing unexpected interrupts or worse, the hardware may have been initialized with ille-
gal values. In some of these cases, such as illegal PLL settings, the CPU may be operated
beyond specification, possibly locking the CPU.
Note
It is recommended that the correct device is selected in the debugger so the debugger
can pass the device name to the J-Link DLL which makes it possible for J-Link to
detect what is the best reset strategy for the device. Moreover, we recommend that
the debugger uses reset type 0 to allow J-Link to dynamically select what reset is the
best for the connected device.
Note
In most cases it is not recommended to reset the core only since most target applica-
tions rely of the reset state of some peripherals (PLL, External memory interface etc.)
and may be confused if they boot up but the peripherals are already configured.
reset (since it might initialize some target settings to their reset state). When using this
reset strategy, J-Link will let the bootloader run after reset and halts the target immediately
after the bootloader and before the target application is started. This is the recommended
reset strategy for LPC11xx and LPC13xx devices where a bootloader should execute after
reset to put the chip into the “real” reset state.
7.9.2.8 Type 7: Reset for Analog Devices CPUs (ADI Halt after kernel)
Performs a reset of the core and peripherals by setting the SYSRESETREQ bit in the AIRCR.
The core is allowed to perform the ADI kernel (which enables the debug interface) but the
core is halted before the first instruction after the kernel is executed in order to guarantee
that no user application code is performed after reset.
quest or halted by vector catch). When using this reset strategy, J-Link performs a reset
of the CPU and peripherals, using the SYSRESETREQ bit and sets VC_CORERESET in order
to halt the CPU after reset, before it executes a single instruction. Then the watchdog of
the S3FN60D device is disabled.
Action Prototype
ConfigTargetSettings() int ConfigTargetSettings (void);
InitTarget() int InitTarget (void);
SetupTarget() int SetupTarget (void);
ResetTarget() int ResetTarget (void);
InitEmu() int InitEMU (void);
OnTraceStop() int OnTraceStop (void);
OnTraceStart() int OnTraceStart (void);
AfterResetTarget() int AfterResetTarget (void);
SWO_EnableTarget() int SWO_EnableTarget (void);
SWO_GetSWOBaseClock() U32 SWO_GetSWOBaseClock (U32 CPUclock);
HandleBeforeFlashProg() int HandleBeforeFlashProg (void);
HandleAfterFlashProg() int HandleAfterFlashProg (void);
StartETM() int StartETM (void);
StopETM() int StopETM (void);
StartTPIU() int StartTPIU (void);
StopTPIU() int StopTPIU (void);
StartTMC() int StartTMC (void);
StopTMC() int StopTMC (void);
StartPTM() int StartPTM (void);
StopPTM() int StopPTM (void);
StartTF() int StartTF (void);
StopTF() int StopTF (void);
StartETB() int StartETB (void);
StopETB() int StopETB (void);
7.12.1.1 ConfigTargetSettings()
Called before InitTarget(). Mainly used to set some global DLL variables to customize the
normal connect procedure. For ARM CoreSight devices this may be specifying the base
address of some CoreSight components (ETM, …) that cannot be auto-detected by J-Link
due to erroneous ROM tables etc. May also be used to specify the device name in case
debugger does not pass it to the DLL.
Prototype
int ConfigTargetSettings(void);
Notes / Limitations
• May not, under absolutely NO circumstances, call any API functions that perform target
communication.
• Should only set some global DLL variables
7.12.1.2 InitTarget()
Replaces the target-CPU-auto-find procedure of the J-Link DLL. Useful for target CPUs that
are not accessible by default and need some special steps to be executed before the normal
debug probe connect procedure can be executed successfully. Example devices are MCUs
from TI which have a so-called ICEPick JTAG unit on them that needs to be configured via
JTAG, before the actual CPU core is accessible via JTAG.
Prototype
int InitTarget(void);
Notes / Limitations
• If target interface JTAG is used: JTAG chain has to be specified manually before leaving
this function (meaning all devices and their TAP IDs have to be specified by the user).
Also appropriate JTAG TAP number to communicate with during the debug session has
to be manually specified in this function.
• MUST NOT use any MEM_ API functions
• Global DLL variable “CPU” MUST be set when implementing this function, so the DLL
knows which CPU module to use internally.
7.12.1.3 SetupTarget()
If present, called after InitTarget() and after general debug connect sequence has been
performed by J-Link. Usually used for more high-level CPU debug setup like writing certain
memory locations, initializing PLL for faster download etc.
Prototype
int SetupTarget(void);
Notes / Limitations
• Does not replace any DLL functionality but extends it.
• May use MEM_ API functions
7.12.1.4 ResetTarget()
Replaces reset strategies of DLL. No matter what reset type is selected in the DLL, if this
function is present, it will be called instead of the DLL internal reset.
Prototype
int ResetTarget(void);
Notes / Limitations
• DLL expects target CPU to be halted / in debug mode, when leaving this function
• May use MEM_ API functions
7.12.1.5 InitEMU()
This function can be used to initialize the emulator settings like for example the host in-
terface (e.g. in case of it cannot be selected in the IDE). This function should be used
thoughtful and only if you know exactly what you are doing as there are many things which
needs to be taken into account. Currently this function is only used to override the host
interface (USB or IP). It will be called right before the connection to the emulator is opened.
Prototype
int InitEMU(void);
7.12.1.6 OnTraceStop()
Called right before capturing of trace data is stopped on the J-Link / J-Trace. On some
target, an explicit flush of the trace FIFOs is necessary to get the latest trace data. If such
a flush is not performed, the latest trace data may not be output by the target
Prototype
int OnTraceStop(void);
Notes / Limitations
• May use MEM_ functions
7.12.1.7 OnTraceStart()
If present, called right before trace is started. Used to initialize MCU specific trace related
things like configuring the trace pins for alternate function.
Prototype
int OnTraceStart(void);
Notes / Limitations
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.8 AfterResetTarget()
If present, called after ResetTarget(). Usually used to initialize peripheries which have been
reset during reset, disable watchdogs which may be active after reset, etc… Apart from this,
for some cores it is necessary to perform some special operations after reset to guarantee
proper device functionality after reset. This is mainly the case on devices which have some
bugs that occur at the time of a system reset (not power on reset).
Prototype
int AfterResetTarget(void);
Notes / Limitations
• DLL expects target CPU to be halted / in debug mode, when leaving this function
• May use MEM_ API functions
7.12.1.9 SWO_EnableTarget()
If present, called before SWO_GetSWOBaseClock(). Used for target device that need ad-
ditional init steps to enable SWO. For example if there are none CoreSight registers that
need to be enabled or more than one pin can be configured to be the SWO pin.
Prototype
int SWO_EnableTarget(void);
Notes / Limitations
• This function should only be called if the target device needs extra initialization of SWO
registers that are not generic.
7.12.1.10 SWO_GetSWOBaseClock()
Determines the actual SWO base clock that is supplied by the device to the SWO CoreSight
logic. On most devices it is CPUClock / 1 but there are exceptions for which this function
can be used for.
Prototype
U32 SWO_GetSWOBaseClock(U32 CPUClock);
Parameter Description
CPUClock Measured CPU clock speed in Hz
<ReturnValue>
The return value is the actual SWO base clock speed.
Notes / Limitations
• This function should only be called if the target device has some other SWO base clock
than CPUClock / 1.
7.12.1.11 HandleBeforeFlashProg()
If present, called right before flash programming is performed Usually used to initialize
peripherals which are used during the flash download like for example clocks or port pins
(e.g. QSPI alternate function)
Prototype
int HandleBeforeFlashProg(void);
Notes / Limitations
• DLL expects target CPU to be halted / in debug mode, when leaving this function
• May use MEM_ API functions
7.12.1.12 HandleAfterFlashProg()
If present, called right after flash programming Usually used to restore initialized periph-
erals which have been used during the flash download like for example clocks or port pins
(e.g. QSPI alternate function)
Prototype
int HandleAfterFlashProg(void);
Notes / Limitations
• DLL expects target CPU to be halted / in debug mode, when leaving this function
• May use MEM_ API functions
7.12.1.13 StartETM()
If present, replaces generic initialization of Embedded Trace Macrocell (ETM) trace settings.
Used for target devices that need different init steps for ETM which are not set automatically
by J-Link/J-Trace.
Prototype
int StartETM(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.14 StopETM()
If present, replaces generic deinitialization of Embedded Trace Macrocell (ETM) trace set-
tings. Used for target devices that need different deinit steps for ETM which are not set
automatically by J-Link/J-Trace.
Prototype
int StopETM(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.15 StartETB()
If present, replaces generic initialization of Embedded Trace Buffer (ETB) trace settings.
Used for target devices that need different init steps for ETB which are not set automatically
by J-Link/J-Trace.
Prototype
int StartETB(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.16 StopETB()
If present, replaces generic deinitialization of Embedded Trace Buffer (ETB) trace settings.
Used for target devices that need different deinit steps for ETB which are not set automat-
ically by J-Link/J-Trace.
Prototype
int StopETB(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.17 StartTPIU()
If present, replaces generic initialization of Trace Port Interface Unit (TPIU) trace settings.
Used for target devices that need different init steps for TPIU which are not set automatically
by J-Link/J-Trace.
Prototype
int StartTPIU(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.18 StopTPIU()
If present, replaces generic deinitialization of Trace Port Interface Unit (TPIU) trace set-
tings. Used for target devices that need different deinit steps for TPIU which are not set
automatically by J-Link/J-Trace.
Prototype
int StopTPIU(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.19 StartTMC()
If present, replaces generic initialization of Trace Memory Controller (TMC) trace settings.
Used for target devices that need different init steps for TMC which are not set automatically
by J-Link/J-Trace.
Prototype
int StartTMC(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.20 StopTMC()
If present, replaces generic deinitialization of Trace Memory Controller (TMC) trace settings.
Used for target devices that need different deinit steps for TMC which are not set automat-
ically by J-Link/J-Trace.
Prototype
int StopTMC(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.21 StartTF()
If present, replaces generic initialization of Trace Funnel (TF) trace settings. Used for target
devices that need different init steps for TF which are not set automatically by J-Link/J-
Trace.
Prototype
int StartTF(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.22 StopTF()
If present, replaces generic deinitialization of Trace Funnel (TF) trace settings. Used for
target devices that need different deinit steps for TF which are not set automatically by
J-Link/J-Trace.
Prototype
int StopTF(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.23 StartPTM()
If present, replaces generic initialization of Program Flow Trace (PTM) trace settings. Used
for target devices that need different init steps for PTM which are not set automatically
by J-Link/J-Trace.
Prototype
int StartPTM(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.1.24 StopPTM()
If present, replaces generic initialization of Program Flow Trace (PTM) trace settings. Used
for target devices that need different init steps for PTM which are not set automatically
by J-Link/J-Trace.
Prototype
int StopPTM(void);
Notes / Limitations
• Only to be used if you are familiar with trace initializations. If the generic initialization
from J-Link software produces a trace output, do not use this function!
• May use high-level API functions like JLINK_MEM_ etc.
• Should not call JLINK_TARGET_Halt(). Can rely on target being halted when entering
this function.
7.12.2.1 JLINK_C2_ReadAddr()
Reads the address register of the C2 interface.
Prototype
int JLINK_C2_ReadAddr(U32* pAddr);
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.2 JLINK_C2_WriteAddr()
Writes the address register of the C2 interface.
Prototype
int JLINK_C2_WriteAddr(U32 Addr);
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.3 JLINK_C2_ReadData()
Reads the data register of the C2 interface.
Prototype
int JLINK_C2_ReadData(U8* pData, int NumItems);
Parameter Description
pData Pointer to buffer to read to
NumItems NumBytes to read
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.4 JLINK_C2_WriteData()
Writes the data register of the C2 interface.
Prototype
int JLINK_C2_WriteData(const U8* pData, int NumItems);
Parameter Description
pData Pointer to data to write
NumItems NumBytes to write
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.5 JLINK_CORESIGHT_AddAP()
Allows the user to manually configure the AP-layout of the device J-Link is connected to.
This makes sense on targets on which J-Link can not perform a auto-detection of the APs
which are present on the target system. Type can only be a known global J-Link DLL AP
constant. For a list of all available constants, please refer to Global DLL constants .
Prototype
int JLINK_CORESIGHT_AddAP(int Index, U32 Type);
Parameter Description
Index AP Index
Type AP Type
Return Value
Return
Description
value
≥0 O.K.
<0 Error
Example
7.12.2.6 JLINK_CORESIGHT_Configure()
Has to be called once, before using any other _CORESIGHT_ function that accesses the
DAP. Takes a configuration string to prepare target and J-Link for CoreSight function usage.
Configuration string may contain multiple setup parameters that are set. Setup parameters
are separated by a semicolon.
At the end of the JLINK_CORESIGHT_Configure(), the appropriate target interface switch-
ing sequence for the currently active target interface is output, if not disabled via setup
parameter.
This function has to be called again, each time the JTAG chain changes (for dynamically
changing JTAG chains like those which include a TI ICEPick), in order to setup the JTAG
chain again.
For JTAG
The SWD -> JTAG switching sequence is output. This also triggers a TAP reset on the
target (TAP controller goes through -> Reset -> Idle state) The IRPre, DRPre, IRPost,
DRPost parameters describe which device inside the JTAG chain is currently selected for
communication.
For SWD
The JTAG -> SWD switching sequence is output. It is also made sure that the “overrun mode
enable” bit in the SW-DP CTRL/STAT register is cleared, as in SWD mode J-Link always
assumes that overrun detection mode is disabled.
Make sure that this bit is NOT set by accident when writing the SW-DP CTRL/STAT register
via the _CORESIGHT_ functions.
Prototype
int JLINK_CORESIGHT_Configure(const char* sConfig);
Return Value
Return
Description
value
≥0 O.K.
<0 Error
= -2 Not supported by the current CPU + target interface combination
Example
if (JLINK_ActiveTIF == JLINK_TIF_JTAG) {
// Simple setup where we have TDI -> Cortex-M (4-bits IRLen) -> TDO
JLINK_CORESIGHT_Configure("IRPre=0;DRPre=0;IRPost=0;DRPost=0;IRLenDevice=4");
} else {
// For SWD, no special setup is needed, just output the switching sequence
JLINK_CORESIGHT_Configure("");
}
v = JLINK_CORESIGHT_ReadDP(JLINK_CORESIGHT_DP_REG_CTRL_STAT);
JLINK_SYS_Report1("DAP-CtrlStat: " v);
// Complex setup where we have
// TDI -> ICEPick (6-bits IRLen) -> Cortex-M (4-bits IRLen) -> TDO
JLINK_CORESIGHT_Configure("IRPre=0;DRPre=0;IRPost=6;DRPost=1;IRLenDevice=4;");
v = JLINK_CORESIGHT_ReadDP(JLINK_CORESIGHT_DP_REG_CTRL_STAT);
JLINK_SYS_Report1("DAP-CtrlStat: " v)
7.12.2.7 JLINK_CORESIGHT_ReadAP()
Reads a specific AP register. For JTAG, makes sure that AP is selected automatically. Makes
sure that actual data is returned, meaning for register read-accesses which usually only
return data on the second access, this function performs this automatically, so the user
will always see valid data.
Prototype
int JLINK_CORESIGHT_ReadAP(int RegIndex);
Parameter Description
RegIndex Specifies the index of the AP register to read.
Return
Description
value
≠ -1 Data read
= -1 Error
Example
v = JLINK_CORESIGHT_ReadAP(JLINK_CORESIGHT_AP_REG_DATA);
JLINK_SYS_Report1("DATA: " v);
7.12.2.8 JLINK_CORESIGHT_ReadDP()
Reads a specific DP register. For JTAG, makes sure that DP is selected automatically. Makes
sure that actual data is returned, meaning for register read-accesses which usually only
return data on the second access, this function performs this automatically, so the user
will always see valid data.
Prototype
int JLINK_CORESIGHT_ReadDP(int RegIndex);
Parameter Description
RegIndex Specifies the index of the DP register to read.
Return
Description
value
≠ -1 Data read
= -1 Error
Example
v = JLINK_CORESIGHT_ReadDP(JLINK_CORESIGHT_DP_REG_IDCODE);
JLINK_SYS_Report1("DAP-IDCODE: " v);
7.12.2.9 JLINK_CORESIGHT_ReadDAP()
Reads a specific AP/DP register. For JTAG, makes sure that AP/DP is selected automatically.
Makes sure that actual data is returned, meaning for register read-accesses which usually
only return data on the second access, this function performs this automatically, so the
user will always see valid data.
Prototype
int JLINK_CORESIGHT_ReadDAP(int RegIndex, int APnDP, U32* Data);
Parameter Description
RegIndex Specifies the index of the AP/DP register to read.
0: DP register
APnDP
1: AP register
Data Pointer to buffer for data read
Return Value
Return
Description
value
O.K. (Number of repetitions needed before read was accepted / returned valid
≥0
data)
<0 Error
Example
JLINK_CORESIGHT_ReadDAP(JLINK_CORESIGHT_DP_REG_IDCODE, 0, v);
JLINK_SYS_Report1("DAP-IDCODE: " v);
7.12.2.10 JLINK_CORESIGHT_WriteAP()
Writes a specific AP register. For JTAG, makes sure that AP is selected automatically.
Prototype
int JLINK_CORESIGHT_WriteAP(int RegIndex, U32 Data);
Parameter Description
RegIndex Specifies the index of the AP register to write.
Data Data to be written
Return Value
Return
Description
value
≥0 O.K. (Number of repetitions needed before write was accepted)
<0 Error
= -2 Not supported by the current CPU + target interface combination
Example
JLINK_CORESIGHT_WriteAP(JLINK_CORESIGHT_AP_REG_BD1, 0x1E);
7.12.2.11 JLINK_CORESIGHT_WriteDP()
Writes a specific DP register. For JTAG, makes sure that DP is selected automatically.
Prototype
int JLINK_CORESIGHT_WriteDP(int RegIndex, U32 Data);
Parameter Description
RegIndex Specifies the index of the DP register to write.
Data Data to be written
Return Value
Return
Description
value
≥0 O.K. (Number of repetitions needed before write was accepted)
<0 Error
= -2 Not supported by the current CPU + target interface combination
Example
JLINK_CORESIGHT_WriteDP(JLINK_CORESIGHT_DP_REG_ABORT, 0x1E);
7.12.2.12 JLINK_CORESIGHT_WriteDAP()
Writes to a CoreSight AP/DP register. This function 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.
Prototype
int JLINK_CORESIGHT_WriteDAP(int RegIndex, int APnDP, U32 Data);
Parameter Description
RegIndex Specifies the index of the AP/DP register to write.
0: DP register
APnDP
1: AP register
Data Data to be written
Return Value
Return
Description
value
≥0 O.K. (Number of repetitions needed before write was accepted)
<0 Error
= -2 Not supported by the current CPU + target interface combination
Example
JLINK_CORESIGHT_WriteDAP(JLINK_CORESIGHT_DP_REG_ABORT, 0, 0x1E);
7.12.2.13 JLINK_ExecCommand()
Gives the option to use J-Link Command Strings in the J-Link script file.
Prototype
int JLINK_ExecCommand(const char* sMsg);
Return Value
Return
Description
value
≥0 O.K.
<0 Error
Example
JLINK_ExecCommand("TraceSampleAdjust TD=2000");
Note
Has no effect when executed in Flasher stand-alone mode or when calling this function
from a function that implements the __probe attribute.
7.12.2.14 JLINK_GetTime()
Returns J-Link (DLL) uptime in milliseconds.
Intended usage: timeouts and time measurements.
Prototype
int JLINK_GetTime(void);
7.12.2.15 JLINK_GetPinState()
Gets the state of a specific pin.
Prototype
int JLINK_GetPinState(U8 iPin);
Parameter Description
iPin Specifies the pin to get the state from
Parameter iPin
Value Description
0 Pin 3
1 Pin 5
2 Pin 7
3 Pin 9
4 Pin 11
5 Pin 13
6 Pin 15
7 Pin 17
Return Value
Return
Description
value
=1 Pin state is HIGH
=0 Pin state is LOW
Getting state for this pin
<0 is not supported by this
J-Link
7.12.2.16 JLINK_JTAG_GetDeviceId()
Retrieves the JTAG ID of a specified device, in the JTAG chain. The index of the device
depends on its position in the JTAG chain. The device closest to TDO has index 0.
Prototype
int JLINK_JTAG_GetDeviceId(int DeviceIndex);
Return Value
Return
Description
value
>0 Device ID
=0 No JTAG device found at Index
Example
/*********************************************************************
*
* SetupTarget
*/
int SetupTarget(void) {
int r;
r = JLINK_JTAG_GetDeviceId(0);
JLINK_SYS_Report1("Device 0: ", r);
r = JLINK_JTAG_GetDeviceId(1);
JLINK_SYS_Report1("Device 1: ", r);
return 0;
}
Device 0: 0x3BA00477
Device 1: 0x06430041
7.12.2.17 JLINK_JTAG_GetU32()
Gets 32 bits JTAG data, starting at given bit position.
Prototype
int JLINK_JTAG_GetU32(int BitPos);
7.12.2.18 JLINK_JTAG_ReadWriteBits()
This function stores the specified number of bits in the output buffers, transfers the whole
content of the output buffers to the JTAG device(s) and stores the received data in the
input buffer.
Prototype
int JLINK_JTAG_ReadWriteBits(const U8 * pTDI, U8 * pTMS, U8 * pTDO, unsigned
NumBits);
Parameter Description
pTDI Pointer to input buffer
pTMS Pointer to mode select buffer
pTDO Pointer to output buffer
NumBits Number of bits to read and write
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.19 JLINK_JTAG_Reset()
Performs a TAP reset and tries to auto-detect the JTAG chain (Total IRLen, Number of
devices). If auto-detection was successful, the global DLL variables which determine the
JTAG chain configuration, are set to the correct values. For more information about the
known global DLL variables, please refer to Global DLL variables .
Note
This will not work for devices which need some special init (for example to add the
core to the JTAG chain), which is lost at a TAP reset.
Prototype
int JLINK_JTAG_Reset(void);
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.20 JLINK_JTAG_SetDeviceId()
Sets the JTAG ID of a specified device, in the JTAG chain. The index of the device depends
on its position in the JTAG chain. The device closest to TDO has index 0. The Id is used
by the DLL to recognize the device. Before calling this function, please make sure that the
JTAG chain has been configured correctly by setting the appropriate global DLL variables.
For more information about the known global DLL variables, please refer to Global DLL
variables .
Prototype
int JLINK_JTAG_SetDeviceId(int DeviceIndex, U32 Id);
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.21 JLINK_JTAG_StartDR()
Brings the state machine of the selected device in the JTAG-chain in SHIFT-DR state.
Prototype
int JLINK_JTAG_StartDR(void);
Return Value
Return
Description
value
≥1 Bit position in JTAG buffer
=0 Error
7.12.2.22 JLINK_JTAG_Store()
Stores a JTAG sequence (max. 64 bits per pin) in the DLL JTAG buffer.
Prototype
int JLINK_JTAG_Store(U32 tms, U32 tdi, U32 NumBits);
Parameter Description
tms Bitmask to output on TMS
tdi Bitmask to output on TDI
NumBits NumBits to store for each pin. Maximum 32.
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.23 JLINK_JTAG_StoreClocks()
Stores a given number of clocks in the DLL JTAG buffer.
Prototype
int JLINK_JTAG_StoreClocks(int NumClocks);
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.24 JLINK_JTAG_StoreDR()
Stores JTAG data in the DLL JTAG buffer.
Before calling this function, please make sure that the JTAG chain has been configured
correctly by setting the appropriate global DLL variables. For more information about the
known global DLL variables, please refer to Global DLL variables .
Prototype
int JLINK_JTAG_StoreDR(U32 tdi, int NumBits);
Parameter Description
tdi Bitmask to output on TDI
NumBits NumBits to store
Return Value
Returns the bit position.
7.12.2.25 JLINK_JTAG_StoreIR()
Stores a JTAG instruction in the DLL JTAG buffer.
Before calling this function, please make sure that the JTAG chain has been configured
correctly by setting the appropriate global DLL variables. For more information about the
known global DLL variables, please refer to Global DLL variables .
Prototype
int JLINK_JTAG_StoreIR(U32 Cmd);
Return Value
Returns the bit position.
7.12.2.26 JLINK_JTAG_Write()
Writes a JTAG sequence (max. 64 bits per pin).
Prototype
int JLINK_JTAG_Write(U32 tms, U32 tdi, U32 NumBits);
Parameter Description
tms Bitmask to output on TMS
tdi Bitmask to output on TDI
NumBits NumBits to write
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.27 JLINK_JTAG_WriteClocks()
Writes a given number of clocks.
Prototype
int JLINK_JTAG_WriteClocks(int NumClocks);
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.28 JLINK_JTAG_WriteDR()
Writes JTAG data. Before calling this function, please make sure that the JTAG chain has
been configured correctly by setting the appropriate global DLL variables. For more infor-
mation about the known global DLL variables, please refer to Global DLL variables .
Prototype
int JLINK_JTAG_WriteDR(U32 tdi, int NumBits);
Parameter Description
tdi Bitmask to output on TDI
NumBits NumBits to store
Return Value
Returns the bit position.
7.12.2.29 JLINK_JTAG_WriteDRCont()
Writes data of variable length and remains in UPDATE-DR state. This function expects that
the JTAG chain has already be configured before. It does not try to perform any JTAG
identification before sending the DR-data.
Prototype
int JLINK_JTAG_WriteDRCont(U32 Data, int NumBits);
Return Value
Returns the bit position.
7.12.2.30 JLINK_JTAG_WriteDREnd()
Writes data of variable length and remains in UPDATE-DR state. This function expects that
the JTAG chain has already be configured before. It does not try to perform any JTAG
identification before sending the DR-data.
Prototype
int JLINK_JTAG_WriteDREnd(U32 Data, int NumBits);
Return Value
Returns the bit position.
7.12.2.31 JLINK_JTAG_WriteIR()
Writes a JTAG instruction.
Before calling this function, please make sure that the JTAG chain has been configured
correctly by setting the appropriate global DLL variables. For more information about the
known global DLL variables, please refer to Global DLL variables .
Prototype
int JLINK_JTAG_WriteIR(U32 Cmd);
Return Value
Returns the bit position.
7.12.2.32 JLINK_PIN_Override()
This function allows to override some of the J-Link pins and assign a special functionality to
them (GPIO, UART, …). For example setting the functionality to GPIO allows to implement
almost any protocol on these pins which can give some extra flexibility in some cases.
Prototype
int JLINK_PIN_Override(const U32* paMode, U32* paState);
Parameter Description
Pointer to JLINK_PIN_MAX_NUM_PINS-element array that holds the
configuration to be assigned to the pins. Each element of the ar-
paMode
ray describes a pin that can be overridden, resulting in a total of
JLINK_PIN_MAX_NUM_PINS pins that can be overridden.
Pointer to JLINK_PIN_MAX_NUM_PINS-element array that is used
to store the state of each pin. This for example can be used to read
paState the current data on the pin, if it is configured as JLINK_PIN_OVER-
RIDE_MODE_PIO_IN.
State may be = 0 for LOW or = 1 for HIGH.
Return Value
Return
Description
value
≥0 O.K.
<0 Error
Example
The following example shows how to output a default->low->(wait 2500ms)->high->(wait
2500ms)->default signal on pin 15 (= nRESET) after InitTarget()
/*********************************************************************
*
* SetupTarget
*/
int SetupTarget(void) {
int i;
int r;
i = 0;
do {
_aPINMode[i] = JLINK_PIN_OVERRIDE_MODE_RELEASE;
// Do not override any pin by default
i += 1;
} while(i < JLINK_PIN_MAX_NUM_PINS);
//
// Initially, we check if pin override is supported
//
r = JLINK_PIN_Override(&_aPINMode[0], &_aPINState[0]);
if (r < 0) {
JLINK_SYS_Report("ERROR: Pin override is not supported by the connected J-
Link");
return r;
}
_aPINMode[6] = JLINK_PIN_OVERRIDE_MODE_PIO_OUT_LOW;
r = JLINK_PIN_Override(&_aPINMode[0], &_aPINState[0]);
JLINK_SYS_Sleep(2500);
_aPINMode[6] = JLINK_PIN_OVERRIDE_MODE_PIO_OUT_HIGH;
r = JLINK_PIN_Override(&_aPINMode[0], &_aPINState[0]);
JLINK_SYS_Sleep(2500);
//
// Restore pin configuration of J-Link
//
i = 0;
do {
_aPINMode[i] = JLINK_PIN_OVERRIDE_MODE_RELEASE;
// Do not override any pin by default
i += 1;
} while(i < JLINK_PIN_MAX_NUM_PINS);
JLINK_PIN_Override(&_aPINMode[0], &_aPINState[0]);
return 0;
}
7.12.2.33 JLINK_MemRegion()
This command is used to specify memory areas with various region types.
Prototype
int JLINK_MemRegion(const char* sConfig);
Syntax of sConfig
<StartAddressOfArea>-<EndAddressOfArea> <RegionType>
Parameter RegionType
Region type Description
N Normal
C Cacheable
X Excluded
XI Excluded & Illegal
I Indirect access
Alias (static, e.g. RAM/flash that is aliased multiple times in one area.
A
Does not change during the debug session.)
Alias (dynamic, e.g. memory areas where different memories can be
AD
mapped to.)
Return
Description
value
≥0 O.K.
<0 Error
Example
JLINK_MemRegion(“0x100000-0x1FFFFF C”)
Note
Has no effect when executed in Flasher stand-alone mode or when calling this function
from a function that implements the __probe attribute.
7.12.2.34 JLINK_MEM_WriteU8()
Writes a byte to the specified address.
Prototype
int JLINK_MEM_WriteU8(U32 Addr, U32 Data);
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.35 JLINK_MEM_WriteU16()
Writes a halfword to the specified address.
Prototype
int JLINK_MEM_WriteU16(U32 Addr, U32 Data);
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.36 JLINK_MEM_WriteU32()
Writes a word to the specified address.
Prototype
int JLINK_MEM_WriteU32(U32 Addr, U32 Data);
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.37 JLINK_MEM_ReadU8()
Reads a byte from the specified address.
Prototype
U8 MEM_ReadU8 (U32 Addr);
7.12.2.38 JLINK_MEM_ReadU16()
Reads a halfword from the specified address.
Prototype
U16 MEM_ReadU16(U32 Addr);
7.12.2.39 JLINK_MEM_ReadU32()
Reads a word from the specified address.
Prototype
U32 MEM_ReadU32(U32 Addr);
7.12.2.40 JLINK_MEM_Preserve()
Preserves selected memory area in amount of set size.
Prototype
int JLINK_MEM_Preserve(U32 Addr, U32 NumBytes);
Parameter Description
Specifies the address starting
Addr
point which to preserve
NumBytes Number of bytes to preserve
Return Value
Return
Description
value
O.K., handle to preserved area (may be
≥0
used by JLINK_MEM_Restore())
<0 Error
-1 Unspecified error
-2 Failed to read memory to preserve
7.12.2.41 JLINK_MEM_Restore()
Restore memory that has been previously preserved via JLINK_MEM_Preserve(). Returned
handle is used to identify the restore region.
Prototype
int JLINK_MEM_Restore(int Handle);
Parameter Description
Specifies handle to identify the
Handle
restore region
Return Value
Return
Description
value
≥0 O.K.
<0 Error
-1 Unspecified error
-2 Failed to write memory to restore
7.12.2.42 JLINK_MEM_Fill()
Fill memory with given value. Only the lowest byte of <FillVal> is taken into account.
Prototype
int JLINK_MEM_Fill(U32 Addr, U32 NumBytes, U32 FillVal);
Parameter Description
Specifies the address starting
Addr
point which to preserve
NumBytes Number of bytes to preserve
FillVal Value used for filling
Return Value
Return
Description
value
O.K., handle to preserved area (may be
≥0
used by JLINK_MEM_Restore())
<0 Error
-1 Unspecified error
-2 Failed to read memory to fill
7.12.2.43 JLINK_SelectTIF()
Selects a target interface. For a list of all available constants, please refer to Constants for
global variable“JLINK_ActiveTIF”.
Prototype
void JLINK_SelectTIF(U32 tif);
7.12.2.44 JLINK_SetDevice()
Selects / specifies the target device.
Prototype
int JLINK_SetDevice(const char* sDevice);
sDevice has to be a valid device identifier. For a list of all available device identifiers, please
refer to Supported devices .
Return Value
Return
Description
value
≥0 O.K.
Return
Description
value
<0 Error
Example
JLINK_SetDevice("AT91SAM7S256");
7.12.2.45 JLINK_SWD_ReadWriteBits()
This function stores the specified number of bits in the output buffers, transfers the whole
content of the output buffers to the SWD device and stores the received data in the input
buffer.
Prototype
int JLINK_SWD_ReadWriteBits(const U8 * pDataIn, const U8 * pDirection, U8 *
pDataOut, int NumBits);
Parameter Description
pDataIn Pointer to data to be send to the target
pDirection Pointer to direction buffer
pDataOut Pointer to buffer for receiving data from target
NumBits Number of bits to read and write
Return Value
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.46 JLINK_SYS_MessageBox()
Outputs a string in a message box.
Prototype
int JLINK_SYS_MessageBox(const char * sMsg);
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.47 JLINK_SYS_MessageBox1()
Outputs a constant character string in a message box. In addition to that, a given value
(can be a constant value, the return value of a function or a variable) is added, right behind
the string.
Prototype
int JLINK_SYS_MessageBox1(const char * sMsg, int v);
Return
Description
value
≥0 O.K.
Return
Description
value
<0 Error
7.12.2.48 JLINK_SYS_Report()
Outputs a constant character string on stdio.
Prototype
int JLINK_SYS_Report(const char * sMsg);
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.49 JLINK_SYS_Report1()
Outputs a constant character string on stdio. In addition to that, a given value (can be a
constant value, the return value of a function or a variable) is added, right behind the string.
Prototype
int JLINK_SYS_Report1(const char * sMsg, int v);
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.50 JLINK_SYS_Sleep()
Waits for a given number of milliseconds. During this time, J-Link does not communicate
with the target.
Prototype
int JLINK_SYS_Sleep(int Delayms);
Return
Description
value
≥0 O.K.
<0 Error
7.12.2.51 JLINK_SYS_UnsecureDialog()
Informs the user that the device needs to be unsecured for further debugging. This is
usually done via a message box where possible (except on Linux & Mac).
Prototype
int JLINK_SYS_UnsecureDialog (const char* sText, const char* sQuestion, const
char* sIdent, int DefaultAnswer, U32 Flags);
Parameter Description
sText Text printed to the logfile or presented in a message box
sQuestion Question printed in the message box after sText
Parameter Description
Unique ID for the request. User settings like “Do not show again” are
sIdent
saved per Unique ID.
Default answer for messages with timeout or non-GUI versions. Only
DefaultAnswer
used if not setting is saved for the Unique ID.
Please consult the table below for valid values. Specifying a valid
Flags
JLINK_DLG_TYPE flag is mandatory.
Parameter Flags
Value Description
JLINK_DLG_TYPE_PROT_READ Read protection dialog
JLINK_DLG_TYPE_PROT_WRITE Write protection dialog
Return Value
Return
Description
value
=1 User selected to unsecure the device
=0 User selected to NOT unsecure the device
Note
If executed in Flasher stand-alone mode or when calling this function from a function
that implements the __probe attribute, no dialog is shown but the default answer is
used
7.12.2.52 JLINK_TARGET_IsHalted()
Checks if the target device is halted.
Prototype
int JLINK_TARGET_IsHalted(void);
Return Value
Return
Description
value
=1 O.K. CPU is halted
=0 O.K. CPU is not halted
<0 Error
Example
/*********************************************************************
*
* SetupTarget
*/
int SetupTarget(void) {
int r;
r = JLINK_TARGET_IsHalted();
if (r == 0) {
JLINK_SYS_Report("Target is not halted!");
} else if (r == 1) {
JLINK_SYS_Report("Target is halted!");
} else {
JLINK_SYS_Report("Error occurred!");
}
return 0;
}
7.12.2.53 JLINK_TARGET_Halt()
Halt the target device. Returns O.K. if the target is already halted.
Prototype
int JLINK_TARGET_Halt(void);
Return Value
Return
Description
value
=> 1 Error
=0 O.K.
Example
/*********************************************************************
*
* SetupTarget
*/
int SetupTarget(void) {
int r;
r = JLINK_TARGET_Halt();
if (r == 0) {
JLINK_SYS_Report("Target is halted!");
} else {
JLINK_SYS_Report("Error occurred!");
}
return 0;
}
7.12.2.54 JLINK_TIF_ActivateTargetReset()
Sets nReset LOW.
Prototype
void JLINK_TIF_ActivateTargetReset(void);
7.12.2.55 JLINK_TIF_ReleaseTargetReset()
Sets nReset HIGH.
Prototype
void JLINK_TIF_ReleaseTargetReset(void);
7.12.2.56 JLINK_TIF_SetClrTCK()
Sets or clears the TCK pin.
Prototype
void JLINK_TIF_SetClrTCK(int OnOff);
Parameter Description
OnOff Desired state of TCK
Parameter OnOff
Value Description
≥1 Set pin to HIGH
=0 Set pin to LOW
7.12.2.57 JLINK_TIF_SetClrTMS()
Sets or clears the TMS pin.
Prototype
void JLINK_TIF_SetClrTMS(int OnOff);
Parameter Description
OnOff Desired state of TMS
Parameter OnOff
Value Description
≥1 Set pin to HIGH
=0 Set pin to LOW
7.12.2.58 JLINK_TIF_SetClrTDI()
Sets or clears the TCK pin.
Prototype
void JLINK_TIF_SetClrTDI(int OnOff);
Parameter Description
OnOff Desired state of TDI
Parameter OnOff
Value Description
≥1 Set pin to HIGH
=0 Set pin to LOW
7.12.2.59 JLINK_TIF_SetSpeed()
Sets the target interface speed.
Prototype
void JLINK_TIF_SetSpeed(U32 Speed);
Parameter Description
Speed Speed in kHz.
set to the whole data type with. In the following all global variables and their value ranges
are listed and described.
Note
All global variables are treated as unsigned 32-bit values and are zero-initialized.
Legend
Abbreviation Description
RO: Variable is read-only
WO: Variable is write-only
R/W: Variable is read-write
• ARM7TDMIR3
• ARM7TDMIR4
• ARM7TDMIS
• ARM7TDMISR3
• ARM7TDMISR4
• ARM9
• ARM9TDMIS
• ARM920T
• ARM922T
• ARM926EJS
• ARM946EJS
• ARM966ES
• ARM968ES
• ARM11
• ARM1136
• ARM1136J
• ARM1136JS
• ARM1136JF
• ARM1136JFS
• ARM1156
• ARM1176
• ARM1176J
• ARM1176JS
• ARM1176IF
• ARM1176JFS
• CORTEX_M0
• CORTEX_M1
• CORTEX_M3
• CORTEX_M3R1P0
• CORTEX_M3R1P1
• CORTEX_M3R2P0
• CORTEX_M4
• CORTEX_M7
• CORTEX_A5
• CORTEX_A7
• CORTEX_A8
• CORTEX_A9
• CORTEX_A12
• CORTEX_A15
• CORTEX_A17
• CORTEX_R4
• CORTEX_R5
• JLINK_CORESIGHT_AP_REG_BD0
• JLINK_CORESIGHT_AP_REG_BD1
• JLINK_CORESIGHT_AP_REG_BD2
• JLINK_CORESIGHT_AP_REG_BD3
• JLINK_CORESIGHT_AP_REG_ROM
• JLINK_CORESIGHT_AP_REG_IDR
• const
• signed
• unsigned
void InitTarget(void) {
JLINK_SYS_Report("J-Link script example.");
JTAG_Reset(); // Perform TAP reset and J-Link JTAG auto-detection
if (JTAG_TotalIRLen != 9) { // Basic check if JTAG chain information matches
MessageBox("Can not find xxx device");
return 1;
}
JTAG_DRPre = 0; // Cortex-A8 is closest to TDO, no no pre devices
JTAG_DRPost = 1; // 1 device (custom device) comes after the Cortex-A8
JTAG_IRPre = 0; // Cortex-A8 is closest to TDO, no no pre IR bits
JTAG_IRPost = 5; // Custom device after Cortex-A8 has 5 bits IR len
JTAG_IRLen = 4; // We selected the Cortex-A8, it has 4 bits IRLen
CPU = CORTEX_A8; // We are connected to a Cortex-A8
JTAG_AllowTAPReset = 1; // We are allowed to enter JTAG TAP reset
//
// We have a non-CoreSight compliant Cortex-A8 here
// which does not allow auto-detection of the Core debug components base address.
// so set it manually to overwrite the DLL auto-detection
//
CORESIGHT_CoreBaseAddr = 0x80030000;
}
Command Description
AppendToLogFile Enables/Disables always appending new loginfo to logfile.
DisableCortexMXPSRAutoCorrect-
Disables auto-correction of XPSR T-bit for Cortex-M devices.
TBit
DisableFlashBPs Disables the FlashBP feature.
Command Description
Invalidate flash ranges in flash cache, that are configured to be
ExcludeFlashCacheRange
excluded from flash cache.
Reads the given memory area into the streaming trace instruc-
ReadIntoTraceCache
tion cache.
Used to power-down the debug unit of the target CPU when the
SetDbgPowerDownOnClose
debug session is closed.
Command Description
SetMonModeDebug Enables/Disables monitor mode debugging.
7.13.1.1 AppendToLogFile
This command can be used to configure the AppendToLogFile feature. If enabled, new log
data will always be appended to an existing logfile. Otherwise, each time a new connection
will be opened, existing log data will be overwritten. By default new log data will not be
always appended to an existing logfile.
Syntax
AppendToLogFile = 0 | 1
Example
AppendToLogFile 1 // Enables AppendToLogFile
7.13.1.2 CORESIGHT_SetIndexAHBAPToUse
This command is used to select a specific AHB-AP to be used when connected to an ARM
Cortex-M device. Usually, it is not necessary to explicitly select an AHB-AP to be used, as
J-Link auto-detects the AP automatically. For multi-core systems with multiple AHB-APs it
might be necessary.
The index selected here is an absolute index. For example, if the connected target provides
the following AP layout:
• AP[0]: AHB-AP
• AP[1]: APB-AP
• AP[2]: AHB-AP
• AP[3]: JTAG-AP
Syntax
CORESIGHT_SetIndexAHBAPToUse = <Index>
Example
CORESIGHT_SetIndexAHBAPToUse = 2
7.13.1.3 CORESIGHT_SetIndexAPBAPToUse
This command is used to select a specific APB-AP to be used when connected to an ARM
Cortex-A or Cortex-R device. Usually, it is not necessary to explicitly select an AHB-AP to
be used, as J-Link auto-detects the AP automatically. For multi-core systems with multiple
APB-APs it might be necessary.
The index selected here is an absolute index. For example, if the connected target provides
the following AP layout:
• AP[0]: APB-AP
• AP[1]: AHB-AP
• AP[2]: APB-AP
• AP[3]: JTAG-AP
In order to select the second APB-AP to be used, use “2” as index.
Syntax
CORESIGHT_SetIndexAPBAPToUse = <Index>
Example
CORESIGHT_SetIndexAPBAPToUse = 2
7.13.1.4 CORESIGHT_SetETBBaseAddr
This command can be used to set the Coresight ETB base address if the debug probe could
not get this information from the target devices ROM table.
Syntax
CORESIGHT_SetETBBaseAddr = <Addr>
Example
CORESIGHT_SetETBBaseAddr = 0xE0041000
7.13.1.5 CORESIGHT_SetMTBBaseAddr
This command can be used to set the Coresight MTB base address if the debug probe could
not get this information from the target devices ROM table.
Syntax
CORESIGHT_SetMTBBaseAddr = <Addr>
Example
CORESIGHT_SetMTBBaseAddr = 0xE0041000
7.13.1.6 CORESIGHT_SetETMBaseAddr
This command can be used to set the Coresight ETM base address if the debug probe could
not get this information from the target devices ROM table.
Syntax
CORESIGHT_SetETMBaseAddr = <Addr>
Example
CORESIGHT_SetETMBaseAddr = 0xE0041000
7.13.1.7 CORESIGHT_SetPTMBaseAddr
This command can be used to set the Coresight PTM base address if the debug probe could
not get this information from the target devices ROM table.
Syntax
CORESIGHT_SetPTMBaseAddr = <Addr>
Example
CORESIGHT_SetPTMBaseAddr = 0xE0041000
7.13.1.8 CORESIGHT_SetCSTFBaseAddr
This command can be used to set the Coresight TF(Trace Funnel) base address if the debug
probe could not get this information from the target devices ROM table.
Syntax
CORESIGHT_SetCSTFBaseAddr = <Addr>
Example
CORESIGHT_SetCSTFBaseAddr = 0xE0041000
7.13.1.9 CORESIGHT_SetTMCBaseAddr
This command can be used to set the Coresight TMC base address if the debug probe could
not get this information from the target devices ROM table.
Syntax
CORESIGHT_SetTMCBaseAddr = <Addr>
Example
CORESIGHT_SetTMCBaseAddr = 0xE0041000
7.13.1.10 CORESIGHT_SetTPIUBaseAddr
This command can be used to set the Coresight TPIU base address if the debug probe could
not get this information from the target devices ROM table.
Syntax
CORESIGHT_SetTPIUBaseAddr = <Addr>
Example
CORESIGHT_SetTPIUBaseAddr = 0xE0041000
7.13.1.11 device
This command selects the target device.
Syntax
device = <DeviceID>
DeviceID has to be a valid device identifier. For a list of all available device identifiers,
please refer to Supported devices .
Example
device = AT91SAM7S256
7.13.1.12 DisableAutoUpdateFW
This command is used to disable the automatic firmware update if a new firmware is avail-
able.
Syntax
DisableAutoUpdateFW
7.13.1.13 DisableCortexMXPSRAutoCorrectTBit
Usually, the J-Link DLL auto-corrects the T-bit of the XPSR register to 1, for Cortex-M
devices. This is because having it set as 0 is an invalid state and would cause several
problems during debugging, especially on devices where the erased state of the flash is
0x00 and therefore on empty devices the T-bit in the XPSR would be 0. Anyhow, if for some
reason explicit disable of this auto-correction is necessary, this can be achieved via the
following J-Link Command String.
Syntax
DisableCortexMXPSRAutoCorrectTBit
7.13.1.14 DisableFlashBPs
This command disables the FlashBP feature.
Syntax
DisableFlashBPs
7.13.1.15 DisableFlashDL
This command disables the J-Link FlashDL feature.
Syntax
DisableFlashDL
7.13.1.16 DisableInfoWinFlashBPs
This command is used to disable the flash download window for the flash breakpoint feature.
Enabled by default.
Syntax
DisableInfoWinFlashBPs
7.13.1.17 DisableInfoWinFlashDL
This command is used to disable the flash download information window for the flash down-
load feature. Enabled by default.
Syntax
DisableInfoWinFlashDL
7.13.1.18 DisableLowPowerHandlingMode
This command is used to disable low-power handling mode. For further information, please
refer to Activating low power mode handling for J-Link .
Disabled by default.
Syntax
DisableLowPowerHandlingMode
7.13.1.19 DisableMOEHandling
The J-Link DLL outputs additional information about mode of entry (MOE) in case the target
CPU halted / entered debug mode. Disabled by default.
Syntax
DisableMOEHandling
7.13.1.20 DisablePowerSupplyOnClose
This command is used to ensure that the power supply for the target will be disabled on
close.
Syntax
DisablePowerSupplyOnClose
7.13.1.21 EnableAutoUpdateFW
This command is used to enable the automatic firmware update if a new firmware is avail-
able.
Syntax
EnableAutoUpdateFW
7.13.1.22 EnableEraseAllFlashBanks
Used to enable erasing of other flash banks than the internal, like (Q)SPI flash or CFI flash.
Syntax
EnableEraseAllFlashBanks
7.13.1.23 EnableFlashBPs
This command enables the FlashBP feature.
Syntax
EnableFlashBPs
7.13.1.24 EnableFlashDL
This command enables the J-Link ARM FlashDL feature.
Syntax
EnableFlashDL
7.13.1.25 EnableInfoWinFlashBPs
This command is used to enable the flash download window for the flash breakpoint feature.
Enabled by default.
Syntax
EnableInfoWinFlashBPs
7.13.1.26 EnableInfoWinFlashDL
This command is used to enable the flash download information window for the flash down-
load feature.
Syntax
EnableInfoWinFlashDL
7.13.1.27 EnableLowPowerHandlingMode
Puts the DLL in low-power handling mode. For further information, please refer to Activating
low power mode handling for J-Link .
Disabled by default.
Syntax
EnableLowPowerHandlingMode
7.13.1.28 EnableMOEHandling
The J-Link DLL outputs additional information about mode of entry (MOE) in case the target
CPU halted / entered debug mode. Disabled by default. Additional information is output via
log-callback set with JLINK_OpenEx(JLINK_LOG* pfLog, JLINK_LOG* pfErrorOut)
Syntax
EnableMOEHandling
7.13.1.29 EnableRemarks
The J-Link DLL provides more detailed output during CPU-detection / connection process.
Kind of “verbose” option. Disabled by default, therefore only an enable option. Will be reset
to “disabled” on each call to JLINK_Open() (reconnect to J-Link).
Syntax
EnableRemarks
7.13.1.30 ExcludeFlashCacheRange
This command is used to invalidate flash ranges in flash cache, that are configured to be
excluded from the cache. Per default, all areas that J-Link knows to be Flash memory,
are cached. This means that it is assumed that the contents of this area do not change
during program execution. If this assumption does not hold true, typically because the
target program modifies the flash content for data storage, then the affected area should
be excluded. This will slightly reduce the debugging speed.
Syntax
ExcludeFlashCacheRange <Range>
Example
ExcludeFlashCacheRange 0x10000000-0x100FFFFF
Syntax
HideDeviceSelection = 0 | 1
Example
HideDeviceSelection 1 // Device selection will not show up
7.13.1.32 HSSLogFile
This command enables HSS-Logging. Separate to the application using HSS, all HSS Data
will be stored in the specified file.
Syntax
HSSLogFile = <Path>
Example
HSSLogFile = C:\Test.log
7.13.1.33 InvalidateCache
This command is used to invalidate cache.
Syntax
InvalidateCache
7.13.1.34 InvalidateFW
This command is used to invalidate the current firmware of the J-Link / J-Trace. Invalidating
the firmware will force a firmware update. Can be used for downdating. For more informa-
tion please refer to J-Link / J-Trace firmware .
Syntax
InvalidateFW
Memory mapping
Some devices do not allow access of the entire 4GB memory area. Ideally, the entire mem-
ory can be accessed; if a memory access fails, the CPU reports this by switching to abort
mode. The CPU memory interface allows halting the CPU via a WAIT signal. On some de-
vices, the WAIT signal stays active when accessing certain unused memory areas. This
halts the CPU indefinitely (until RESET) and will therefore end the debug session. This is
exactly what happens when accessing critical memory areas. Critical memory areas should
not be present in a device; they are typically a hardware design problem. Nevertheless,
critical memory areas exist on some devices.
To avoid stalling the debug session, a critical memory area can be excluded from access:
J-Link will not try to read or write to critical memory areas and instead ignore the access
silently. Some debuggers (such as IAR C-SPY) can try to access memory in such areas
by dereferencing non-initialized pointers even if the debugged program (the debuggee) is
working perfectly. In situations like this, defining critical memory areas is a good solution.
Syntax
map exclude <SAddr>-<EAddr>
Example
This is an example for the map exclude command in combination with an NXP LPC2148 MCU.
Memory map
Range Description
0x00000000-0x0007FFFF On-chip flash memory
0x00080000-0x3FFFFFFF Reserved
0x40000000-0x40007FFF On-chip SRAM
0x40008000-0x7FCFFFFF Reserved
0x7FD00000-0x7FD01FFF On-chip USB DMA RAM
0x7FD02000-0x7FD02000 Reserved
0x7FFFD000-0x7FFFFFFF Boot block (remapped from on-chip flash memory)
0x80000000-0xDFFFFFFF Reserved
0xE0000000-0xEFFFFFFF VPB peripherals
0xF0000000-0xFFFFFFFF AHB peripherals
Range Description
0x00080000-0x3FFFFFFF Reserved
0x40008000-0x7FCFFFFF Reserved
0x7FD02000-0x7FD02000 Reserved
0x80000000-0xDFFFFFFF Reserved
To exclude these areas from being accessed through J-Link the map exclude command
should be used as follows:
Syntax
Map Illegal <SAddr>-<EAddr>
Example
Map Illegal 0xF0000000-0xFFDFFFFF
Additional information
• SAddr has to be a 256-byte aligned address.
The region size has to be a multiple of 256 bytes.
the data of the specified memory area to the host. Before map indirectread can be called
a RAM area for the indirect read code snippet has to be defined. Use therefor the map ram
command and define a RAM area with a size of ≥ 256 byte.
Typical applications
Syntax
map indirectread <StartAddressOfArea>-<EndAddress>
Example
map indirectread 0x3fffc000-0x3fffcfff
Additional information
• StartAddressOfArea has to be a 256-byte aligned address.
The region size has to be a multiple of 256 bytes.
Typical applications
Syntax
map ram <StartAddressOfArea>-<EndAddressOfArea>
Example
map ram 0x40000000-0x40003fff;
Additional information
• StartAddressOfArea has to be a 256-byte aligned address.
The region size has to be a multiple of 256 bytes.
Syntax
map region <StartAddressOfArea>-<EndAddressOfArea> <RegionType>
in case of using alias region type:
map region <StartAddressOfArea>-<EndAddressOfArea> <RegionType> <StartAl-
iasedAddress> <AliasedAreaSize>
Example
map region 0x100000-0x1FFFFF C
map region 0x0-0x1ffff A 0x08000000 0x20000
Typical applications
Used with other “map” commands to return to the default values. The map reset command
should be called before any other “map” command is called.
Syntax
map reset
Example
map reset
7.13.1.41 MemPreserveOnReset
This command is used to add a memory preserve area to the internal list of memory areas
that need to be preserved before reset and need to be restored after reset.
The memory area specified must be readable by the CPU before reset and must be writeable
by the CPU immediately after reset.
This is mainly used for SRAM debug configurations etc.
Note
Syntax
MemPreserveOnReset <Addr> <Size>[ <Addr> <Size> …]
Example
MemPreserveOnReset 0x20000000 0x1000
7.13.1.42 ProjectFile
This command is used to specify a file used by the J-Link DLL to save the current config-
uration.
Using this command is recommended if settings need to be saved. This is typically the
case if Flash breakpoints are enabled and used. It is recommended that an IDE uses this
command to allow the JLinkARM.dll to store its settings in the same directory as the project
and settings file of the IDE. The recommended extension for project files is *.jlink.
Assuming the Project is saved under C:\Work\Work and the project contains to targets
name Debug and Release, the debug version could set the file name
C:\Work\Work\Debug.jlink .
The release version could use
C:\Work\Work\Release.jlink .
Note
Syntax
ProjectFile = <FullFileName>
Example
ProjectFile = C:\Work\Release.jlink
7.13.1.43 ReadIntoTraceCache
This command is used to read a given memory area into the trace instruction cache. It
is mainly used for cases where the download address of the application differs from the
execution address. As for trace analysis only cached memory contents are used as mem-
ory accesses during trace (especially streaming trace) cause an overhead that is too big,
by default trace will only work if execution address is identical to the download address.
For other cases, this command can be used to read specific memory areas into the trace
instruction cache.
Note
This command causes an immediate read from the target, so it should only be called
at a point where memory contents at the given area are known to be valid.
Syntax
ReadIntoTraceCache <Addr> <NumBytes>
Example
ReadIntoTraceCache 0x08000000 0x2000
7.13.1.44 RTTTelnetAllowNonLocalClient
This command is used to set allowance for non local telnet clients to access RTT data. Per
default this value is 0 and only local connections are accepted. It can be set to 1 to enable
non local connections as well.
Note
This command is allowed to be used before JLINKARM_Open() was called. This can be
achieved using J-Link SDK. For more information visit our website.
Syntax
RTTTelnetAllowNonLocalClient = 0 | 1
Example
RTTTelnetAllowNonLocalClient = 1 // enables non local clients
7.13.1.45 ScriptFile
This command is used to set the path to a J-Link script file which shall be executed. J-Link
scriptfiles are mainly used to connect to targets which need a special connection sequence
before communication with the core is possible.
Syntax
ScriptFile = <FullFileName>
Example
ScriptFile = C:\Work\Default.JLinkScript
7.13.1.46 SelectTraceSource
This command selects the trace source which shall be used for tracing.
Note
This is only relevant when tracing on a target that supports trace via pins as well
as trace via on-chip trace buffer and a J-Trace (which supports both) is connected
to the PC.
Syntax
SelectTraceSource = <SourceNumber>
Example
SelectTraceSource = 0 // Select ETB
7.13.1.47 SetAllowStopMode
This command is used to allow / disallow stop mode for RTT and memory accesses. Enabled
by default, should only be disabled for testing purposes. For more information about dif-
ferent RTT and memory access modes, please refer to:
Wiki article RTT modes
Wiki article memory access modes
Syntax
SetAllowStopMode = 0 | 1
Example
SetAllowStopMode = 0 // Disable usage of stop mode
7.13.1.48 SetAllowFlashCache
This command is used to enable / disable caching of flash contents. Enabled by default.
Syntax
SetAllowFlashCache = 0 | 1
Example
SetAllowFlashCache = 1 // Enables flash cache
7.13.1.49 SetHostIF
This command can be used to override the host interface. This function should be used
used thoughtful and only if you know exactly what you are doing as there are many things
which needs to be taken into account. For further information regarding this please refer
to InitEmu()
Syntax
SetHostIF USB = <SerialNumber>
SetHostIF IP = <IP address>
Example
7.13.1.50 SetAllowSimulation
This command can be used to enable or disable the instruction set simulation. By default
the instruction set simulation is enabled.
Syntax
SetAllowSimulation = 0 | 1
Example
SetAllowSimulation 1 // Enables instruction set simulation
7.13.1.51 SetBatchMode
This command is used to tell the J-Link DLL that it is used in batch-mode / automatized
mode, so some dialogs etc. will automatically close after a given timeout. Disabled by
default.
Syntax
SetBatchMode = 0 | 1
Example
SetBatchMode 1 // Enables batch mode
7.13.1.52 SetCFIFlash
This command can be used to set a memory area for CFI compliant flashes.
Syntax
SetCFIFlash <StartAddressOfArea>-<EndAddressOfArea>
Example
SetCFIFlash 0x10000000-0x100FFFFF
7.13.1.53 SetCheckModeAfterRead
This command is used to enable or disable the verification of the CPSR (current processor
status register) after each read operation. By default this check is enabled. However this
can cause problems with some CPUs (e.g. if invalid CPSR values are returned). Please note
that if this check is turned off (SetCheckModeAfterRead = 0), the success of read operations
cannot be verified anymore and possible data aborts are not recognized.
Typical applications
This verification of the CPSR can cause problems with some CPUs (e.g. if invalid CPSR
values are returned). Note that if this check is turned off (SetCheckModeAfterRead = 0),
the success of read operations cannot be verified anymore and possible data aborts are
not recognized.
Syntax
SetCheckModeAfterRead = 0 | 1
Example
SetCheckModeAfterRead = 0
7.13.1.54 SetCompareMode
This command is used to configure the compare mode.
Syntax
SetCompareMode = <Mode>
<Mode> Description
0 Skip
1 Using fastest method (default)
2 Using CRC
3 Using readback
Example
SetCompareMode = 1 // Select using fastest method
7.13.1.55 SetCPUConnectIDCODE
Used to specify an IDCODE that is used by J-Link to authenticate itself when connecting
to a specific device. Some devices allow the user to lock out a debugger by default, until
a specific unlock code is provided that allows further debugging. This function allows to
automate this process, if J-Link is used in a production environment.
The IDCODE stream is expected as a hex-encoded byte stream. If the CPU e.g. works on a
word-basis for the IDCODE, this stream is interpreted as a little endian formatted stream
where the J-Link library then loads the words from and passes them to the device during
connect.
Syntax
SetCPUConnectIDCODE = <IDCODE_Stream>
Example
CPU has a 64-bit IDCODE (on word-basis) and expects 0x11223344 0x55667788 as IDCODE.
SetCPUConnectIDCODE = 4433221188776655
7.13.1.56 SetDbgPowerDownOnClose
When using this command, the debug unit of the target CPU is powered-down when the
debug session is closed.
Note
Typical applications
This feature is useful to reduce the power consumption of the CPU when no debug session
is active.
Syntax
SetDbgPowerDownOnClose = <value>
Example
7.13.1.57 SetEnableMemCache
Enables/Disables DLL internal memory cache mechanisms that are used to improve per-
formance. By default, memory cache mechanisms are enabled.
Syntax
SetEnableMemCache = 0 | 1
Example
Notes
This command may not be used by any IDE, listed as a supported IDE, to disable memory
cache mechanisms by default. It may only be used by specific customers for very specific
test cases that needs the cache mechanisms to be disabled.
7.13.1.58 SetETBIsPresent
This command is used to select if the connected device has an ETB.
Syntax
SetETBIsPresent = 0 | 1
Example
7.13.1.59 SetETMIsPresent
This command is used to select if the connected device has an ETM.
Syntax
SetETMIsPresent = 0 | 1
Example
7.13.1.60 SetFlashDLNoRMWThreshold
This command sets the J-Link DLL internal threshold when a write to flash memory does not
cause a read-modify-write (RMW) operation. For example, when setting this value to 0x800,
all writes of amounts of data < 2 KB will cause the DLL to perform a read-modify-write
operation on incomplete sectors.
Default: Writing amounts of < 1 KB (0x400) to flash causes J-Link to perform a read-
modify-write on the flash.
Syntax
SetFlashDLNoRMWThreshold = <value>
Example
SetFlashDLNoRMWThreshold = 0x100 // 256 Bytes
7.13.1.61 SetFlashDLThreshold
This command is used to set a minimum amount of data to be downloaded by the flash
download feature.
Syntax
SetFlashDLThreshold = <value>
Example
SetFlashDLThreshold = 0x100 // 256 Bytes
7.13.1.62 SetIgnoreReadMemErrors
This command can be used to ignore read memory errors. Disabled by default.
Syntax
SetIgnoreReadMemErrors = 0 | 1
Example
7.13.1.63 SetIgnoreWriteMemErrors
This command can be used to ignore read memory errors. Disabled by default.
Syntax
SetIgnoreWriteMemErrors = 0 | 1
Example
7.13.1.64 SetMonModeDebug
This command is used to enable / disable monitor mode debugging. Disabled by default.
Syntax
SetMonModeDebug = 0 | 1
Example
7.13.1.65 TraceSampleAdjust
Allows to adjust the sample point for the specified trace data signals inside the J-Trace
firmware. This can be useful to compensate certain delays on the target hardware (e.g.
caused by routing etc.).
Syntax
TraceSampleAdjust <PinName> = <Adjust_Ps>[ <PinName#<Adjust_Ps> …]
<PinName> Description
TD Adjust all trace data signals
TD0 Adjust trace data 0
TD1 Adjust trace data 1
TD2 Adjust trace data 2
TD3 Adjust trace data 3
TD3..0 Adjust trace data 0-3
TD2..1 Adjust trace data 1-2
TDx..y Adjust trace data x-y
<Adjust_Ps> Description
-5000 to 5000 Adjustment in [ps]
Example
TraceSampleAdjust TD = 1000
7.13.1.66 SetResetPulseLen
This command defines the length of the RESET pulse in milliseconds. The default for the
RESET pulse length is 20 milliseconds.
Syntax
SetResetPulseLen = <value>
Example
SetResetPulseLen = 50
7.13.1.67 SetResetType
This command selects the reset strategy which shall be used by J-Link, to reset the device.
The value which is used for this command is analog to the reset type which shall be selected.
For a list of all reset types which are available, please refer to Reset strategies . Please note
that there different reset strategies for ARM 7/9 and Cortex-M devices.
Syntax
SetResetType = <value>
Example
SetResetType = 0 // Selects reset strategy type 0: normal
7.13.1.68 SetRestartOnClose
This command specifies whether the J-Link restarts target execution on close. The default
is to restart target execution. This can be disabled by using this command.
Syntax
SetRestartOnClose = 0 | 1
Example
SetRestartOnClose = 1
7.13.1.69 SetRTTAddr
In some cases J-Link cannot locate the RTT buffer in known RAM. This command is used
to set the exact address manually.
Syntax
SetRTTAddr <RangeStart>
Example
SetRTTAddr 0x20000000
7.13.1.70 SetRTTTelnetPort
This command alters the RTT telnet port. Default is 19021. This command must be called
before a connection to a J-Link is established. In J-Link Commander, J-Link Command
Strings (“exec <JLinkCommandString>”) can only be executed after a connection to J-Link
is established, therefore this command string has no effect in J-Link Commander. The -
RTTTelnetPort command line parameter can be used instead .
Syntax
SetRTTTelnetPort <value>
Example
SetRTTTelnetPort 9100
7.13.1.71 SetRTTSearchRanges
In some cases J-Link cannot locate the RTT buffer in known RAM. This command is used to
set (multiple) ranges to be searched for the RTT buffer.
Syntax
SetRTTSearchRanges <RangeAddr> <RangeSize> [, <RangeAddr1> <RangeSize1>, ..]
Example
SetRTTSearchRanges 0x10000000 0x1000, 0x20000000 0x1000,
7.13.1.72 SetRXIDCode
This command is used to set the ID Code for Renesas RX devices to be used by the J-
Link DLL.
Syntax
SetRXIDCode = <RXIDCode_String>
Example
Set 16 IDCode Bytes (32 Characters).
SetRXIDCode = 112233445566778899AABBCCDDEEFF00
7.13.1.73 SetSkipProgOnCRCMatch
Note
Syntax
SetSkipProgOnCRCMatch = <CompareMode>
Example
SetSkipProgOnCRCMatch = 1 // Select using fastest method
7.13.1.74 SetSysPowerDownOnIdle
When using this command, the target CPU is powered-down when no transmission between
J-Link and the target CPU was performed for a specific time. When the next command is
given, the CPU is powered-up.
Note
Typical applications
This feature is useful to reduce the power consumption of the CPU.
Syntax
SetSysPowerDownOnIdle = <value>
Note
Example
7.13.1.75 SetVerifyDownload
This command is used to configure the verify mode.
Syntax
SetVerifyDownload = <VerifyMode>
Example
SetVerifyDownload = 1 // Select programmed sectors, fastest method
7.13.1.76 SetWorkRAM
This command can be used to configure the RAM area which will be used by J-Link.
Syntax
SetWorkRAM <StartAddressOfArea>-<EndAddressOfArea>
Example
SetWorkRAM 0x10000000-0x100FFFFF
7.13.1.77 ShowControlPanel
Executing this command opens the control panel.
Syntax
ShowControlPanel
7.13.1.78 SilentUpdateFW
After using this command, new firmware will be updated automatically without opening a
message box.
Syntax
SilentUpdateFW
7.13.1.79 SupplyPower
This command activates power supply over pin 19 of the JTAG connector. The KS (Kickstart)
versions of J-Link have the V5 supply over pin 19 activated by default.
Typical applications
This feature is useful for some eval boards that can be powered over the JTAG connector.
Syntax
SupplyPower = 0 | 1
Example
SupplyPower = 1
7.13.1.80 SupplyPowerDefault
This command activates power supply over pin 19 of the JTAG connector permanently. The
KS (Kickstart) versions of J-Link have the V5 supply over pin 19 activated by default.
Typical applications
This feature is useful for some eval boards that can be powered over the JTAG connector.
Syntax
SupplyPowerDefault = 0 | 1
Example
SupplyPowerDefault = 1
7.13.1.81 SuppressControlPanel
Using this command ensures, that the control panel will not pop up automatically.
Syntax
SuppressControlPanel
7.13.1.82 SuppressInfoUpdateFW
After using this command information about available firmware updates will be suppressed.
Note
We strongly recommend not to use this command, latest firmware versions should
always be used!
Syntax
SuppressInfoUpdateFW
7.13.1.83 SWOSetConversionMode
This command is used to set the SWO conversion mode.
Syntax
SWOSetConversionMode = <ConversionMode>
Example
SWOSetConversionMode = 0
Note
The implementation of the cache handling is different for different cores. However,
the cache is handled correctly for all supported ARM9 cores.
Note
VCOM can only be used when debugging via SWD target interface. Pin 5 = J-Link-Tx
(out), Pin 17 = J-Link-Rx (in).
Note
Currently, only J-Link models with hardware version 9 or newer comes with VCOM
capabilities.
Flash download
This chapter describes how the flash download feature of the DLL can be used in different
debugger environments.
8.1 Introduction
The J-Link DLL comes with a lot of flash loaders that allow direct programming of internal
flash memory for popular microcontrollers. Moreover, the J-Link DLL also allows program-
ming of CFI-compliant external NOR flash memory. The flash download feature of the J-
Link DLL does not require an extra license and can be used free of charge.
8.2 Licensing
No extra license required. The flash download feature can be used free of charge.
Note
While using flashloaders of a 3rd party applications works in most cases, SEGGER can
neither offer support for those nor guarantee that other features won’t be impaired
as a side effect of not using the J-Link flashloader
Flash breakpoints
This chapter describes how the flash breakpoints feature of the DLL can be used in different
debugger environments.
9.1 Introduction
The J-Link DLL supports a feature called flash breakpoints which allows the user to set
an unlimited number of breakpoints in flash memory rather than only being able to use
the hardware breakpoints of the device. Usually when using hardware breakpoints only, a
maximum of 2 (ARM 7/9/11) to 8 (Cortex-A/R) breakpoints can be set. The flash memory
can be the internal flash memory of a supported microcontroller or external CFI-compliant
flash memory. In the following sections the setup for different debuggers for use of the
flash breakpoints feature is explained.
9.2 Licensing
In order to use the flash breakpoints feature a separate license is necessary for each J-
Link. For some devices J-Link comes with a device-based license and some J-Link models
also come with a full license for flash breakpoints but the normal J-Link comes without any
licenses. For more information about licensing itself and which devices have a device-based
license, please refer to J-Link Model overview .
9.5.1 Setup
The setup for the debugger is the same as for downloading into QSPI flash. For more
information please refer to QSPI flash support .
9.6 FAQ
Why can flash breakpoints not be used with Rowley Crossworks? Because Rowley Cross-
works does not use the proper J-Link API to set breakpoints. Instead of using the break-
point-API, Crossworks programs the debug hardware directly, leaving J-Link no choice to
use its flash breakpoints.
This chapter describes how to use monitor mode debugging support with J-Link.
10.1 Introduction
In general, there are two standard debug modes available for CPUs:
1. Halt mode
2. Monitor mode
Halt mode is the default debug mode used by J-Link. In this mode the CPU is halted and
stops program execution when a breakpoint is hit or the debugger issues a halt request.
This means that no parts of the application continue running while the CPU is halted (in
debug mode) and peripheral interrupts can only become pending but not taken as this
would require execution of the debug interrupt handlers. In circumstances halt mode may
cause problems during debugging specific systems:
1. Certain parts of the application need to keep running in order to make sure that
communication with external components does not break down. This is the case for
Bluetooth applications where the Bluetooth link needs to be kept up while the CPU is in
debug mode, otherwise the communication would fail and a resume or single stepping
of the user application would not be possible
2. Some peripherals are also stopped when the CPU enters debug mode. For example;
Pulse-width modulation (PWM) units for motor control applications may be halted while
in an undefined / or even dangerous state, resulting in unwanted side-effects on the
external hardware connected to these units.
This is where monitor mode debugging becomes effective. In monitor debug mode the CPU
is not halted but takes a specific debug exception and jumps into a defined exception handler
that executes (usually in a loop) a debug monitor software that performs communication
with J-Link (in order to read/write CPU registers and so on). The main effect is the same
as for halting mode: the user application is interrupted at a specific point but in contrast
to halting mode, the fact that the CPU executes a handler also allows it to perform some
specific operations on debug entry / exit or even periodically during debug mode with almost
no delay. This enables the handling of such complex debug cases as those explained above.
10.3.1 Cortex-M3
See Cortex-M4 on page 268.
10.3.2 Cortex-M4
For Cortex-M4, monitor mode debugging is supported. The monitor code provided by SEG-
GER can easily be linked into the user application.
This chapter describes how to debug low power modes on a supported target CPU.
11.1 Introduction
As power consumption is an important factor for embedded systems, CPUs provide different
kinds of low power modes to reduce power consumption of the target system. The useful
this is for the application, the problematic it is during debug. In general, how far debugging
target applications that make use of low power modes is possible, heavily depends on the
device being used as several behavior is implementation defined and differs from device to
device. The following cases are the most common ones:
1. The device provides specific special function registers for debugging to keep some clocks
running necessary for debugging, while the device is in a low power mode.
2. The device wakes up automatically, as soon as there is a request by the debug probe
on the debug interface
3. The device powers off the debug interface partially, allowing the debug probe to read-
access certain parts but does not allow to control the CPU.
4. The device powers off the debug interface completely and the debug probe loses the
connection to the device (temporarily)
While cases 1-3 are the most convenient ones from the debug perspective because the
low power mode is transparent to the end user, they do not provide a real-world scenario
because certain things cannot be really tested if certain clocks are still active which would
not be in the release configuration with no debug probe attached. In addition to that,
the power consumption is significantly higher than in the release config which may cause
problems on some hardware designs which are specifically designed for very low power
consumption.
The last case (debug probes temporarily loses connection) usually causes the end of a
debug session because the debugger would get errors on accesses like “check if CPU is
halted/hit a BP”. To avoid this, there is a special setting for J-Link that can be activated, to
handle such cases in a better way, which is explained in the following.
11.3 Restrictions
As the connection to the target is temporary lost while it is in low power mode, some
restrictions during debug apply:
• Make sure that the IDE does not perform periodic accesses to memory while the target
is in a low power mode. E.g.: Disable periodic refresh of memory windows, close live
watch windows etc.
• Avoid issuing manual halt requests to the target while it is in a low power mode.
• Do not try to set breakpoints while the target already is in a low power mode. If a
breakpoint in a wake-up routine shall be hit as soon as the target wakes up from low
power mode, set this breakpoint before the target enters low power mode.
• Single stepping instructions that enter a low power mode (e.g. WFI/WFE on Cortex-M)
is not possible/supported.
• Debugging low power modes that require a reset to wake-up can only be debugged on
targets where the debug interface is not reset by such a reset. Otherwise breakpoints
and other settings are lost which may result in unpredictable behavior.
J-Link does it’s best to handle cases where one or more of the above restrictions is not
considered but depending on how the IDE reacts to specific operations to fail, error mes-
sages may appear or the debug session will be terminated by the IDE.
Open Flashloader
This chapter describes how to add support for new devices to the J-Link DLL and software
that uses the J-Link DLL using the Open Flashloader concept.
12.1 Introduction
As the number of devices being available is steadily growing and sometimes in an early
stage of the MCU development only a few samples/boards are available that may not be
provided to third parties (e.g. SEGGER) to add support for a new device. Also the existence
of the device may have confidential status, so it might not be mentioned as being supported
in public releases yet. Therefore it might be desirable to be able to add support for new
devices on your own, without depending on SEGGER and a new release of the J-Link soft-
ware package being available.
The J-Link DLL allows customers to add support for new devices on their own. It is also
possible to edit/extend existing devices of the device database by for example adding new
flash banks (e.g. to add support for internal EEPROM programming or SPIFI programming
etc.). This chapter explains how new devices can be added to the DLL and how existing
ones can be edited/extended.
<Database>
<Device>
<ChipInfo Vendor="..."
Name="..."
WorkRAMAddr="..."
WorkRAMSize="..."
Core="..." />
<FlashBankInfo Name="..."
BaseAddr="..."
MaxSize="..."
Loader="..."
LoaderType="..."
AlwaysPresent="..." />
</Device>
</Database>
When adding a new device, the following attributes for the <ChipInfo> tag are mandatory:
• Vendor
• Name
• Core
In case a <FlashBankInfo> tag is also added, the following attributes in addition to the
ones mentioned before, become mandatory:
ChipInfo-Tag
• WorkRAMAddr
• WorkRAMSize
• FlashBankInfo
FlashBankInfo-Tag
• Name
• BaseAddr
• MaxSize
• Loader
• LoaderType
• AlwaysPresent
For more information about the tags and their attributes, please refer to XML Tags and
Attributes .
In order to add more than one device to the device database, just repeat the <Device> …
</Device> tag structure from above for each device.
<Database>
<Device>
<ChipInfo Vendor="..."
Name="..." />
<FlashBankInfo Name="..."
BaseAddr="..."
MaxSize="..."
Loader="..."
LoaderType="..."
AlwaysPresent="..." />
</Device>
</Database>
The attribute Name of the tag <ChipInfo> must specify exactly the same name as the
device in the built-in device database specifies. In case the value of the attribute BaseAddr
specifies an address of an existing flash bank for the existing device, in the built-in device
database, the flash bank from the built-in database is replaced by the one from the XML file.
When adding new flash banks or if the device in the built-in database does not specify any
flash banks so far, the same attribute requirements as for adding a new device, apply. For
more information, please refer to Adding a new device .
In order to add more than one flash bank, just repeat the <FlashBankInfo … />> tag
structure from above, inside the same <Device> tag.
For more information about the tags and their attributes, please refer to XML Tags and
Attributes .
General rules
• Attributes may only occur inside an opening tag
• Attribute values must be enclosed by quotation marks
Tag Description
<Database> Opens the XML file top-level tag.
<Device> Opens the description for a new device.
Specifies basic information about the device to be added, like the
<ChipInfo>
core it incorporates etc.
<FlashBankInfo> Specifies a flash bank for the device.
12.5.1 <Database>
Opens the XML file top-level tag. Only present once per XML file.
Valid attributes
This tag has no attributes
Notes
• Must only occur once per XML file
• Must be closed via </Database>
12.5.2 <Device>
Opens the description for a new device.
Valid attributes
This tag has no attributes
Notes
• Must be closed via </Device> .
• May occur multiple times in an XML file
12.5.3 <ChipInfo>
Specifies basic information about the device to be added, like the core it incorporates etc.
Valid attributes
Parameter Meaning
String that specifies the name of the vendor of the device.
Vendor This attribute is mandatory.
E.g. Vendor=“ST”.
Name of the device. This attribute is mandatory.
Name
E.g. Name=“STM32F407IE”
Hexadecimal value that specifies the address of a RAM area
that can be used by J-Link during flash programming etc.
Should not be used by any DMAs on the device. Cannot exist
WorkRAMAddr
without also specifying WorkRAMSize. If no flash banks are
added for the new device, this attribute is optional.
E.g. WorkRAMAddr=“0x20000000”
Parameter Meaning
Hexadecimal value that specifies the size of the RAM area
that can be used by J-Link during flash programming etc.
Cannot exist without also specifying WorkRAMAddr. If no
WorkRAMSize
flash banks are added for the new device, this attribute is
optional.
E.g. WorkRAMSize=“0x10000”
Specifies the core that the device incorporates. If a new de-
vice added, this attribute is mandatory.
Core E.g. Core=“JLINK_CORE_CORTEX_M0”
For a list of valid attribute values, please refer to Attribute
values - Core .
String that specifies the path to a J-Link script file if required
for the device. Path can be relative or absolute. If path is
JLinkScriptFile relative, is relative to the location of the JLinkDevices.xml
file. This attribute is mandatory.
E.g. JLinkScriptFile=“ST/Example.jlinkscript”
String that is a list of aliases for the specified device.
Every alias creates an entry in the target device list with the
Aliases alias as device name.
The different aliases are separated by semicolons (“;”).
E.g. Aliases=“Device_1;Device_2;Device_3;Device_4”
Notes
• No separate closing tag.
Directly closed after attributes have been specified: <ChipInfo … />
• Must not occur outside a <Device> tag.
• JLINK_CORE_ARM968E_S
• JLINK_CORE_ARM11
• JLINK_CORE_ARM1136
• JLINK_CORE_ARM1136J
• JLINK_CORE_ARM1136J_S
• JLINK_CORE_ARM1136JF
• JLINK_CORE_ARM1136JF_S
• JLINK_CORE_ARM1156
• JLINK_CORE_ARM1176
• JLINK_CORE_ARM1176J
• JLINK_CORE_ARM1176J_S
• JLINK_CORE_ARM1176JF
• JLINK_CORE_ARM1176JF_S
• JLINK_CORE_CORTEX_R4
• JLINK_CORE_CORTEX_R5
• JLINK_CORE_RX
• JLINK_CORE_RX62N
• JLINK_CORE_RX62T
• JLINK_CORE_RX63N
• JLINK_CORE_RX630
• JLINK_CORE_RX63T
• JLINK_CORE_RX621
• JLINK_CORE_RX62G
• JLINK_CORE_RX631
• JLINK_CORE_RX65N
• JLINK_CORE_RX21A
• JLINK_CORE_RX220
• JLINK_CORE_RX230
• JLINK_CORE_RX231
• JLINK_CORE_RX23T
• JLINK_CORE_RX24T
• JLINK_CORE_RX110
• JLINK_CORE_RX113
• JLINK_CORE_RX130
• JLINK_CORE_RX71M
• JLINK_CORE_CORTEX_M4
• JLINK_CORE_CORTEX_M7
• JLINK_CORE_CORTEX_M_V8MAINL
• JLINK_CORE_CORTEX_A5
• JLINK_CORE_POWER_PC
• JLINK_CORE_POWER_PC_N1
• JLINK_CORE_POWER_PC_N2
• JLINK_CORE_MIPS
• JLINK_CORE_MIPS_M4K
• JLINK_CORE_MIPS_MICROAPTIV
• JLINK_CORE_EFM8_UNSPEC
• JLINK_CORE_CIP51
12.5.4 <FlashBankInfo>
Specifies a flash bank for the device. This allows to use the J-Link flash download func-
tionality with IDEs, debuggers and other software that uses the J-Link DLL (e.g. J-Link
Commander) for this device. The flash bank can then be programmed via the normal flash
download functionality of the J-Link DLL. For more information about flash download, please
refer to Flash download . For possible limitations etc. regarding newly added flash banks,
please refer to Add. Info / Considerations / Limitations .
Valid attributes
Parameter Meaning
String that specifies the name of the flash bank. Only used
for visualization. Can be freely chosen.
Name
This attribute is mandatory.
E.g. Name=“SPIFI flash”
Hexadecimal value that specifies the start address of the
flash bank. The J-Link DLL uses this attribute together with
MaxSize to determine which memory write accesses per-
formed by the debugger, shall be redirected to the flash
BaseAddr
loader instead of being written directly to the target as nor-
mal memory access.
This attribute is mandatory.
E.g. BaseAddr=“0x08000000”
Hexadecimal value that specifies the max. size of the flash
bank in bytes. For many flash loader types the real bank size
may depend on the actual flash being connected (e.g. SPIFI
flash where the loader can handle different SPIFI flashes so
size may differ from hardware to hardware). Also, for some
flash loaders the sectorization is extracted from the flash
loader at runtime. The real size of the flash bank may be
MaxSize
smaller than MaxSize but must never be bigger. The J-Link
DLL uses this attribute together with BaseAddr to determine
which memory write accesses performed by the debugger,
shall be redirected to the flash loader instead of being writ-
ten directly to the target as normal memory access.
This attribute is mandatory.
E.g. MaxSize=“0x80000”
String that specifies path to the ELF file that holds the flash
loader. Path can be relative or absolute. If path is relative, it
is relative to the location of the JLinkDevices.xml file.
Loader This attribute is mandatory.
E.g. Loader=“ST/MyFlashLoader.elf”
For CMSIS flash loaders the file extension is usually FLM,
however any extension is accepted by the J-Link DLL.
Specifies the type of the loader specified by Loader.
This attribute is mandatory. E.g. LoaderType=“FLASH_AL-
LoaderType
GO_TYPE_OPEN” For a list of valid attribute values, please
refer to Attribute values LoaderType .
Specifies if a flash bank is always present (e.g. internal
flash). If this element is set to one, this flash bank will be af-
AlwaysPresent
fected by the “erase” command.
This attribute is optional. E.g. AlwaysPresent=“1”.
Notes
• No separate closing tag. Directly closed after attributes have been specified:
<FlashBankInfo … />
• Must not occur outside a <Device> tag
SEGGER does not give any guarantee for correct functionality nor provide any support
for customized devices / flash banks. Using J-Link support for customized devices that
have been added via a XML device description file is done at user’s own risk.
In the following, some considerations / limitations when adding support for a new device
or editing/extending an existing device, are given:
J-Flash SPI
This chapter describes J-Flash SPI and J-Flash SPI CL, which are separate software (exe-
cutables) which allow direct programming of SPI flashes, without any additional hardware.
Both, J-Flash SPI and J-Flash SPI CL are part of the J-Link Software and Documentation
Package which is available free of charge. This chapter assumes that you already possess
working knowledge of the J-Link device.
13.1 Introduction
The following chapter introduces J-Flash SPI, highlights some of its features, and lists its
requirements on host and target systems.
13.1.1.1 Supported OS
The following Microsoft Windows versions are supported by J-Flash SPI:
• 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
13.1.2.1 Supported OS
The following operating systems are supported by J-Flash CL:
• 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
13.1.3 Features
• Directly communicates with the SPI flash via SPI protocol, no MCU in between needed.
• Programming of all kinds of SPI flashes is supported.
• Can also program SPI flashes that are connected to CPUs that are not supported by
J-Link.
• Supports any kind of custom command sequences (e.g. write protection register)
• Verbose logging of all communication.
• .hex, .mot, .srec, and .bin support.
• Intuitive user interface.
13.1.4 Requirements
13.1.4.1 Host
J-Flash SPI requires a PC running one of the supported operating system (see above) with
a free USB port dedicated to a J-Link. A network connection is required only if you want to
use J-Flash SPI together with J-Link Remote Server.
13.1.4.2 Target
The flash device must be an SPI flash that supports standard SPI protocols.
13.2 Licensing
The following chapter provides an overview of J-Flash SPI related licensing options.
13.2.1 Introduction
A J-Link PLUS, ULTRA+, PRO or Flasher ARM/PRO is required to use J-Flash SPI. No addi-
tional license is required / available.
13.3.1 Setup
For J-Link setup procedure required in order to work with J-Flash SPI, please refer to chapter
Setup on page 139.
Directory Contents
Command Description
Opens a project file. Note that only one project file may be open
Open Project… at a time. Opening a project will close any other project currently
open.
Save Project Saves a project file.
Save Project as… Saves a project file using the name and location given.
Close Project Closes a project file.
Recent Files > Contains a list of the most recently open data files.
Recent Projects > Contains a list of the most recently open project files.
Generates data which can be used to test if the flash can be pro-
Test > Generate test
grammed correctly. The size of the generated data file can be de-
data
fined.
Program Programs the chip using the currently active data file.
Programs the chip using the currently active data file and then
Program & Verify
verifies that it was written successfully.
Performs a sequence of steps, which can be configured in the
Production tab of the Project settings. Additionally, the first step
executed are the init steps and the last step executed are the
Auto
exit steps, which both can be configured in the MCU tab of the
project settings. The range of sectors to be erased can be config-
ured through the Global settings dialog.
Command Description
Verify Verifies the data found on the chip with the data file.
Read back > Entire Reads back the data found on the chip and creates a new data
chip file to store this information.
Reads back the data found in a range specified by the user and
Read back > Range
creates a new data file to store this information.
<List of currently A entry of the list can be selected to move the focus to the re-
open windows> spective window.
13.4 Settings
The following chapter provides an overview of the program settings. Both general and per
project settings are considered.
USB
If this option is checked, J-Flash SPI will connect to J-Link over the USB port. You may
change the device number if you want to connect more than one J-Link to your PC. The
default device number is 0. For more information about how to use multiple J-Links on one
PC, please see also the chapter “Working with J-Link” of the J-Link Manual (UM08001).
TCP/IP
If this option is selected, J-Flash SPI will connect to J-Link via J-Link Remote Server. You
have to specify the hostname of the remote system running the J-Link Remote Server.
13.4.1.2 Setup
This dialog is used to configure the SPI interface settings like SPI communication speed
and allows to add Init steps and Exit steps which can be used to execute custom command
sequences.
Interface Speed
Specifies the SPI communication speed J-Link uses to communicate with the SPI flash.
Command Description
Performs a compare of the current flash content and the da-
ta to be programmed. Sectors which do already match will be
skipped by Erase / Program operation. Note: If Erase is enabled
Compare
and Erase type is “Chip”, the compare will be skipped as after
mass erase, the entire device is empty and needs to be re-pro-
grammed.
Performs an erase depending on the settings, selected in the
drop down box:
• Sectors: Erases all sectors which are effected by the image to
Erase be programmed.
• Sectors if not blank: Erases all sectors which are both, effected
by the image to be programmed and not already blank.
• Chip: Erase the entire chip independent of the content.
Program Programs the data file.
Command Description
Verify Verifies the programmed data by reading them back.
13.4.2.1 Operation
You may define the behavior of some operations such as “Auto” or “Program & Verify”.
13.4.2.2 Logging
You may set some logging options to customize the log output of J-Flash SPI.
13.5.1 Overview
In addition to its traditional Windows graphical user interface (GUI), J-Flash SPI supports a
command line mode as well. This makes it possible to use J-Flash SPI for batch processing
purposes. All important options accessible from the menus are available in command line
mode as well. If you provide command line options, J-Flash SPI will still start its GUI, but
processing will start immediately.
The screenshot below shows the command line help dialog, which is displayed if you start
J-Flash SPI in a console window with JFlashSPI.exe -help or JFlashSPI.exe -? .
The command line options are evaluated in the order they are passed to J-Flash, so please
ensure that a project and data file has already been opened when evaluating a command
line option which requires this.
It is recommended to always use -open<FILENAME>[,<SADDR>] to make sure the right data
file is opened.
All command line options return 0 if the processing was successful. A return value unequal
0 means that an error occurred.
Note: Entries marked with “*” Do not work for J-Flash SPI_CL
Option Description
-? Displays the help dialog.
Executes the steps selected in Production Pro-
-auto gramming. Default: Erases, programs and veri-
fies target.
-connect Connects to the target.
-delrange<SADDR>,<EADDR> * Deletes data in the given range.
-disconnect Disconnects from the target.
-eliminate * Eliminates blank areas in data file.
-erasechip Erases the entire flash chip.
-erasesectors Erases selected sectors.
-exit * Exits J-Flash SPI.
-help Displays the help dialog.
-jflashlog<FILENAME> Sets a temporary J-Flash SPI logfile.
-jlinklog<FILENAME> Sets a temporary J-Link logfile.
* Saves the current data file into the specified
• -merge<FILENAME> file. Please note that the parameters <SAD-
• -merge<FILENAME>.bin,<ADDR> DR>, <EADDR> apply only if the data file is a
*.bin file or *.c file.
-min * Starts application minimized
Opens a data file. Please note that the <SAD-
-open<FILENAME>[,<SADDR>] DR> parameter applies only if the data file is a
*.bin file
Opens an existing project file. This will also au-
-openprj<FILENAME> tomatically open the data file that has been re-
cently used with this project.
-program Programs the target.
-programverify Programs and verify the target.
-readchip Reads the entire flash chip.
-readrange<SADDR>,<EADDR> Reads specified range of target memory.
-relocate<Offset> * Relocate data by <Offsest>.
Saves the current data file. Please note that
-save[<SADDR>,<EADDR>] the parameters <SADDR>,<EADDR> apply on-
ly if the data file is a *.bin file or *.c file.
Saves the current data file into the specified
-saveas<FILENAME>[,<SAD- file. Please note that the parameters <SAD-
DR>,<EADDR>] DR>,<EADDR> apply only if the data file is a
*.bin file or *.c file.
-saveprj * Saves the current project.
-saveprjas<FILENAME> * Saves the current project in the specified file.
-verify Verifies the target memory.
Option Description
-usb<SN> Overrides connection settings to USB S/N.
• -ip<xxx.xxx.xxx.xxx>
Overrides connection settings to IP.
• -ip<HostName>
Sets the connection speed
-speed<SpeedInkHZ>
NOTE: Only J-Flash SPI_CL
Sets the log verbosity level to <Level>.
-verbose<Level> <Level>-range is from 0-9
NOTE: Only J-Flash SPI_CL
@ECHO OFF
ECHO Open a project and data file, start auto processing and exit
JFlashSPI.exe -openprjC:\Projects\Default.jflash -openC:\Data
\data.bin,0x100000 -auto -exit
IF ERRORLEVEL 1 goto ERROR
goto END
:ERROR
ECHO J-Flash SPI: Error!
pause
:END
Note
Every call of JFlashSPI.exe has to be completed with the -exit option, otherwise the
execution of the batch file stops and the following commands will not be processed.
The easiest way is to setup the appropriate project once and then make multiple copies of
this project. Now modify the Connection to J-Link setting in each project, in order to let
J-Flash SPI connect to the different programmers as shown in the screenshot below: Find
below a small sample which shows how to program multiple targets in parallel:
@ECHO OFF
ECHO Open first project which is configured to connect to the first J-Link.
ECHO Open data file, start auto processing and exit
open JFlashSPI.exe -openprjC:\Projects\Project01.jflash -openC:\Data\data.bin,
0x100000 -auto -exit
IF ERRORLEVEL 1 goto ERROR
ECHO Open second project which is configured to connect to the second J-Link.
ECHO Open data file, start auto processing and exit
open JFlashSPI.exe -openprjC:\Projects\Project02.jflash -openC:\Data\data.bin,
0x100000 -auto -exit
IF ERRORLEVEL 1 goto ERROR
ECHO Open third project which is configured to connect to the third J-Link.
ECHO Open data file, start auto processing and exit
open JFlashSPI.exe -openprjC:\Projects\Project03.jflash -openC:\Data\data.bin,
0x100000 -auto -exit
IF ERRORLEVEL 1 goto ERROR
goto END
:ERROR
ECHO J-Flash SPI: Error!
pause
:END
Note
Every call of JFlashSPI.exe has to be completed with the -exit option, otherwise the
execution of the batch file stops and the following commands will not be processed.
3. Define the SPI communication speed. The default settings work without any problem
for most targets, but to achieve the last quantum of performance, manual tuning may
be necessary.
4. Open the Flash and either select Automatically detect SPI flash or manually enter
the flash parameters.
5. Save the project (File -> Save Project) and test it.
13.7.2 Example
The example below demonstrates how to use the custom command sequence feature to
implement a read-modify-write security register on the Winbond W25Q128FVSIG SPI flash
using the init steps. To make sure that the output of the example is exactly the same, the
sample erases the security register to have defined values.
Step #0 to Step#2: Set Write Enable
Step #3 to Step#6: Erase security register to have a defined values (0xFF)
Step #7 to Step#11: Read 16 byte security register into Var buffer
Step #12 to Step#19: Modify the data in the Var buffer
Step #20 to Step#22: Set Write Enable
Step #23 to Step#27: Program security register with values from Var buffer
Step #28 to Step#32: Read back security register to verify successful programming
Step Description
ExitStepX_Action = “$Action$” Any action as described in the table below.
User can specify any comment here. This field
ExitStepX_Comment = “$Comment$”
is optional and not taken into account.
ExitStepX_Value0 = “$Value0$” Value depends on the action. See table below
ExitStepX_Value1 = “$Value1$” Value depends on the action. See table below
The number of exit steps needs to be specified right behind the ExitStep sequence with the
line “NumExitSteps = <NumExitSteps>” (see example below).
Below is a small example excerpt from a J-Flash project, which shows a example sequence
to erase sector 0 of the SPI flash using the 0xD8 command. Further examples can be found
in the installation directory of the J-Link software and documentation package.
[CPU]
//
// Set write enable
//
ExitStep0_Action = "Activate CS"
ExitStep0_Value0 = 0x00000000
ExitStep0_Value1 = 0x00000000
ExitStep1_Action = "Write data"
ExitStep1_Comment = "Set write enable"
ExitStep1_Value0 = 1
ExitStep1_Value1[1] = 0x06
ExitStep2_Action = "Deactivate CS"
ExitStep2_Comment = "Deactivate CS"
ExitStep2_Value0 = 0x00000000
ExitStep2_Value1 = 0x00000000
//
// Erase sector 0
//
ExitStep3_Action = "Activate CS"
ExitStep3_Comment = "Activate CS"
ExitStep3_Value0 = 0x00000000
ExitStep3_Value1 = 0x00000000
ExitStep4_Action = "Write data"
ExitStep4_Comment = "Set write enable"
ExitStep4_Value0 = 4
ExitStep4_Value1[4] = 0xD8,0x00,0x00,0x00
ExitStep5_Action = "Deactivate CS"
ExitStep5_Comment = "Deactivate CS"
ExitStep5_Value0 = 0x00000000
ExitStep5_Value1 = 0x00000000
//
// Wait until sector has been erased
//
ExitStep6_Action = "Delay"
ExitStep6_Comment = "Wait until sector has been erased"
ExitStep6_Value0 = 0x00000080
ExitStep6_Value1 = 0x00000000
NumExitSteps = 7
13.10 Performance
The following chapter lists programming performance for various SPI flash devices.
13.12 Support
The following chapter provides advises on troubleshooting for possible typical problems and
information about how to contact our support.
13.12.1 Troubleshooting
13.12.1.1 Typical problems
Target system has no power
Meaning:
J-Link could not measure the target (flash) reference voltage on pin 1 of its connector.
Remedy:
The target interface of J-Link works with level shifters to be as flexible as possible. There-
fore, the reference I/O voltage the flash is working with also needs to be connected to pin
1 of the J-Link connector.
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
RDI
RDI (Remote Debug Interface) is a standard defined by ARM, trying to standardize a de-
bugger / debug probe interface. It is defined only for cores that have the same CPU register
set as ARM7 CPUs. This chapter describes how to use the RDI DLL which comes with the
J-Link Software and Documentation Package. The J-Link RDI DLL allows the user to use J-
Link with any RDI-compliant debugger and IDE.
14.1 Introduction
Remote Debug Interface (RDI) is an Application Programming Interface (API) that defines
a standard set of data structures and functions that abstract hardware for debugging pur-
poses. J-Link RDI mainly consists of a DLL designed for ARM cores to be used with any
RDI compliant debugger. The J-Link DLL feature flash download and flash breakpoints can
also be used with J-Link RDI.
14.1.1 Features
• Can be used with every RDI compliant debugger.
• Easy to use.
• Flash download feature of J-Link DLL can be used.
• Flash breakpoints feature of J-Link DLL can be used.
• Instruction set simulation (improves debugging performance).
14.2 Licensing
In order to use the J-Link RDI software a separate license is necessary for each J-Link. For
some devices J-Link comes with a device-based license and some J-Link models also come
with a full license for J-Link RDI. The normal J-Link however, comes without any licenses.
For more information about licensing itself and which devices have a device-based license,
please refer to:
J-Link Model overview: Licenses
4. Select J-Link and press OK to connect to the target via J-Link. For more information
about the generic setup of J-Link RDI, please refer to Configuration on page 331. After
downloading an image to the target board, the debugger window looks as follows:
Note
RVDS version 3.1 does not longer support RDI protocol to communicate with the
debugger.
3. In the Connection Control dialog use the right mouse click on the first item and select
Add/Remove/Edit Devices.
4. Now select Add DLL to add the JLinkRDI.dll. Select the installation path of the
software, for example: C:\Program Files\SEGGER\JLinkARM_V350g\JLinkRDI.dll
5. After adding the DLL, an additional Dialog opens and asks for description: (These values
are voluntary, if you do not want change them, just click OK) Use the following values
and click on OK, Short Name: JLinkRDI Description: J-Link RDI Interface.
6. Back in the RDI Target List Dialog, select JLink-RDI and click Configure. For more
information about the generic setup of J-Link RDI, please refer to Configuration on
page 331.
7. Click the OK button in the configuration dialog. Now close the RDI Target List dialog.
Make sure your target hardware is already connected to J-Link.
8. In the Connection control dialog, expand the JLink ARM RDI Interface and select
the ARM_0 processor. Close the Connection Control window.
10. A project or an image is needed for debugging. After downloading, J-Link is used to
debug the target.
4. The Connection Editor dialog will be opened. Enter rdiserv in the Server field and
enter the following values in the Arguments field:
-config -dll <FullPathToJLinkDLLs>
Note that JLinkRDI.dll and JLinkARM.dll must be stored in the same directory. If the
standard J-Link installation path or another path that includes spaces has been used,
enclose the path in quotation marks.
Example:
-config -dll “C:\Program Files\SEGGER\JLinkARM_V350g\JLinkRDI.dll”
Refer to GHS manual “MULTI: Configuring Connections for ARM Targets”, chapter
“ARM Remote Debug Interface (rdiserv) Connections” for a complete list of possible
arguments.
5. Confirm the choices by clicking the Apply button after the Connect button.
6. The J-Link RDI Configuration dialog will open. For more information about the generic
setup of J-Link RDI, please refer to Configuration on page 331.
7. Click the OK button to connect to the target. Build the project and start the debugger.
Note that at least one action (for example step or run) has to be performed in order
to initiate the download of the application.
14.4 Configuration
This section describes the generic setup of J-Link RDI (same for all debuggers) using the
J-Link RDI configuration dialog.
Connection to J-Link
This setting allows the user to configure how the DLL should connect to the J-Link. Some J-
Link models also come with an Ethernet interface which allows to use an emulator remotely
via TCP/IP connection.
2. Click the Add license button and enter your license. Confirm your input by clicking
the OK button.
Macro file
A macro file can be specified to load custom settings to configure J-Link RDI with advanced
commands for special chips or operations. For example, a macro file can be used to initialize
a target to use the PLL before the target application is downloaded, in order to speed up
the download.
Command Description
Delay(x); Waits a given time, x = delay in milliseconds
Reset(x); Resets the target, x = delay in milliseconds
Go(); Starts the ARM core
Halt(); Halts the ARM core
Read8(Addr);
Reads a 8/16/32 bit value,
Read16(Addr);
Addr = address to read (as hex value)
Read32(Addr);
Verify8(Addr, Data); Verifies a 8/16/32 bit value,
Verify16(Addr, Data); Addr = address to verify (as hex value)
Verify32(Addr, Data); Data = data to verify (as hex value)
Write8(Addr, Data); Writes a 8/16/32 bit value,
Write16(Addr, Data); Addr = address to write (as hex value)
Write32(Addr, Data); Data = data to write (as hex value)
WriteVerify8(Addr, Data); Writes and verifies a 8/16/32 bit value,
WriteVerify16(Addr, Data); Addr = address to write (as hex value)
WriteVerify32(Addr, Data); Data = data to write (as hex value)
WriteRegister(Reg, Data); Writes a register
WriteJTAG_IR(Cmd); Writes the JTAG instruction register
WriteJTAG_DR(nBits, Data); Writes the JTAG data register
/*********************************************************************
*
* Macro file for J-LINK RDI
*
**********************************************************************
* File: LPC2294.setup
* Purpose: Setup for Philips LPC2294 chip
**********************************************************************
*/
SetJTAGSpeed(1000);
Reset(0);
Write32(0xE01FC040, 0x00000001); // Map User Flash into Vector area at (0-3f)
Write32(0xFFE00000, 0x20003CE3); // Setup CS0
Write32(0xE002C014, 0x0E6001E4); // Setup PINSEL2 Register
SetJTAGSpeed(2000);
JTAG speed
This allows the selection of the JTAG speed. There are basically three types of speed settings
(which are explained below):
• Fixed JTAG speed
• Automatic JTAG speed
• Adaptive clocking
Reset strategy
This defines the way J-Link RDI should handle resets called by software.
J-Link supports different reset strategies. This is necessary because there is no single way
of resetting and halting an ARM core before it starts to execute instructions.
For more information about the different reset strategies which are supported by J-Link and
why different reset strategies are necessary, please refer to Reset strategies .
Example of
logfile content:
14.5 Semihosting
Semihosting can be used with J-Link RDI. For more information how to enable semihosting
in J-Link RDI, please refer to Enabling Semihosting in J-Link RDI + AXD .
15.1 Introduction
Serial Wire Debug (SWD) is a debug interface specified by ARM, as a low pin count (2:
SWCLK, SWDIO) alternative to the traditional 4-wire JTAG (IEEE 1149.1) debug interface.
It was released before 2-wire cJTAG (IEEE 1149.7) was released. This chapter explains
SWD specifics that do not apply for other debug interfaces.
Note
Not all devices that support SWD also support multi-drop. This requires SWDv2 com-
patibility. For more information about if a specific device supports multi-drop, please
refer to the technical reference manual of the specific device
int ConfigTargetSettings(void) {
JLINK_ExecCommand("SetSWDTargetId=0x01234567"); // 28-bit target ID
JLINK_ExecCommand("SetSWDInstanceId=0x8"); // 4-bit instance ID
return 0;
}
RTT
SEGGER’s Real Time Transfer (RTT) is a technology for interactive user I/O in embedded ap-
plications. It combines the advantages of SWO and semihosting at very high performance.
16.1 Introduction
With RTT it is possible to output information from the target microcontroller as well as
sending input to the application at a very high speed without affecting the target’s real
time behavior.
SEGGER RTT can be used with any J-Link model and any supported target processor which
allows background memory access, which are Cortex-M and RX targets.
RTT supports multiple channels in both directions, up to the host and down to the target,
which can be used for different purposes and provide the most possible freedom to the user.
The default implementation uses one channel per direction, which are meant for printable
terminal input and output. With the J-Link RTT Viewer this channel can be used for multiple
“virtual” terminals, allowing to print to multiple windows (e.g. one for standard output, one
for error output, one for debugging output) with just one target buffer. An additional up (to
host) channel can for example be used to send profiling or event tracing data.
16.2.4 Requirements
SEGGER RTT does not need any additional pin or hardware, despite a J-Link connected via
the standard debug port to the target. It does not require any configuration of the target
or in the debugging environment and can even be used with varying target speeds.
RTT can be used in parallel to a running debug session, without intrusion, as well as without
any IDE or debugger at all.
16.2.5 Performance
The performance of SEGGER RTT is significantly higher than any other technology used to
output data to a host PC. An average line of text can be output in one microsecond or less.
Basically only the time to do a single memcopy().
16.4 Implementation
The SEGGER RTT implementation code is written in ANSI C and can be integrated into any
embedded application by simply adding the available sources.
RTT can be used via a simple and easy to use API. It is even possible to override the standard
printf() functions to be used with RTT. Using RTT reduces the time taken for output to a
minimum and allows printing debug information to the host computer while the application
is performing time critical real time tasks.
The implementation code also includes a simple version of printf() which can be used to
write formatted strings via RTT. It is smaller than most standard library printf() implemen-
tations and does not require heap and only a configurable amount of stack.
The SEGGER RTT implementation is fully configurable at compile time with pre-processor
defines. The number of channels, the size of the default channels can be set. Reading and
writing can be made task-safe with definable Lock() and Unlock() routines.
API functions
SEGGER_RTT_ConfigDownBuffer()
SEGGER_RTT_ConfigUpBuffer()
SEGGER_RTT_GetKey()
SEGGER_RTT_HasKey()
SEGGER_RTT_Init()
SEGGER_RTT_printf()
SEGGER_RTT_Read()
SEGGER_RTT_SetTerminal()
SEGGER_RTT_TerminalOut()
SEGGER_RTT_WaitKey()
SEGGER_RTT_Write()
SEGGER_RTT_WriteString()
16.4.1.1 SEGGER_RTT_ConfigDownBuffer()
Configure or add a down buffer by specifying its name, size and flags.
Syntax
int SEGGER_RTT_ConfigDownBuffer (unsigned BufferIndex, const char* sName,
char* pBuffer, int BufferSize, int Flags);
Parameter Meaning
Index of the buffer to configure.
BufferIndex
Must be lower than SEGGER_RTT_MAX_NUM_DOWN_CHANNELS.
Pointer to a 0-terminated string to be displayed as the name of the
sName
channel.
pBuffer Pointer to a buffer used by the channel.
BufferSize Size of the buffer in Bytes.
Flags Flags of the channel (blocking or non-blocking).
Return value
Value Meaning
≥0 O.K.
<0 Error
Example
//
// Configure down channel 1
//
SEGGER_RTT_ConfigDownChannel(1, "DataIn", &abDataIn[0], sizeof(abDataIn),
SEGGER_RTT_MODE_NO_BLOCK_SKIP);
Additional information
Once a channel is configured only the flags of the channel should be changed.
16.4.1.2 SEGGER_RTT_ConfigUpBuffer()
Configure or add an up buffer by specifying its name, size and flags.
Syntax
int SEGGER_RTT_ConfigUpBuffer (unsigned BufferIndex, const char* sName, char*
pBuffer, int BufferSize, int Flags);
Parameter Meaning
Index of the buffer to configure.
BufferIndex
Must be lower than SEGGER_RTT_MAX_NUM_UP_CHANNELS.
Pointer to a 0-terminated string to be displayed as the name of the
sName
channel.
pBuffer Pointer to a buffer used by the channel.
BufferSize Size of the buffer in Bytes.
Flags Flags of the channel (blocking or non-blocking).
Return value
Value Meaning
≥0 O.K.
<0 Error
Example
//
// Configure up channel 1 to work in blocking mode
//
SEGGER_RTT_ConfigUpChannel(1, "DataOut", &abDataOut[0], sizeof(abDataOut),
SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL);
Additional information
Once a channel is configured only the flags of the channel should be changed.
16.4.1.3 SEGGER_RTT_GetKey()
Reads one character from SEGGER RTT buffer 0. Host has previously stored data there.
Syntax
int SEGGER_RTT_GetKey (void);
Return value
Value Meaning
≥0 Character which has been read (0 - 255).
<0 No character available (empty buffer).
Example
int c;
c = SEGGER_RTT_GetKey();
if (c == 'q') {
exit();
}
16.4.1.4 SEGGER_RTT_HasKey()
Checks if at least one character for reading is available in SEGGER RTT buffer.
Syntax
int SEGGER_RTT_HasKey (void);
Return value
Value Meaning
1 At least one character is available in the buffer.
0 No characters are available to be read.
Example
if (SEGGER_RTT_HasKey()) {
int c = SEGGER_RTT_GetKey();
}
16.4.1.5 SEGGER_RTT_Init()
Initializes the RTT Control Block.
Syntax
void SEGGER_RTT_Init (void);
Additional information
Should be used in RAM targets, at start of the application.
16.4.1.6 SEGGER_RTT_printf()
Send a formatted string to the host.
Syntax
int SEGGER_RTT_printf (unsigned BufferIndex, const char * sFormat, …)
Parameter Meaning
BufferIndex Index of the up channel to sent the string to.
sFormat Pointer to format string, followed by arguments for conversion.
Return value
Value Meaning
≥0 Number of bytes which have been sent.
<0 Error.
Example
Additional information
(1) Conversion specifications have following syntax:
• %[flags][FieldWidth][.Precision]ConversionSpecifier
(2) Supported flags:
• -: Left justify within the field width
• +: Always print sign extension for signed conversions
• 0: Pad with 0 instead of spaces. Ignored when using ’-’-flag or precision
(3) Supported conversion specifiers:
• c: Print the argument as one char
• d: Print the argument as a signed integer
• u: Print the argument as an unsigned integer
• x: Print the argument as an hexadecimal integer
• s: Print the string pointed to by the argument
• p: Print the argument as an 8-digit hexadecimal integer. (Argument shall be a pointer
to void.)
16.4.1.7 SEGGER_RTT_Read()
Read characters from any RTT down channel which have been previously stored by the host.
Syntax
unsigned SEGGER_RTT_Read (unsigned BufferIndex, char* pBuffer, unsigned
BufferSize);
Parameter Meaning
BufferIndex Index of the down channel to read from.
pBuffer Pointer to a character buffer to store the read characters.
BufferSize Number of bytes available in the buffer.
Return value
Value Meaning
≥0 Number of bytes that have been read.
Example
char acIn[4];
unsigned NumBytes = sizeof(acIn);
NumBytes = SEGGER_RTT_Read(0, &acIn[0], NumBytes);
if (NumBytes) {
AnalyzeInput(acIn);
}
16.4.1.8 SEGGER_RTT_SetTerminal()
Set the “virtual” terminal to send following data on channel 0.
Syntax
void SEGGER_RTT_SetTerminal(char TerminalId);
Parameter Meaning
TerminalId Id of the virtual terminal (0-9).
Example
//
// Send a string to terminal 1 which is used as error out.
//
SEGGER_RTT_SetTerminal(1); // Select terminal 1
SEGGER_RTT_WriteString(0, "ERROR: Buffer overflow");
SEGGER_RTT_SetTerminal(0); // Reset to standard terminal
Additional information
All following data which is sent via channel 0 will be printed on the set terminal until the
next change.
16.4.1.9 SEGGER_RTT_TerminalOut()
Send one string to a specific “virtual” terminal.
Syntax
int SEGGER_RTT_TerminalOut (char TerminalID, const char* s);
Parameter Meaning
TerminalId Id of the virtual terminal (0-9).
s Pointer to 0-terminated string to be sent.
Return value
Value Meaning
≥0 Number of bytes sent to the terminal.
<0 Error
Example
//
// Sent a string to terminal 1 without changing the standard terminal.
//
SEGGER_RTT_TerminalOut(1, "ERROR: Buffer overflow.");
Additional information
SEGGER_RTT_TerminalOut does not affect following data which is sent via channel 0.
16.4.1.10 SEGGER_RTT_Write()
Send data to the host on an RTT channel.
Syntax
unsigned SEGGER_RTT_Write (unsigned BufferIndex, const char* pBuffer, un-
signed NumBytes);
Parameter Meaning
BufferIndex Index of the up channel to send data to.
pBuffer Pointer to data to be sent.
NumBytes Number of bytes to send.
Return value
Value Meaning
Number of bytes which have been
≥0
sent
Additional information
With SEGGER_RTT_Write() all kinds of data, not only printable one can be sent.
16.4.1.11 SEGGER_RTT_WaitKey()
Waits until at least one character is available in SEGGER RTT buffer 0. Once a character
is available, it is read and returned.
Syntax
int SEGGER_RTT_WaitKey (void);
Return value
Value Meaning
≥0 Character which has been read (0 - 255).
Example
int c = 0;
do {
c = SEGGER_RTT_WaitKey();
} while (c != 'c');
16.4.1.12 SEGGER_RTT_WriteString()
Write a 0-terminated string to an up channel via RTT.
Syntax
unsigned SEGGER_RTT_WriteSting (unsigned BufferIndex, const char* s);
Parameter Meaning
BufferIndex Index of the up channel to send string to.
s Pointer to 0-terminated string to be sent.
Return value
Value Meaning
≥0 Number of bytes which have been sent.
Example
SEGGER_RTT_MAX_NUM_UP_BUFFERS
Maximum number of up (to host) channels.
BUFFER_SIZE_DOWN
Size of the buffer for default down channel 0.
BUFFER_SIZE_UP
Size of the buffer for default up channel 0.
SEGGER_RTT_PRINT_BUFFER_SIZE
Size of the buffer for SEGGER_RTT_printf to bulk-send chars.
SEGGER_RTT_LOCK()
Locking routine to prevent interrupts and task switches from within an RTT operation.
SEGGER_RTT_UNLOCK()
Unlocking routine to allow interrupts and task switches after an RTT operation.
SEGGER_RTT_IN_RAM
Indicate the whole application is in RAM to prevent falsely identifying the RTT Control Block
in the init segment by defining as 1.
SEGGER_RTT_MODE_NO_BLOCK_SKIP
If the up buffer has not enough space to hold all of the incoming data, nothing is written
to the buffer.
SEGGER_RTT_MODE_NO_BLOCK_TRIM
If the up buffer has not enough space to hold all of the incoming data, the available space
is filled up with the incoming data while discarding any excess data.
Note
RTT_CTRL_TEXT_*
Set the text color to one of the following colors.
• BLACK
• RED
• GREEN
• YELLOW
• BLUE
• MAGENTA
• CYAN
• WHITE (light grey)
• BRIGHT_BLACK (dark grey)
• BRIGHT_RED
• BRIGHT_GREEN
• BRIGHT_YELLOW
• BRIGHT_BLUE
• BRIGHT_MAGENTA
• BRIGHT_CYAN
• BRIGHT_WHITE
RTT_CTRL_BG_*
Set the background color to one of the following colors.
• BLACK
• RED
• GREEN
• YELLOW
• BLUE
• MAGENTA
• CYAN
• WHITE (light grey)
• BRIGHT_BLACK (dark grey)
• BRIGHT_RED
• BRIGHT_GREEN
• BRIGHT_YELLOW
• BRIGHT_BLUE
• BRIGHT_MAGENTA
• BRIGHT_CYAN
• BRIGHT_WHITE
----------------------------------------------------------------------
File : RTT.c
Purpose : Simple implementation for output via RTT.
It can be used with any IDE.
---------------------------- END-OF-HEADER ---------------------------
*/
#include "SEGGER_RTT.h"
int main(void) {
int Cnt = 0;
16.7 FAQ
Q: How does J-Link find the RTT buffer?
A: There are two ways: If the debugger (IDE) knows the address of the SEGGER RTT
Control Block, it can pass it to J-Link. This is for example done by J-Link Debugger. If
another application that is not SEGGER RTT aware is used, then J-Link searches for the
ID in the known target RAM during execution of the application in the background. This
process normally takes just fractions of a second and does not delay program execution.
Q: I am debugging a RAM-only application. J-Link finds an RTT buffer, but I get no output.
What can I do?
A: In case the init section of an application is stored in RAM, J-Link might falsely identify
the block in the init section instead of the actual one in the data section. To prevent
this, set the define SEGGER_RTT_IN_RAM to 1. Now J-Link will find the correct RTT
buffer, but only after calling the first SEGGER_RTT function in the application. A call to
SEGGER_RTT_Init() at the beginning of the application is recommended.
Q: Can this also be used on targets that do not have the SWO pin?
A: Yes, the debug interface is used. This can be JTAG or SWD (2pins only!) on most Cortex-
M devices, or even the FINE interface on some Renesas devices, just like the Infineon
SPD interface (single pin!).
Q: Can this also be used on Cortex-M0 and M0+?
A: Yes.
Q: Some terminal output (printf) Solutions “crash” program execution when executed
outside of the debug environment, because they use a Software breakpoint that triggers
a hardfault without debugger or halt because SWO is not initialized. That makes it
impossible to run a Debug-build in stand-alone mode. What about SEGGER-RTT?
A: SEGGER-RTT uses non-blocking mode per default, which means it does not halt program
execution if no debugger is present and J-Link is not even connected. The application
program will continue to work.
Q: I do not see any output, although the use of RTT in my application is correct. What
can I do?
A: In some cases J-Link cannot locate the RTT buffer in the known RAM region. In this case
the possible region or the exact address can be set manually via a J-Link exec command:
• Set ranges to be searched for RTT buffer: SetRTTSearchRanges <RangeStart [Hex]>
<RangeSize >[, <Range1Start [Hex]> <Range1Size>, …] (e.g. “SetRTTSearchRanges
0x10000000 0x1000, 0x2000000 0x1000”)
• Set address of the RTT buffer: SetRTTAddr <RTTBufferAddress [Hex]> (e.g.
“SetRTTAddr 0x20000000”)
• Set address of the RTT buffer via J-Link Control Panel -> RTTerminal
Note
J-Link exec commands can be executed in most applications, for example in J-Link
Commander via “exec <Command>”, in J-Link GDB Server via “monitor exec <Com-
mand>” or in IAR EW via “__jlinkExecCommand(”<Command>“);” from a macro file.
Trace
This chapter provides information about tracing in general as well as information about how
to use SEGGER J-Trace.
17.1 Introduction
With increasing complexity of embedded systems, demands to debug probes and utilities
(IDE, …) increase too. With tracing, it is possible to get an even better idea about what is
happening / has happened on the target system, in case of tracking down a specific error.
A special trace component in the target CPU (e.g. ETM on ARM targets) registers instruc-
tion fetches done by the CPU as well as some additional actions like execution/skipping
of conditional instructions, target addresses of branch/jump instructions etc. and provides
these events to the trace probe. Instruction trace allows reproducing what instructions have
been executed by the CPU in which order, which conditional instructions have been exe-
cuted/skipped etc., allowing to reconstruct a full execution flow of the CPU.
Note
To use any of the trace features mentioned in this chapter, the CPU needs to implement
this specific trace hardware unit. For more information about which targets support
tracing, please refer to Target devices with trace support .
1. Traditional trace:
Collects trace data while the CPU is running and stores them in a buffer on the trace robe.
If the buffer is full, writes continues at the start of the buffer, overwriting the oldest trace
data in it. The debugger on the PC side can request trace data from the probe only when
the target CPU is halted. This allows doing backtrace as described in What is backtrace?
on page 362.
2. Streaming trace:
Trace data is collected while the CPU is running but streamed to the PC in real-time, while
the target CPU continues to execute code. This increases the trace buffer (and therefore
the amount of trace data that can be stored) to an theoretically unlimited size (on modern
systems multiple terabytes). Streaming trace allows to implement more complex trace
features like code coverage and code profiling as these require a complete instruction flow,
not only the last xx executed instructions, to provide real valuable data.
This enables a fast and efficient way to improve the code or to create a suitable test suite
for uncovered blocks.
Note
Note
As can be seen in the following drawings, by moving the sampling point of the TDx signal,
a setup time for the trace data is generated (∆td). This can be used to enable tracing on
targets that do not provide a setup time for the trace data.
TCLK
TDx
a)
Drawing a) shows the correct behavior of a target and b) shows a target that does not
apply setup times. Therefore in b) the undelayed signal TDx would be sampled as a logical
0 at the rising edge of TCLK which would give the J-Trace wrong tracing information. In the
case where the sample point of TDx is moved to the left (negative) by ∆td at each rising
TCLK edge a logical 1 is sampled which in this case means that the J-Trace now receives
the correct trace information.
TCLK
TDx
Δtd Δtd
TDx + Δtd
b)
Note
17.3.1 CPUs that provide tracing via pins and on-chip buffer
Some CPUs provide a choice to either use the on-chip trace buffer for tracing (e.g. when
the trace pins are needed as GPIOs etc. or are not available on all packages of the device).
• For J-Link: The on-chip trace buffer is automatically used, as this is the only method
J-Link supports.
• For J-Trace: By default, tracing via trace pins is used. If, for some reason, the on-chip
trace buffer shall be used instead, the J-Link software needs to be made aware of this.
The trace source can be selected via the SelectTraceSource command string. For more
information about the syntax of this command string, please refer to J-Link Command
Strings . For more information about how to use J-Link Command Strings in different
environments, please refer to Using J-Link Command Strings .
This chapter gives an overview about J-Link / J-Trace specific hardware details, such as the
pinouts and available adapters.
*On some models like the J-Link ULTRA, these pins are re-
served for firmware extension purposes. They can be left open
or connected to GND in normal debug environment. Please do
not assume them to be connected to GND inside J-Link.
Pins 4, 6, 8, 10, 12 are GND pins connected to GND in J-Link. They should also be connected
to GND in the target system.
Command Explanation
power on Switch target power on
Command Explanation
power off Switch target power off
power on perm Set target power supply default to “on”
power off perm Set target power supply default to “off”
*On some models like the J-Link ULTRA, these pins are re-
served for firmware extension purposes. They can be left open
or connected to GND in normal debug environment. Please do
not assume them to be connected to GND inside J-Link.
Pins 4, 6, 8, 10, 12 are GND pins connected to GND in J-Link. They should also be connected
to GND in the target system.
Command Explanation
power on Switch target power on
power off Switch target power off
power on perm Set target power supply default to “on”
power off perm Set target power supply default to “off”
*On some models like the J-Link ULTRA, these pins are re-
served for firmware extension purposes. They can be left open
or connected to GND in normal debug environment. Please do
not assume them to be connected to GND inside J-Link.
*On some models like the J-Link ULTRA, these pins are re-
served for firmware extension purposes. They can be left open
or connected to GND in normal debug environment. Please do
not assume them to be connected to GND inside J-Link.
The following table lists the pinout for the SPI interface on J-Link.
Note
Never connect trace cable and JTAG cable at the same time because this may lead to
unstable debug and trace connections.
Command Explanation
power on Switch target power on
power off Switch target power off
Command Explanation
power on perm Set target power supply default to “on”
power off perm Set target power supply default to “off”
Note
*On some models like the J-Link ULTRA, these pins are reserved for firmware exten-
sion purposes. They can be left open or connected to GND in normal debug environ-
ment. Please do not assume them to be connected to GND inside J-Link.
18.5 Adapters
There are various adapters available for J-Link as for example the JTAG isolator, the J-Link
RX adapter or the J-Link Cortex-M adapter.
For more information about the different adapters, please refer to
J-Link adapters
Background information
This chapter provides background information about JTAG and ARM. The ARM7 and ARM9
architecture is based on Reduced Instruction Set Computer (RISC) principles. The instruc-
tion set and the related decode mechanism are greatly simplified compared with micropro-
grammed Complex Instruction Set Computer (CISC).
19.1 JTAG
JTAG is the acronym for Joint Test Action Group. In the scope of this document, “the JTAG
standard” means compliance with IEEE Standard 1149.1-2001.
Idle
Idle is a TAP controller state between scan (DR or IR) operations. Once entered, this state
remains active as long as TMS is low.
DR-Scan
Temporary controller state. If TMS remains low, a scan sequence for the selected data
registers is initiated.
IR-Scan
Temporary controller state. If TMS remains low, a scan sequence for the instruction register
is initiated.
Capture-DR
Data may be loaded in parallel to the selected test data registers.
Shift-DR
The test data register connected between TDI and TDO shifts data one stage towards the
serial output with each clock.
Exit1-DR
Temporary controller state.
Pause-DR
The shifting of the test data register between TDI and TDO is temporarily halted.
Exit2-DR
Temporary controller state. Allows to either go back into Shift-DR state or go on to Up-
date-DR.
Update-DR
Data contained in the currently selected data register is loaded into a latched parallel output
(for registers that have such a latch). The parallel latch prevents changes at the parallel
output of these registers from occurring during the shifting process.
Capture-IR
Instructions may be loaded in parallel into the instruction register.
Shift-IR
The instruction register shifts the values in the instruction register towards TDO with each
clock.
Exit1-IR
Temporary controller state.
Pause-IR
Wait state that temporarily halts the instruction shifting.
Exit2-IR
Temporary controller state. Allows to either go back into Shift-IR state or go on to Up-
date-IR.
Update-IR
The values contained in the instruction register are loaded into a latched parallel output
from the shift-register path. Once latched, this new instruction becomes the current one.
The parallel latch prevents changes at the parallel output of the instruction register from
occurring during the shifting process.
Data trace
Data tracing means that the processor outputs trace data about memory accesses (read /
write access to which address and which data has been read / stored). In general, J-Trace
supports data tracing, but it depends on the debugger if this option is available or not. Note
that when using data trace, the amount of trace data to be captured rises enormously.
The result of the limited buffer size is that not more data can be traced than the buffer
can hold. Because of this limitation, an ETB is not a fully- alternative to the direct access
to an ETM via J-Trace.
19.4.4.2 RDI flash loader: Allows flash download from any RDI-compli-
ant tool chain
RDI (Remote debug interface) is a standard for “debug transfer agents” such as J-Link.
It allows using J-Link from any RDI compliant debugger. RDI by itself does not include
download to flash. To debug in flash, you need to somehow program your application pro-
gram (debuggee) into the flash. You can use J-Flash for this purpose, use the flash loader
supplied by the debugger company (if they supply a matching flash loader) or use the flash
loader integrated in the J-Link RDI software. The RDI software as well as the RDI flash
loader require licenses from SEGGER.
In the screenshot:
• The red box identifies the new firmware.
• The green box identifies the old firmware which has been replaced.
Note
To downdate J-Link / J-Trace, you need to invalidate the current J-Link / J-Trace firmware,
using the command exec InvalidateFW (first red box) .
In the screenshot, the yellow box contains information about the formerly used J-Link / J-
Trace firmware version, which is invalidated. Use an application (for example JLink.exe )
which uses the desired version of JLinkARM.dll. This automatically replaces the invalidated
firmware with its embedded firmware.
This is also show in the screenshot, were the invalidated firmware (2nd red box) is replaced
with the one provided by the currently used J-Link DLL (green box).
In the screenshot:
• “Updating firmware” identifies the new firmware.
• “Replacing firmware” identifies the old firmware which has been replaced.
This chapter describes the hardware requirements which have to be met by the target
board.
Note
These principles apply to all of the trace port signals (TRACEPKT[0:15], PIPES-
TAT[0:2], TRACESYNC), but special care must be taken with TRACECLK.
Matched impedance
Where available, the best termination scheme is to have the ASIC manufacturer match
the output impedance of the driver to the impedance of the PCB track on your board. This
produces the best possible signal.
DC parallel termination
This requires either a single resistor to ground, or a pull-up/pull-down combination of re-
sistors (Thevenin termination), fitted at the end of each signal and as close as possible to
the JTAG+Trace connector. If a single resistor is used, its value must be set equal to the
PCB track impedance. If the pull-up/pull-down combination is used, their resistance values
must be selected so that their parallel combination equals the PCB track impedance.
Caution:
At lower frequencies, parallel termination requires considerably more drive capability from
the ASIC than series termination and so, in practice, DC parallel termination is rarely used.
Signal Value
Fmax 200MHz
Ts setup time (min.) 2.0ns
Th hold time (min.) 1.0ns
TRACECLK high pulse width (min.) 1.5ns
TRACECLK high pulse width (min.) 1.5ns
Semihosting
J-Link supports semihosting for ARM targets. This chapter explains what semihosting is,
what it can be used for and how to enable semihosting in different environments.
21.1 Introduction
Semihosting is a mechanism for ARM based target devices to provide a way to communi-
cate/interact with a host system (the PC where the debugger is running on) to allow dif-
ferent operations to be performed /automatized. Typical use-cases for semihosting are:
• Calls to printf() in the target to be forwarded to the host system and then output in a
console/terminal on the host
• Calls to scanf() to retrieve user input entered in a console/terminal on the host and
then being received and evaluated by the target
• Performing file I/O operations on the host system (reading / writing files)
• Writing a flashloader that reads the bin file to be flashed from the host system and
performs the flashing operation chunk-wise
Most standard I/O libraries for embedded applications come with semihosting implemen-
tations for printf() and scanf().
21.1.1 Advantages
• Provides standardized commands for file I/O operations on the host, allowing relatively
complex operations with minimal logic in the target application
• Does not need chip-specific hardware capabilities
• Semihosting handling is natively supported by many debuggers/IDEs, for example GDB.
21.1.2 Disadvantages
• Target CPU is halted on each semihosting command, debugger evaluates the
semihosting command and restarts the CPU. This affects real-time behavior of the
system.
21.3 Implementation
In general, there are two ways of implement semihosting which are explained in the fol-
lowing:
• SVC instruction (called SWI on legacy CPUs)
• Breakpoint instruction
• J-Link GDBServer optimized version
Disadvantages
If the SVC instruction is also used by the user application or a operating system on the
target, the CPU will be halted on every semihosting exception and be restarted by the
debugger. This affects real-time behavior of the target application.
Disadvantages
Having a breakpoint instruction compiled in a library call will make it necessary to have
different compile options for debug and release configurations as the target application will
not run stand-alone, without debugger intervention.
dling the semihosting call. It also inhibits the CPU from being halted on each non-semi-
hosting call, preserving the real-time behavior of the target application.
Advantages
Application also runs stand-alone (no debugger connected). Real-time behavior of the ap-
plication is preserved.
Disadvantages
One hardware breakpoint is not available for debugging / stepping as it is permanently
used while semihosting is enabled. Only works with J-Link GDBServer as other debuggers
do not support this specialized version.
SVC_Handler:
;
; For semihosting R0 and R1 contain the semihosting information and may not
; be changed before semihosting is handled.
; If R2 and R3 contain values for the SVC handler or need to be restored for
; the calling function, save them on the stack.
;
#if SAVE_REGS_IN_SVC
PUSH {R2,R3}
#endif
BIC R2, LR, #0xFFFFFFFE
CMP R2, #0x01 ; Check whether we come from Thumb or ARM mode
BNE CheckSemiARM
CheckSemiThumb:
#if BIG_ENDIAN
LDRB R2, [LR, #-2]
#else
LDRB R2, [LR, #-1]
#endif
LDR R3, _DataTable2
CMP R2, R3 ; ARM semihosting call?
BNE DoSVC
B SemiBreak
CheckSemiARM:
LDR R2, [LR, #-4]
BIC R2, R2, #0xFF000000
LDR R3, _DataTable1
CMP R2, R3 ; Thumb semihosting call?
BNE DoSVC
#if SAVE_REGS_IN_SVC
POP {R2,R3} ; Restore regs needed for semihosting
#endif
SemiBreak: ; Debugger will set a breakpoint here and perform exception return
NOP
MOVS R0, #+0 ; Make sure we have a valid return value in case
BX LR ; debugger is not connected
DoSVC:
;
; Customer specific SVC handler code
;
MOVS R0, #+0 ; Replace this code with your SVC Handler
BX LR
_DataTable1:
.word 0x00123456
_DataTable2:
.byte 0xAB
.byte 0x00
.byte 0x00
.byte 0x00
21.4.1 Register R0
Right before the operation that halts the CPU for semihosting, is performed, the target
application needs to prepare CPU register R0 and (depending on the command) also some
other CPU registers. On halt, R0 will hold the semihosting command, so the debugger can
determine further parameters and operation to be performed, from it.
Command RO value
SYS_OPEN 0x01
SYS_CLOSE 0x02
SYS_WRITEC 0x03
SYS_WRITE0 0x04
SYS_WRITE 0x05
SYS_READ 0x06
SYS_READC 0x07
SYS_ISTTY 0x09
SYS_SEEK 0x0A
SYS_FLEN 0x0C
SYS_REMOVE 0x0E
SYS_RENAME 0x0F
SYS_GET_CMDLINE 0x15
SYS_EXIT 0x18
Word 0
Pointer to a null-terminated string that specifies the file to open. Special: The string “:tt”
specifies the console input/output (usually stdin / stdout). Which one is selected depends
on if the stream is opened for reading or writing.
Word 1
A number that specifies how the file is to be opened (reading/writing/appending etc.). In
the following, the corresponding ISO C fopen() modes for the numbers are listed. ISO C
fopen() modes
ISO C
Word1 fopen()
mode
0 r
1 rb
2 r+
3 r+b
ISO C
Word1 fopen()
mode
4 w
5 wb
6 w+
7 w+b
8 a
9 ab
10 a+
11 a+b
Word 2
Integer that specifies the length of the string (excluding the terminating null character)
pointed to by word 0.
Return value
Operation result is written to register R0 by the debugger.
Value Meaning
O.K., handle of the file (needed for
≠0
SYS_CLOSE etc.)
= -1 Error
Word 0
Handle of the file retrieved on SYS_OPEN
Return value
Operation result is written to register R0 by the debugger.
Value Meaning
=0 O.K.
= -1 Error
Word 0
Pointer to the character to the written.
Return value
None
Return value
None
Word 0
Handle of the file to be written.
Word 1
Pointer to the data on the target, to be written.
Word 2
Number of bytes to write
Return value
Operation result is written to register R0 by the debugger.
Value Meaning
=0 O.K.
Number of bytes to write left (in case not
≠0
all bytes could be written)
Word 0
Handle of the file to be read.
Word 1
Pointer to a buffer on the target where data from file is written to.
Word 2
Number of bytes to read
Return value
Operation result is written to register R0 by the debugger.
Value Meaning
=0 O.K.
Number of bytes to read left (in case not
all bytes could be read). If identical to the
≠0 number of bytes to be read, read pointer
was pointing to end-of-file and no bytes
have been read.
Return value
Character that has been read is written to register R0.
Word 0
Handle of the file to be checked.
Return value
Operation result is written to register R0 by the debugger.
Value Meaning
=1 O.K., given handle is an interactive device.
=0 O.K., given handle is not an interactive device.
Else Error
Word 0
Handle of the file.
Word 1
Position of the filepointer inside the file, to set to.
Return value
Operation result is written to register R0 by the debugger.
Value Meaning
=0 O.K.
≠0 Error
Word 0
Handle of the file.
Return value
Operation result is written to register R0 by the debugger.
Value Meaning
≥0 File size in byte
= -1 Error
Word 0
Pointer to a null-terminated string that specifies the path + file to be deleted.
Word 1
Length of the string pointed to by word 0 .
Return value
Operation result is written to register R0 by the debugger.
Value Meaning
=0 O.K.
≠0 Error
Word 0
Pointer to a null-terminated string that specifies the old name of the file.
Word 1
Length of the string (without terminating null-character) pointed to by word 0 .
Word 2
Pointer to a null-terminated string that specifies the new name of the file.
Word 3
Length of the string (without terminating null-character) pointed to by word 2 .
Return value
Operation result is written to register R0 by the debugger.
Value Meaning
=0 O.K.
≠0 Error
Word 0
Pointer to a buffer on the target system to store the command line to.
Word 1
Size of the buffer in bytes.
Return value
After the operation, word 1 will hold the length of the command line string. Operation result
is written to register R0 by the debugger.
Value Meaning
=0 O.K.
≠0 Error
Return value
None.
$semihosting_enabled
Set this variable to 0 to disable semihosting. If you are debugging an application running
from ROM, this allows you to use an additional watchpoint unit.
Set this variable to 1 to enable semihosting. This is the default.
Set this variable to 2 to enable Debug Communications Channel (DCC) semihosting.
The S bit in $vector_catch has no effect unless semihosting is disabled.
$semihosting_vector
This variable controls the location of the breakpoint set by J-Link RDI to detect a semihosted
SWI. It is set to the SWI entry in the exception vector table () by default.
22.1 J-Link
• Operating temperature +5°C … +60°C
• Storage temperature -20°C … +65 °C
• Relative humidity (non-condensing) Max. 90% rH
• For indoor use only. Use on current-limited USB ports only.
• J-Link WiFi only: This device is test equipment and consequently is exempt from part
15 of the FCC rules under section 15.103.
22.2 Flasher
• Operating temperature +5°C … +60°C (+5°C … +45°C for Flasher Portable PLUS when
charging internal battery)
• Storage temperature -20°C … +65 °C
• Relative humidity (non-condensing) Max. 90% rH
• For indoor use only. Use on current-limited USB ports only.
22.3 J-Trace
• Operating temperature +5°C … +60°C
• Storage temperature -20°C … +65 °C
• Relative humidity (non-condensing) Max. 90% rH
• For indoor use only. Use on current-limited USB ports only.
This chapter contains troubleshooting tips as well as solutions for common problems which
might occur when using J-Link / J-Trace. There are several steps you can take before con-
tacting support. Performing these steps can solve many problems and often eliminates the
need for assistance. This chapter also contains a collection of frequently asked questions
(FAQs) with answers.
23.2 Troubleshooting
23.2.1 General procedure
If you experience problems with J-Link / J-Trace, you should follow the steps below to solve
these problems:
• Close all running applications on your host system.
• Disconnect the J-Link / J-Trace device from USB.
• Disable power supply on the target.
• Re-connect J-Link / J-Trace with the host system (attach USB cable).
• Enable power supply on the target.
• Try your target application again. If the problem remains continue the following
procedure.
• Close all running applications on your host system again.
• Disconnect the J-Link / J-Trace device from USB.
• Disable power supply on the target.
• Re-connect J-Link / J-Trace with the host system (attach the USB cable).
• Enable power supply on the target.
• Start JLink.exe .
• If JLink.exe displays the J-Link / J-Trace serial number and the target processor’s core
ID, the J-Link / J-Trace is working properly and cannot be the cause of your problem.
• If the problem persists and you own an original product (not an OEM version), see
section Contacting support .
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