Difference between revisions of "J-Link Commander"
m |
Arne.kulinna (talk | contribs) (→Commands) |
||
Line 50: | Line 50: | ||
|- |
|- |
||
| [[#VCOM | VCOM]] || VCOM || Enable/disable VCOM Takes effect after power cycle of the probe |
| [[#VCOM | VCOM]] || VCOM || Enable/disable VCOM Takes effect after power cycle of the probe |
||
+ | |- |
||
+ | | [[#BootMode | BootMode]] || BootMode || Select boot mode of the connected probe. |
||
|- |
|- |
||
| [[#Reboot | Reboot]] || Reboot || Reboot the connected probe. |
| [[#Reboot | Reboot]] || Reboot || Reboot the connected probe. |
||
Line 452: | Line 454: | ||
==== Example ==== |
==== Example ==== |
||
<tt>VTREF 3300</tt> |
<tt>VTREF 3300</tt> |
||
+ | |||
+ | === BootMode === |
||
+ | Selects the boot mode of the connected probe if supported (available from V7.96n). |
||
+ | A power cycle is necessary to enter new boot mode after selection. |
||
+ | |||
+ | ==== Syntax ==== |
||
+ | <tt>BootMode <Mode></tt> |
||
+ | {| class="wikitable" |
||
+ | |- |
||
+ | ! Parameter !! Meaning |
||
+ | |- |
||
+ | | ''Mode'' || 0: J-Link <br> 1: CMSIS-DAPv1 |
||
+ | |} |
||
=== Reboot === |
=== Reboot === |
Latest revision as of 10:24, 21 June 2024
J-Link Commander (JLink.exe / JLinkExe) is a free, command line based utility that can be used for verifying proper functionality of J-Link as well as for simple analysis of the target system with J-Link. It supports some simple commands, such as memory dump, halt, step, go etc. to verify the target connection. The J-Link Commander is part of the J-Link Software and Documentation Pack, which is available for download on the SEGGER webpage.
The sources of the J-Link Commander are available as part of the J-Link SDK.
Contents
- 1 Commands
- 1.1 ?
- 1.2 Exit
- 1.3 ExitOnError
- 1.4 Sleep
- 1.5 Log
- 1.6 ExpDevList
- 1.7 ExpDevListXML
- 1.8 USB
- 1.9 IP
- 1.10 SelectProbe
- 1.11 ShowEmuList
- 1.12 Power
- 1.13 VTREF
- 1.14 BootMode
- 1.15 Reboot
- 1.16 Uptime
- 1.17 VCOM
- 1.18 ShowFWInfo
- 1.19 ShowHWStatus
- 1.20 License
- 1.21 IPAddr
- 1.22 GWAddr
- 1.23 DNSAddr
- 1.24 ShowConf
- 1.25 Calibrate
- 1.26 Connect
- 1.27 Device
- 1.28 SelectInterface
- 1.29 Speed
- 1.30 LE
- 1.31 BE
- 1.32 Halt
- 1.33 IsHalted
- 1.34 WaitHalt
- 1.35 Go
- 1.36 Reset
- 1.37 ResetX
- 1.38 RSetType
- 1.39 Step
- 1.40 IS
- 1.41 MS
- 1.42 Regs
- 1.43 RReg
- 1.44 WReg
- 1.45 MoE
- 1.46 SetBP
- 1.47 ClearBP
- 1.48 SetWP
- 1.49 ClearWP
- 1.50 VCatch
- 1.51 SetPC
- 1.52 ReadAP
- 1.53 WriteAP
- 1.54 ReadDP
- 1.55 WriteDP
- 1.56 RCP15Ex
- 1.57 WCP15Ex
- 1.58 Term
- 1.59 Mem
- 1.60 Mem8
- 1.61 Mem16
- 1.62 Mem32
- 1.63 Write1
- 1.64 Write2
- 1.65 Write4
- 1.66 Write8
- 1.67 JTAGConf
- 1.68 JTAGId
- 1.69 WJTAGIR
- 1.70 WJTAGDR
- 1.71 WJTAGRaw
- 1.72 ResetTAP
- 1.73 ResetTRST
- 1.74 ICE
- 1.75 ReadICE
- 1.76 WriteICE
- 1.77 STraceStart
- 1.78 STraceStop
- 1.79 STraceRead
- 1.80 SWOSpeed
- 1.81 SWOStart
- 1.82 SWOStop
- 1.83 SWOStat
- 1.84 SWORead
- 1.85 SWOShow
- 1.86 SWOFlush
- 1.87 SWOView
- 1.88 Erase
- 1.89 LoadFile
- 1.90 SaveBin
- 1.91 VerifyBin
- 1.92 FWrite
- 1.93 FRead
- 1.94 FShow
- 1.95 FDelete
- 1.96 FSize
- 1.97 FList
- 1.98 SecureArea
- 1.99 PowerTrace
- 1.100 TestWSpeed
- 1.101 TestRSpeed
- 1.102 TestCSpeed
- 1.103 TestNWSpeed
- 1.104 TestNRSpeed
- 1.105 MR
- 1.106 Clock
- 1.107 Clock00
- 1.108 ClrTCK
- 1.109 SetTCK
- 1.110 ClrTDI
- 1.111 SetTDI
- 1.112 ClrTMS
- 1.113 SetTMS
- 1.114 ClrTRST
- 1.115 SetTRST
- 1.116 ClrRESET
- 1.117 SetRESET
- 2 Command sequence examples
- 3 Using J-Link Command Files
- 4 Perform flash download
- 5 Command line options
- 6 Batch processing
- 7 JLink.exe return value
- 8 Using J-Link Command Strings
- 9 Changing J-Link Reset Strategy
- 10 Connecting to a specific J-Link
- 11 Setup External CFI NOR Flash
- 12 Command specifics
Commands
The table below lists the available commands of J-Link Commander. Detailed descriptions of the commands can be found in the sections below. All commands are accepted case insensitive.
This list is only valid for the latest version of the J-Link Commander. In case of doubt, use the ? command.
Command (long) | Command (short) | Explanation |
---|---|---|
Basic | ||
? | ? | Show information about all or specific commands |
Exit | Exit | Close J-Link connection and quit |
ExitOnError | EoE | Exit on error |
Sleep | Sleep | Waits the given time (in milliseconds) |
Log | Log | Enables log to file |
ExpDevList | ExpDevList | Export device names from DLL internal device list to text file |
ExpDevListXML | ExpDevListXML | Export device names from DLL internal device list to XML file |
Configuration - J-Link | ||
USB | USB | Connect to J-Link via USB |
IP | IP | Connect to J-Link via TCP/IP or to Remote Server |
SelectProbe | SelPrb | Show list of all connected probes via specified interface. The Probe to communicate with can then be selected |
ShowEmuList | ShowEmuList | Show list of all connected probes via specified interface |
Power | Power | Switch power supply for target (5V-Supply pin) on or off |
VTREF | VTREF | Set fixed value for VTref on J-Link |
VCOM | VCOM | Enable/disable VCOM Takes effect after power cycle of the probe |
BootMode | BootMode | Select boot mode of the connected probe. |
Reboot | Reboot | Reboot the connected probe. |
Uptime | Uptime | Show Probe uptime since boot. |
ShowFWInfo | F | Show firmware info |
ShowHWStatus | St | Show hardware status |
License | License | Show list of all available license commands |
IPAddr | IPAddr | Show/Assign IP address and subnetmask of/to connected Probe |
GWAddr | GWAddr | Show/Assign network gateway address of/to connected Probe |
DNSAddr | DNSAddr | Show/Assign network DNS server address of/to connected Probe |
ShowConf | Conf | Show configuration of the connected Probe |
Calibrate | Calib | Calibrate the target current measurement |
Configuration - Target (CPU) | ||
Connect | Con | Connect to target device |
Device | Device | Select specific device J-Link shall connect to |
SelectInterface | SI | Select target interface |
Speed | Speed | Set target interface speed |
LE | LE | Change mode to little endian |
BE | BE | Change mode to big endian |
Debugging | ||
Halt | H | Halt CPU |
IsHalted | IH | Return current CPU state |
WaitHalt | WH | Wait until CPU is halted or timeout is reached |
Go | G | Start CPU if halted |
Reset | R | Reset CPU |
ResetX | RX | Reset CPU with delay after reset |
RSetType | Rst | Set the current reset type |
Step | S | Execute step(s) on the CPU |
IS | IS | Identify length of scan chain select register |
MS | MS | Measure length of scan chain |
Regs | Regs | Display CPU register contents |
RReg | RReg | Read register |
WReg | WReg | Write register |
MoE | MoE | Shows mode-of-entry (CPU halt reason) |
SetBP | SetBP | Set breakpoint |
ClearBP | ClrBP | Clear breakpoint |
SetWP | SetWP | Set watchpoint |
ClearWP | ClrWP | Clear watchpoint |
VCatch | VC | Write vector catch |
SetPC | SetPC | Set the PC to specified value |
ReadAP | ReadAP | Read CoreSight AP register |
WriteAP | WriteAP | Write CoreSight AP register |
ReadDP | ReadDP | Read CoreSight DP register |
WriteDP | WriteDP | Write CoreSight DP register |
RCP15Ex | RCE | Read CP15 register |
WCP15Ex | WCE | Write CP15 register |
Term | Term | Visualize printf output using DCC (SEGGER DCC handler running on target) |
Debugging - Memory operation | ||
Mem | Mem | Read memory and show corresponding ASCII values |
Mem8 | Mem8 | Read 8-bit items |
Mem16 | Mem16 | Read 16-bit items |
Mem32 | Mem32 | Read 32-bit items |
Write1 | W1 | Write 8-bit items |
Write2 | W2 | Write 16-bit items |
Write4 | W4 | Write 32-bit items |
Write8 | W8 | Write 64-bit items |
Debugging - JTAG related | ||
JTAGConf | JTAGConf | Set number of IR/DR bits before Target device |
JTAGId | I | Read JTAG Id |
WJTAGIR | WJIR | Write JTAG command (IR) |
WJTAGDR | WJDR | Write JTAG data (DR) |
WJTAGRaw | WJR | Write Raw JTAG data |
ResetTAP | RTAP | Reset TAP Controller using state machine (111110) |
ResetTRST | RT | Reset TAP Controller using nTRST |
Debugging - ICE | ||
ICE | ICE | Show state of the embedded ICE macrocell (ICE breaker) |
ReadICE | RI | Read Ice register |
WriteICE | WI | Write Ice register |
STRACE | ||
STraceStart | STStart | Starts STRACE |
STraceStop | STStop | Stops STRACE |
STraceRead | STRead | Reads collected STRACE data |
SWO | ||
SWOSpeed | SWOSpeed | Show supported SWO speeds |
SWOStart | SWOStart | Start SWO |
SWOStop | SWOStop | Stop SWO |
SWOStat | SWOStat | Display SWO status |
SWORead | SWORead | Read and display SWO data |
SWOShow | SWOShow | Read and analyze SWO data |
SWOFlush | SWOFlush | Flush SWO data |
SWOView | SWOView | View SWO terminal data |
Flash programming | ||
Erase | Erase | Erase flash (range) of selected device |
LoadFile | LoadFile | Load data file into target memory |
SaveBin | SaveBin | Save target memory range into binary file |
VerifyBin | VerifyBin | Verfy if specified bin file is at the specified target memory location |
Flasher File I/O Commands | ||
FWrite | FWr | (Flasher only) Write file to probe |
FRead | FRd | (Flasher only) Read file from probe |
FShow | FShow | (Flasher only) Read and display file from probe |
FDelete | FDel | (Flasher only) Delete file on probe |
FSize | FSz | (Flasher only) Display size of file on probe |
FList | FList | (Flasher only) List directory on probe |
SecureArea | SecureArea | (Flasher only) Creates/Removes secure area on probe |
Measurement and test commands | ||
PowerTrace | PowerTrace | Perform power trace (not supported by all models) |
TestWSpeed | TestW | Measure download speed into target memory |
TestRSpeed | TestR | Measure upload speed from target memory |
TestCSpeed | TestC | Measure CPU speed |
TestNWSpeed | TestNW | Measure network download speed |
TestNRSpeed | TestNR | Measure network upload speed |
MR | MR | Measure RTCK react time |
J-Link Pin control | ||
Clock | C | Output clock(s) on the TCK pin |
Clock00 | C00 | Output clock(s) on the TCK pin, with TDI == 0 and TMS == 0 |
ClrTCK | TCK0 | Clear TCK pin |
SetTCK | TCK1 | Set TCK pin |
ClrTDI | TDI0 | Clear TDI pin |
SetTDI | TDI1 | Set TDI pin |
ClrTMS | TMS0 | Clear TMS pin |
SetTMS | TMS1 | Set TMS pin |
ClrTRST | TRST0 | Clear TRST pin |
SetTRST | TRST1 | Set TRST pin |
ClrRESET | R0 | Clear RESET pin |
SetRESET | R1 | Set RESET pin |
?
Show information about all commands or one specific command.
Syntax
? [<Command>]
Parameter | Meaning |
---|---|
<Command> | (optional) Command, specific information is required for. |
Example
? Connect
Exit
Close target device connection, J-Link connection and closes the application.
Syntax
Exit
ExitOnError
Toggle exit J-Link Commander on error.
Short command
EoE
Syntax
EoE <1/0>
Parameter | Meaning |
---|---|
0 | Exit on error is off. |
1 | Exit on error is on. |
Sleep
Waits the given time. Usually used for J-Link Command Scripts.
Syntax
Sleep <Delay>
Parameter | Meaning |
---|---|
Delay | Amount of time to sleep in ms. |
Example
Sleep 100
Log
Enables log to file.
Syntax
Log <filename>
Parameter | Meaning |
---|---|
Filename | Log filename |
Example
Log "C:\Users\User\Desktop\MyLogFile.log"
ExpDevList
Export device names from DLL internal device list to text file.
Syntax
ExpDevList <Filename>
Parameter | Meaning |
---|---|
Filename | Path to text file destination. |
Example
ExpDevList "C:\Users\User\Desktop\JLinkSuppDev.txt"
ExpDevListXML
Export device names from DLL internal device list to XML file.
Syntax
ExpDevListXML <Filename>
Parameter | Meaning |
---|---|
Filename | Path to XML file destination. |
Example
ExpDevListXML "C:\Users\User\Desktop\JLinkSuppDev.xml"
USB
Connect to J-Link via USB. Opens the USB selection dialog if no port, SN or nickname (available from V7.92d) is passed.
Syntax
USB [<SN/Nickname>]
Parameter | Meaning |
---|---|
SN/Nickname | (optional) Serial number or nickname (available from V7.92d) of the J-Link to connect to. |
Example
USB 600100000
USB J-Link
USB "My J-Link"
IP
Connect to J-Link via TCP/IP or to Remote Server. Opens the IP selection dialog if no parameter is passed.
Syntax
IP [<IPAddr|RemoteServerString>]
Parameter | Meaning |
---|---|
IPAddr | (optional) IP Address of the J-Link to connect to. |
RemoteServerString | (optional) Remote server string of the J-Link remote server session to connect to. |
Example
IP tunnel:SomeTestName::jlink-europe.segger.com
SelectProbe
Show list of all connected probes via specified interface. The Probe to communicate with can then be selected.
Short command
SelPrb
Syntax
SelectProbe [<Interface0> <Interface1> ...]
Parameter | Meaning |
---|---|
Interface | (optional) Interface, J-Links are supposed to be located at (USB, IP). |
Example
SelectProbe USB IP
ShowEmuList
Show list of all connected probes via specified interface (e.g. USB/IP)
Syntax
ShowEmuList [<Interface0> <Interface1> ...]
Parameter | Meaning |
---|---|
Interface | (optional) Interface, J-Links are supposed to be located at (USB, IP). |
Example
ShowEmuList USB IP
Power
Switch power supply for target (J-Link pin 19, 5V-Supply) on or off, permanently or until next power-cycle.
Syntax
Power <State> [perm]
Parameter | Meaning |
---|---|
State | On: Power supply on. Off: Power supply off. |
perm | Sets the specified State value as default. |
Example
Power on
VTREF
Set fixed value for VTref on J-Link (0 == Auto detection).
Syntax
VTREF <Value[mV]>
Parameter | Meaning |
---|---|
Value[mV] | Value, VTref is supposed to be set to in millivolt. |
Example
VTREF 3300
BootMode
Selects the boot mode of the connected probe if supported (available from V7.96n). A power cycle is necessary to enter new boot mode after selection.
Syntax
BootMode <Mode>
Parameter | Meaning |
---|---|
Mode | 0: J-Link 1: CMSIS-DAPv1 |
Reboot
Reboot the connected probe and reconnect to it. If connection cannot be established in <Timeout>ms, an error is assumed.
Syntax
Reboot [<Timeout[ms]>]
Example
Reboot // Reboot with default timeout. Reboot 10000 // Reboot with 10 sec. timeout.
Uptime
Show current uptime of the connected Probe since boot.
Syntax
Uptime
Example
Uptime
VCOM
Enable/disable VCOM. Takes effect after power cycle of the Probe.
Syntax
VCOM <enable|disable>
Example
VCOM enable
ShowFWInfo
Show firmware info.
Short command
F
ShowHWStatus
Show hardware status.
Short command
St
License
Execute license command. if no command is passed: Show a list of all available license commands.
Syntax
License [Command]
Parameter Command | Meaning |
---|---|
add | Store a custom license on J-Link. Syntax: LicAdd <LicName> |
erase | Erase all custom licenses on J-Link. |
show | Show all licenses stored on J-Link. |
IPAddr
Show/Assign IP address and subnetmask of/to connected Probe.
Syntax
IPAddr
GWAddr
Show/Assign network gateway address of/to connected Probe.
Syntax
GWAddr
DNSAddr
Show/Assign network DNS server address of/to connected Probe.
Syntax
DNSAddr
ShowConf
Show configuration of the connected Probe.
Short command
Conf
Calibrate
Calibrate the target current measurement.
Short command
Calib
Connect
Connect to target device. If no device was preselected, the user is asked to provide the missing information about the connected device.
Short command
Con
Device
Select specific device J-Link shall connect to. If ? is passed: Show device selection dialog.
Syntax
Device <DeviceName>
Parameter | Meaning |
---|---|
DeviceName | Valid device name: Device is selected. ?: Shows device selection dialog. |
Example
Device STM32F407VE
SelectInterface
Select target interface.
Short command
SI
Syntax
SelectInterface <Interface>
Parameter | Meaning |
---|---|
Interface | Any supported target interface (e.g SWD, JTAG, ICSP, FINE, ...) |
Example
SelectInterface SWD
Speed
Set target interface speed.
Syntax
Speed <Setting>
Parameter | Meaning |
---|---|
Setting | Decimal value: Interface speed in kHz. auto: Interface speed is selected automatically. adaptive: Interface speed is set to adaptive. |
Example
Speed 4000
LE
Change mode to little endian.
BE
Change mode to big endian.
Halt
Halt CPU.
Short command
H
IsHalted
Return current CPU state.
Short command
IH
WaitHalt
Wait until CPU is halted or timeout is reached. If no timeout (in ms) is provided, a default timeout of 1000 ms is used.
Short command
WH
Syntax
WaitHalt [<TimeoutMs>]
Parameter | Meaning |
---|---|
TimeoutMs | (optional) Timeout in milliseconds. |
Example
WaitHalt 100
Go
Start CPU if halted.
Short command
G
Reset
Reset CPU.
Short command
R
ResetX
Reset CPU with delay 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.
Short command
RX
Syntax
ResetX <DelayAfterReset>
Parameter | Meaning |
---|---|
DelayAfterReset | Delay in ms. |
Example
RX 1000
RSetType
Set the current reset type.
Short command
Rst
Syntax
RSetType [<Type>]
Parameter | Meaning |
---|---|
Type | Desired reset type. If no type is provided, a list of all available types is printed. |
Example
RSetType 0
Step
Execute step(s) on the CPU and show the executed instructions. If no number of steps is provided, one step is executed.
Short command
S
Syntax
Step [<NumSteps> (decimal)]
Example
Step 10
IS
Identify length of scan chain select register.
MS
Measure length of scan chain.
Syntax
MS <ScanChain>
Parameter | Meaning |
---|---|
ScanChain | Scan chain to be measured. |
Regs
Display CPU register contents.
RReg
Read register. If no register name is passed, all available register names are printed.
Syntax
RReg <RegName>
Parameter | Meaning |
---|---|
RegIndex | Register to read. |
Example
RReg "R15 (PC)"
WReg
Write register.
Short command
WReg
Syntax
WReg <RegName> <Value>
Parameter | Meaning |
---|---|
RegName | Register to write to. |
Data | Data to write to the specified register. |
Example
WReg "R15 (PC)" 0x20000000
MoE
Shows mode-of-entry (Reason why CPU is halted).
SetBP
Set breakpoint.
Syntax
SetBP <addr> [<A/T>/<W/H>] [S/H]
Parameter | Meaning |
---|---|
Addr | Address to be breakpointed. |
A/T | Only for ARM7/9/11 and Cortex-R4 devices: A: ARM mode T: THUMB mode |
W/H | Only for MIPS devices: W: MIPS32 mode (Word) H: MIPS16 mode (Half-word) |
S/H | S: Force software BP H: Force hardware BP |
ClearBP
Clear breakpoint.
Short command
ClrBP
Syntax
ClearBP <BP_Handle>
SetWP
Set Watchpoint.
Syntax
SetWP <Addr(hex)> [<AccessType>] [<Size>] [<Data(hex)> [<DataMask(hex)> [<AddrMask(hex)>]]]
Parameter | Meaning |
---|---|
Addr | Address to be breakpointed. |
AccessType | Trigger on:
|
Size |
|
DataMask | Ignore data bits set to 1. |
AddrMask | Ignore address bits set to 1. |
Example
// Stop if value 0x1000 is written to address 0x20000000 (32-bit access): SetWP 0x20000000 W S32 0x1000 0 0
ClearWP
Clear watchpoint.
Short command
ClrWP
Syntax
ClearWP <WP_Handle>
VCatch
Write vector catch.
Short command
VC
Syntax
VCatch <Value>
SetPC
Set the PC to specified value.
Syntax
SetPC <Addr>
Parameter | Meaning |
---|---|
Addr | Address the PC should be set to. |
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
- See: Reading from another MEM-AP
- Read AP[0], IDR (register 3, bank 15):
WriteDP 2 0x000000F0 // Select AP[0] bank 15 ReadAP 3 // Read AP[0] IDR
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>
Parameter | Meaning |
---|---|
RegIndex | Index of AP register to write |
Data32Hex | Data to write |
Example
See: Reading from another MEM-AP
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, not with SWD) this command performs the additional dummy read request automatically.
Syntax
ReadDP <RegIndex>
Parameter | Meaning |
---|---|
RegIndex | Index of DP register to read |
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>
Parameter | Meaning |
---|---|
RegIndex | Index of DP register to write |
Data32Hex | Data to write |
Example
See: Reading from another MEM-AP
RCP15Ex
Read CP15 register.
Short command
RCE
Syntax
RCP15Ex <Op1> <CRn> <CRm> <Op2>
WCP15Ex
Write CP15 register.
Short command
WCE
Syntax
WCP15Ex <Op1> <CRn> <CRm> <Op2>
Term
Visualize printf output using DCC (SEGGER DCC handler running on target).
Mem
Read memory from the target system and show corresponding ASCII values. 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)
Example
Mem 0x0 0x100
or
mem AHB-AP (AP1):0x20000000 0x100
Mem8
Read memory from the target system in units of 8-bit. If necessary, the target CPU is halted in order to read memory.
Syntax
mem [<Zone>:]<Addr> <NumItems> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
NumItems | Number of items to read. Maximum is 0x100000. |
Example
Mem8 0x0 100
Mem16
Read memory from the target system in units of 16-bits. If necessary, the target CPU is halted in order to read memory.
Syntax
Mem16 [<Zone>:]<Addr> <NumItems> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
NumItems | Number of items to read. Maximum is 0x100000. |
Example
Mem16 0x0 100
Mem32
Read memory from the target system in units of 32-bits. If necessary, the target CPU is halted in order to read memory.
Syntax
Mem32 [<Zone>:]<Addr> <NumItems> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
NumItems | Number of items to read. Maximum is 0x100000. |
Example
Mem32 0x0 100
Write1
Write one single byte to the target system.
Short command
W1
Syntax
W1 [<Zone>:]<Addr> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
Data | 8-bits of data to write. |
Example
W1 0x0 01
Write2
Write 16-bit items.
Short command
W2
Syntax
W2 [<Zone>:]<Addr> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
Data | 16-bits of data to write. |
Example
W2 0x0 0011
Write4
Write 32-bit items.
Short command
W4
Syntax
W4 [<Zone>:]<Addr> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
Data | 32-bits of data to write. |
Example
W4 0x0 00112233
Write8
Write 64-bit items.
Supported since V7.86b
Short command
W8
Syntax
W8 [<Zone>:]<Addr> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
Data | 64-bits of data to write. |
Example
W8 0x0 0x0011223344556677
JTAGConf
Configure JTAG scan chain with multiple devices on it.
For more detailed information on how to configure a scan chain with multiple devices please refer to Determining values for scan chain configuration.
Syntax
Parameter | Meaning |
---|---|
IRPre | Sum of IRLens of all devices closer to TDO, where IRLen is the number of bits in the IR (Instruction Register) of one device. -1 == auto-detection. |
DRPre | Number of devices closer to TDO. -1 == auto-detection. |
Example
//
// JTAG chain: TDI -> TAP#3 -> TAP#2 -> TAP#1 -> TAP#0
// TAP#3 (ARM DAP): IRLen = 4-bit
// TAP#2 (RISC-V): IRLen = 5-bit
// TAP#1 (RISC-V): IRLen = 5-bit
// TAP#0 (custom): IRLen = 7-bit
//
Connect to TAP#1 (RISC-V):
JTAGConf 7 1 // IRPre = 7, DRPre = 1
Connect to TAP#2 (RISC-V):
JTAGConf 12 2 // IRPre = 7 + 5, DRPre = 1 + 1
JTAGId
Read JTAG Id.
Short command
I
WJTAGIR
Write JTAG command (IR). If no IRLen is passed, IRLen=4 is used.
Short command
WJIR
Syntax
WJTAGIR <Insturction(hex)> [<IRLen(dec)>]
Parameter | Meaning |
---|---|
Insturction | Insturction to send as hexadecimal value. |
IRLen | Instruction register length of the current selected device. |
WJTAGDR
Write JTAG data (DR).
Short command
WJDR
Syntax
WJTAGDR <Data64(hex)> <NumBits(dec)>
Parameter | Meaning |
---|---|
Data64 | Data to send. |
NumBits | Number of bits to send. |
WJTAGRaw
Write Raw JTAG data.
Short command
WJR
Syntax
WJTAGRaw <NumBits(dec)> <TMS(hex)> <TDI(hex)>
Parameter | Meaning |
---|---|
NumBits | Number of bits to send. |
TMS | TMS Data to send (hex) in reverse bit order. |
TDI | TDI Data to send (hex) in reverse bit order. |
Example
Execute SWD => JTAG switching sequence and read the IDCODE:
J-Link>wjr 88, 0x00FFE73CFFFFFFFFFFFFFF, 00000000000000000000000 // SWD=>JTAG Switching sequence TDO: 0000000000000000000000 J-Link>wjr 56, 0x30000000007003, 0x00000000000FE0 // Read IDCODE TDO: 00974008EE0110
ResetTAP
Reset TAP Controller using state machine (111110).
Short command
RTAP
ResetTRST
Reset TAP Controller using nTRST.
Short command
RT
ICE
Show state of the embedded ICE macrocell (ICE breaker).
ReadICE
Read Ice register.
Short command
RI
Syntax
RI <RegIndex>(hex)
Parameter | Meaning |
---|---|
RegIndex | Register index of register to read from. |
WriteICE
Write Ice register.
Short command
WI
Syntax
WI <RegIndex> <Data(hex)>
Parameter | Meaning |
---|---|
RegIndex | Register index of register to read from. |
Data | Data to write (in hex). |
STraceStart
Starts STRACE.
STraceStop
Stops STRACE.
STraceRead
Reads collected STRACE data.
SWOSpeed
Show supported SWO speeds.
SWOStart
Start SWO.
SWOStop
Stop SWO.
SWOStat
Display SWO status.
SWORead
Read and display SWO data.
SWOShow
Read, analyze and show SWO data.
SWOFlush
Flush SWO data.
SWOView
View SWO terminal data.
Erase
Erases all flash sectors or a certain flash range of the current device. A device has to be specified previously. When specified, all flash between the <SAddr> and <EAddr> will be erased. By default, the device is being reset before starting the erase operation. This may be skipped by adding "noreset".
Syntax
Erase [<SAddr> <EAddr>] [<noreset | reset>]
Examples
Erase
Erase 0x60000000 0x60001000
Erase 0x60000000 0x60001000 noreset
Erase 0 0 noreset
LoadFile
Program a given data file. For .bin files, a location has to be specified. By default also performs a verification of programmed data. Currently supported data files are:
- .bin
- .elf
- .hex
- .mot
- .s
- .s19
- .s37
- .srec
Syntax
LoadFile <FileName> [<Addr(.bin only)>] [<noreset | reset>]
Parameter | Meaning |
---|---|
Filename | Source filename. |
Addr | Only used for .bin files. Ignored for other formats. Destination address. If not passed, 0x0 is assumed. |
Reset | Used for setting the reset behaviour. "reset" used by default implicitly. When Reset is used "Addr" is always required, but the value is ignored for non .bin files. |
Examples
loadfile C:\Work\MyData.hex
loadfile C:\Work\MyData.bin 0x08000000
loadfile C:\Work\MyData.hex 0 noreset
loadfile C:\Work\MyData.bin 0x08000000 noreset
SaveBin
Save target memory range into binary file.
Syntax
SaveBin <filename> <addr> <NumBytes>
Parameter | Meaning |
---|---|
Filename | Destination file |
Addr | Source address. |
NumBytes | Number of bytes to read. |
Example
SaveBin C:\Work\test.bin 0x0000000 0x100
VerifyBin
Verfy if specified .bin file is at the specified target memory location.
Syntax
VerifyBin <filename> <addr>
Parameter | Meaning |
---|---|
Filename | Sample bin. |
Addr | Start address of memory to verify. |
Example
VerifyBin C:\Work\test.bin 0x0000000
FWrite
On probes 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 destination and source file.
Short command
FWr
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
FRead
On probes which support file I/O this command reads a specific file. Offset applies to both destination and source file.
Short command
FRd
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
FShow
On probes 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
FDelete
On probes which support file I/O this command deletes a specific file.
Short command
FDel
Syntax
fdelete <FileName>
Parameter | Meaning |
---|---|
FileName | File to delete from the Flasher. |
Example
FDelete Flasher.dat
FSize
On probes which support file I/O this command gets the size of a specific file. Currently, only Flasher models support file I/O.
Short command
FSz
Syntax
FSize <FileName>
Parameter | Meaning |
---|---|
FileName | Source file name to read from the Flasher. |
FList
On probes which support file I/O this command shows the directory tree of the Flasher.
SecureArea
On probes which support file I/O this command creates/removes a secure area on the probe.
Syntax
SecureArea <Operation>
PowerTrace
Perform power trace (not supported by all models).
Syntax
PowerTrace <LogFile> [<ChannelMask> <RefCountSel>]
TestWSpeed
Measure download speed into target memory.
Short command
TestW
Syntax
TestWSpeed [<Addr> [<Size>]]
TestRSpeed
Measure upload speed from target memory.
Short command
TestR
Syntax
TestRSpeed [<Addr> [<Size>] [<NumBlocks>]]
TestCSpeed
Measure CPU speed.
Short command
TestC
Syntax
TestCSpeed [<RAMAddr>]
TestNWSpeed
Measure network download speed between the host and the probe.
For a probe that is connected via USB, the USB download speed is measured.
For a probe that is connected via TCP/IP, the TCP/IP download speed is measured.
Short command
TestNW
Syntax
TestNWSpeed [<NumBytes> [<NumReps>]]
TestNRSpeed
Measure network upload speed between the probe and the host.
For a probe that is connected via USB, the USB upload speed is measured.
For a probe that is connected via TCP/IP, the TCP/IP upload speed is measured.
Short command
TestNR
Syntax
TestNRSpeed [<NumBytes> [<NumReps>]]
MR
Measure RTCK reaction time.
Syntax
mr [<RepCount>]
Parameter | Meaning |
---|---|
RepCount | Number of times the test is repeated (Default: 1). |
Example
mr 3
Clock
Output clock(s) on the TCK pin (J-Link pin 9).
Short command
C
Syntax
Clock [NumClocks]
Clock00
Output clock(s) on the TCK pin (J-Link pin 9), with TDI == 0 and TMS == 0.
Short command
C00
Syntax
Clock00 [NumClocks]
ClrTCK
Clear TCK pin (J-Link pin 9).
Short command
TCK0
SetTCK
Set TCK pin (J-Link pin 9).
Short command
TCK1
ClrTDI
Clear TDI pin (J-Link pin 5).
Short command
TDI0
SetTDI
Set TDI pin (J-Link pin 5).
Short command
TDI1
ClrTMS
Clear TMS pin (J-Link pin 7).
Short command
TMS0
SetTMS
Set TMS pin (J-Link pin 7).
Short command
TMS1
ClrTRST
Clear TRST pin (J-Link pin 3).
Short command
TRST0
SetTRST
Set TRST pin (J-Link pin 3).
Short command
TRST1
ClrRESET
Clear RESET pin (J-Link pin 15).
Short command
R0
SetRESET
Set RESET pin (J-Link pin 15).
Short command
R1
Command sequence examples
This section provides some examples for the J-Link Commander Commands
Reading from another MEM-AP
This example shows how to read data via a MEM-AP.
Assumptions
- MCU with a core AP & another AP for background memory access
- User wants to read data while the device is running, using background memory access.
- AP[0]: AHB-AP: CPU
- AP[1]: APB-AP: System AP (for background access)
Commands used
Example sequence
WriteDP 2 0x01000000 // SELECT register: Select AP[1] bank 0
WriteAP 0 0x80006012 // CSW register: DbgSwEnable: Enable, AddrInc: Increment, Size: 32 bits
WriteAP 1 0x00000000 // TAR register: Select address to start reading from
ReadAP 3 // DRW register: Read @0x0000_0000
ReadAP 3 // DRW register: Read @0x0000_0004
...
Using J-Link Command Files
J-Link commander can also be used in batch mode which allows the user to use J-Link commander for batch processing and without user interaction. Please do not confuse J-Link Command Files file with J-Link Script Files. When using J-Link commander in batch mode, the path to a command file is passed to it. The syntax in the command file is the same as when using regular commands in J-Link commander (one line per command). SEGGER recommends to always pass the device name via command line option due some devices need special handling on connect/reset in order to guarantee proper function. J-Link Command Files support C-Style comments.
Example
JLink.exe -device STM32F103ZE -CommandFile C:\\CommandFile.jlink
Contents of CommandFile.jlink:
si 1 // Select interface speed 4000 // Select speed /* Perform reset and halt */ r h loadfile C:\firmware.bin 0x08000000 // Load data file
Perform flash download
J-Link Commander allows to download data files of different types into the flash memory of the target systems.
- Connect J-Link to the PC
- Connect target system to J-Link
- Start J-Link Commander
- Enter the requested settings (e.g. target device, interface settings, etc...)
- Type the following commands:
- r
- loadfile <PathToFile> [<DestAddr>]
- J-Link Commander executes the flash download and prints out the time statistics on success.
Command line options
The table below describes the different command line options, which are supported by J-Link Commander:
Command line option | Explanation |
---|---|
Batch mode specific | |
-AutoConnect <Value> | Value==1: Forces the J-Link Commander to connect to the target, automatically. |
-CommandFile <CommandFilePath> | Selects a J-Link Command file which contains the commands for batch mode / auto execution. |
-ExitOnError <Value> | Value==1: Exit J-Link Commander on Error. |
-NoGui <Value> | Value==1: Suppresses GUI dialogs. |
J-Link connection specific | |
-IP <IP/Tunnel/Nickname> | Selects a specific J-Link (via IP/Tunnel/Nickname) to connect to via TCP/IP. |
-USB <SerialNo/Nickname> | Selects a specific J-Link (via its serial number) or nickname (available from V7.92d) to connect to. Used in case multiple J-Links are connected to the same PC via USB. |
Device connection specific | |
-Device <DeviceName> | Selects the target device. |
-If <TargetInterface> | Configures the target interface. |
-JLinkScriptFile <ScriptFilePath> | Selects a specific J-Link script file to use. |
-JTAGConf <IRPre>,<DRPre> | Configures the JTAG scan configuration of the target device. IRPre==-1 and DRPre==-1 can be passed to use auto-detection (=> first known device will be used). |
-Speed <InterfaceSpeed> | Configures the target interface speed. |
Misc | |
-Log <LogFilePath> | Sets a path a J-Link log file is to be created. |
-RTTTelnetPort <PortNo> | Set the J-Link RTT Telnet port to <PortNo> |
Example:
JLink.exe -device CC2538SF53 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1 -CommandFile C:\Work\JLinkCommandFile.jlink
Batch processing
While J-Link Commander is mainly designed to be used in interactive mode (so the user manually enters commands), as a verification utility, it can also be automated.
For this, a command file may be specified and passed via the -CommandFile command line parameter to J-Link Commander.
A command file is a simple file that contains 1 command per line, as if they were entered manually in the terminal.
Example:
Call:
JLink.exe -CommandFile C:\Work\JLinkCommandFile.jlink
Command file contents:
device CC2538SF53
si JTAG
speed 4000
jtagconf -1,-1
connect
JLink.exe return value
The return value of the J-Link Commander application (JLink.exe) can be read out int the environment variable ERRORLEVEL.
Examples:
1. Returns an Error (ERRORLEVEL == 1)
start /wait "J-Link Commander" "JLink.exe" -if InvalidInterfaceParameter ECHO error level is %ERRORLEVEL% pause
2. Returns no Error (ERRORLEVEL == 0)
start /wait "J-Link Commander" "JLink.exe" ECHO error level is %ERRORLEVEL% pause
For information how to access the environment variable ERRORLEVEL within a java application please refer to: http://stackoverflow.com/questions/8922485/how-to-execute-echo-errorlevel-in-java
For further information regarding this, please refer to: http://blogs.msdn.com/b/oldnewthing/archive/2008/09/26/8965755.aspx
Using J-Link Command Strings
In order to use J-Link Command Strings in J-Link Commander, the native J-Link Commander command exec supplemented by one of the available J-Link Command Strings can be used.
Example:
exec SupplyPower = 1 exec map reset exec map exclude 0x10000000-0x3FFFFFFF
Changing J-Link Reset Strategy
The reset strategy can be changed by executing the RSetType command:
RSetType = 12
Connecting to a specific J-Link
It is possible to have multiple J-Links connected to the PC at the same time (for more information, see here. To connect to a specific J-Link in an automated way (no user interaction required), J-Link Commander needs to be told the S/N of the J-Link to connect to. This can be done via two different methods:
- Specify the S/N directly via command line. See -SelectEmuBySN above for more information.
- Specify "SelectEmuBySN <SN>" (without quotes) as first command in the J-Link command file that is passed to J-Link Commander via command line
Setup External CFI NOR Flash
J-Link Commander supports downloading bin files into external CFI flash memory. In the following, it is explained which steps are necessary to prepare J-Link Commander for download into external CFI flash memory based on a sample sequence for a ST STM32F103ZE device:
r speed 1000 exec setcfiflash 0x64000000 - 0x64FFFFFF exec setworkram 0x20000000 - 0x2000FFFF w4 0x40021014 0x00000114 // RCC_AHBENR, FSMC clock enable w4 0x40021018 0x000001FD // GPIOD~G clock enable w4 0x40011400 0xB4BB44BB // GPIOD low config, NOE, NWE => Output, NWAIT => Input w4 0x40011404 0xBBBBBBBB // GPIOD high config, A16-A18 w4 0x40011800 0xBBBBBBBB // GPIOE low config, A19-A23 w4 0x40011804 0xBBBBBBBB // GPIOE high config, D5-D12 w4 0x40011C00 0x44BBBBBB // GPIOF low config, A0-A5 w4 0x40011C04 0xBBBB4444 // GPIOF high config, A6-A9 w4 0x40012000 0x44BBBBBB // GPIOG low config, A10-A15 w4 0x40012004 0x444B4BB4 // GPIOG high config, NE2 => output w4 0xA0000008 0x00001059 // CS control reg 2, 16-bit, write enable, Type: NOR flash w4 0xA000000C 0x10000505 // CS2 timing reg (read access) w4 0xA000010C 0x10000505 // CS2 timing reg (write access) speed 4000 mem 0x64000000 100 loadfile C:\STMB672_STM32F103ZE_TestBlinky.bin 0x64000000 mem 0x64000000 100
Command specifics
Verifybin command
The verifybin command in J-Link Commander executes a simple read of memory and compares the data against the data in the specified bin file. Note that *no* initialization of any flash interface etc. is done on this command. For external QSPI flash for example this means that the pins and the QSPI controller of the target MCU have to be already initialized etc. for this command to succeed. This is different for "loadfile" which may trigger a flash download implicitly where a flash loader is started that takes care of the initialization. Also note that executing a "loadfile" command in advance, does not guarantee that a "verifybin" succeeds because the loadfile commands restores the controller state after it is done. So if the QSPI controller and/or pins were not initialized before the "loadfile" command, they are not after it either. They are only available while "loadfile" is active.