J-Link Commander
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 Detailed description
- 1.1.1 clrBP
- 1.1.2 clrWP
- 1.1.3 device
- 1.1.4 erase
- 1.1.5 exec
- 1.1.6 exit
- 1.1.7 exitonerror
- 1.1.8 f
- 1.1.9 fdelete
- 1.1.10 flist
- 1.1.11 fread
- 1.1.12 fshow
- 1.1.13 fsize
- 1.1.14 fwrite
- 1.1.15 go
- 1.1.16 halt
- 1.1.17 hwinfo
- 1.1.18 ip
- 1.1.19 is
- 1.1.20 jtagconf
- 1.1.21 loadfile
- 1.1.22 log
- 1.1.23 mem
- 1.1.24 mem8
- 1.1.25 mem16
- 1.1.26 mem32
- 1.1.27 mem64
- 1.1.28 mr
- 1.1.29 ms
- 1.1.30 power
- 1.1.31 r
- 1.1.32 readAP
- 1.1.33 readcsr
- 1.1.34 readDP
- 1.1.35 regs
- 1.1.36 rnh
- 1.1.37 rreg
- 1.1.38 rx
- 1.1.39 savebin
- 1.1.40 setBP
- 1.1.41 setPC
- 1.1.42 SetTimeoutCmd
- 1.1.43 setWP
- 1.1.44 si
- 1.1.45 sleep
- 1.1.46 st
- 1.1.47 step
- 1.1.48 stepover
- 1.1.49 unlock
- 1.1.50 usb
- 1.1.51 verifybin
- 1.1.52 VTREF
- 1.1.53 w1
- 1.1.54 w2
- 1.1.55 w4
- 1.1.56 WebUSBDisable
- 1.1.57 WebUSBEnable
- 1.1.58 writeAP
- 1.1.59 writecsr
- 1.1.60 writeDP
- 1.1.61 wreg
- 1.1 Detailed description
- 2 Command line options
- 3 Using J-Link Command Files
- 4 Perform flash download
- 5 Batch processing
- 6 JLink.exe return value
- 7 Using J-Link Command Strings
- 8 Connecting to a specific J-Link
- 9 Setup External CFI NOR Flash
- 10 Command specifics
Commands
The table below lists the available commands of J-Link Commander. All commands are listed in alphabetical order within their respective categories. Detailed descriptions of the commands can be found in the sections that follow.
Command (short form) | Explanation |
---|---|
Basic | |
clrBP | Clear breakpoint. |
clrWP | Clear watchpoint. |
device | Selects a device. |
erase | Erase internal flash of selected device. |
exec | Execute J-Link Command String. |
exit (qc, q) | Closes J-Link Commander. |
exitonerror (eoe) | Commander exits after error. |
f | Prints firmware info. |
go (g) | Starts the CPU core. |
halt (h) | Halts the CPU core. |
hwinfo | Show hardware info. |
is | Scan chain select register length. |
jtagconf | Configures a JTAG scan chain with multiple devices on it. |
loadfile | Load data file into target memory. |
log | Enables log to file. |
mem | Read memory. |
mem8 | Read 8-bit items. |
mem16 | Read 16-bit items. |
mem32 | Read 32-bit items. |
mem64 | Read 64-bit items. |
mr | Measures reaction time of RTCK pin. |
ms | Measures length of scan chain. |
power | Switch power supply for target. |
r | Resets and halts the target. |
readAP | Reads from a CoreSight AP register. |
readcsr | Reads CSR register on a RISC-V based target. |
readDP | Reads from a CoreSight DP register. |
regs | Shows all current register values. |
rnh | Resets without halting the target. |
rreg | Shows a specific register value. |
rx | Reset target with delay. |
savebin | Saves target memory into binary file. |
setBP | Set breakpoint. |
setPC | Set the PC to specified value. |
SetTimeoutCmd | Set timeout for the stepover command. |
setWP | Set watchpoint. |
setWP | Set watchpoint. |
si | Select a target interface. |
speed | Set target interface speed. |
st | Shows the current hardware status. |
step (s) | Single step the target chip. |
stepover (so) | Execute a stepover. |
unlock | Unlocks a device. |
verifybin | Compares memory with data file. |
w1 | Write 8-bit items. |
w2 | Write 16-bit items. |
w4 | Write 32-bit items. |
writeAP | Writes to a CoreSight AP register. |
writecsr | Writes CSR register on a RISC-V based target. |
writeDP | Writes to a CoreSight DP register. |
wreg | Write register. |
Flasher I/O | |
fdelete (fdel) | Delete file on emulator. |
flist | List directory on emulator. |
fread (frd) | Read file from emulator. |
fshow | Read and display file from emulator. |
fsize (fsz) | Display size of file on emulator. |
fwrite (fwr) | Write file to emulator. |
Connection | |
ip | Connect to J-Link Pro via TCP/IP. |
usb | Connect to J-Link via USB. |
Connection | |
VTREF | Sets a fixed value for VTref on J-Link. |
WebUSBDisable | Disables WebUSB on J-Link. |
WebUSBEnable | Enables WebUSB on J-Link. |
Detailed description
Following is a detailed description with syntax explaination and examples of the commands listed above.
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
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
device
Selects a specific device J-Link shall connect to and performs a reconnect. In most cases explicit selection of the device is not necessary. Selecting a device enables the user to make use of the J-Link flash programming functionality as well as using unlimited breakpoints in flash memory. For some devices explicit device selection is mandatory in order to allow the DLL to perform special handling needed by the device. Some commands require that a device is set prior to use them.
Syntax
device <DeviceName>
Parameter | Meaning |
---|---|
DeviceName | Valid device name: Device is selected. ?: Shows a device selection dialog. |
Example
device stm32f407ig
erase
Erases all flash sectors of the current device. A device has to be specified previously.
Syntax
erase
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
exit
This command closes the target connection, the connection to the J-Link and exits J-Link Commander.
Syntax
q
exitonerror
This command toggles whether J-Link Commander exits on error or not.
Syntax
ExitOnError <1|0>
Parameter | Meaning |
---|---|
1/0 | 1: J-Link Commander will now exit on Error. 0: J-Link Commander will no longer exit on Error. |
Example
eoe 1
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
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
flist
On emulators which support file I/O this command shows the directory tree of the Flasher.
Syntax
flist
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
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
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
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 destination 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
go
Starts the CPU. In order to avoid setting breakpoints it allows to define a maximum number of instructions which can be simulated/emulated. This is 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
go [<NumSteps> [<Flags>]]
Parameter | Meaning |
---|---|
NumSteps | Maximum number of instructions allowed to be simulated. Instruction simulation stops whenever a breakpointed instruction is hit, an instruction which cannot be simulated/emulated is hit or when NumSteps is reached. |
Flags | 0: Do not start the CPU if a BP is in range of NumSteps 1: Overstep BPs |
Example
go //Simply starts the CPU go 20, 1
halt
Halts the CPU Core. If successful, shows the current CPU registers.
Syntax
halt
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
ip
Closes any existing connection to J-Link and opens a new one via TCP/IP. If no IP Address is specified, the Emulator selection dialog shows up.
Syntax
ip [<Addr>]
Parameter | Meaning |
---|---|
Addr | Valid values: IP Address: Connects the J-Link with the specified IP-Address Host Name: Resolves the host name and connects to it. *: Invokes the Emulator selection dialog. |
Example
ip 192.168.6.3
is
This command returns information about the length of the scan chain select register.
Syntax
is
jtagconf
Configures a 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.
Note
To make sure the connection to the device can be established correctly, it is recommended to configure the JTAG scan chain via command line options at the start of GDB Server.
Syntax
jtagconf <IRPre> <DRPre>
Parameter | Meaning |
---|---|
IRPre | 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 | Number of devices closer to TDI. |
Example
jtagconf 4 1 // Select the second device, where there is 1 device in front with IRLen 4
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. If not passed, 0x0 is assumed. Only used for .bin files. Ignored for other formats. |
Example
loadfile C:\Work\test.bin 0x20000000
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
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
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
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>, <NumItems> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
NumItems | Number of halfwords to read. Maximum is 0x80000. |
Example
mem16 0, 100
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>, <NumItems> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
NumItems | Number of words to read. Maximum is 0x40000. |
Example
mem32 0, 100
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>, <NumItems> (hex)
Parameter | Meaning |
---|---|
Zone | Name of memory zone to access. |
Addr | Start address. |
NumItems | Number ofdouble words to read. Maximum is 0x20000. |
Example
mem64 0, 100
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
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
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
r
Resets and halts the target.
Syntax
r
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
readcsr
Reads a specific CSR (Control Status Register) on a RISC-V based target.
Syntax
readcsr <RegIndex>[,<RegSizeBytes>]
Parameter | Meaning |
---|---|
RegIndex | Index of CSR register to read |
RegSizeBytes | Optional. Specifies length of CSR register in bytes. If omitted RegSize is assumed to be XLEN (32-bit on RV32, 64-bit on RV64). |
Example
readcsr 0x300 or readcsr 0x300, 8
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
regs
Shows all current register values.
Syntax
regs
rnh
This command performs a reset but without halting the device.
Syntax
rnh
rreg
The function prints the value of the specified CPU register.
Syntax
rreg <RegIndex>
Parameter | Meaning |
---|---|
RegIndex | Register to read. |
Example
rreg 15
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 |
---|---|
DelayAfterReset | Delay in ms. |
Example
rx 10
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
setBP
This command sets a breakpoint of a specific type at a specified address. Which breakpoint modes are available depends on the CPU that is used.
Syntax
setBP <Addr> [[A/T]/[W/H]] [S/H]
Parameter | Meaning |
---|---|
Addr | Address to be breakpointed. |
A/T | Only for ARM7/9/11 and Cortex-R4 devices: A: ARM mode T: THUMB mode |
W/H | Only for MIPS devices: W: MIPS32 mode (Word) H: MIPS16 mode (Half-word) |
S/H | S: Force software BP H: Force hardware BP |
Example
setBP 0x8000036
setPC
Sets the PC to the specified value.
Syntax
setpc <Addr>
Parameter | Meaning |
---|---|
Addr | Address the PC should be set to. |
Example
setpc 0x59C
SetTimeoutCmd
Set timeout in milliseconds for a specific command.
Note
Right now only stepover is supported
Syntax
SetTimeoutCmd <Cmd> = <TimeoutMs>
Parameter | Meaning |
---|---|
Cmd | Command to set timeout for. |
TimeoutMs | Timeout in milliseconds. |
Example
SetTimeoutCmd stepover = 5000
setWP
This command inserts a new watchpoint that matches the specified parameters. The enable bit for the watchpoint as well as the data access bit of the watchpoint unit are set automatically by this command. Moreover the bits DBGEXT, CHAIN and the RANGE bit (used to connect one watchpoint with the other one) are automatically masked out. In order to use these bits you have to set the watchpoint by writing the ICE registers directly.
Syntax
setWP <Addr> [<AccessType>] [<Size>] [ [<DataMask> [<AddrMask>]]]
Parameter | Meaning |
---|---|
Addr | Address to be watchpointed. |
Accesstype | Specifies the control data on which data event has been set: R: read access W: write access |
Size | Valid values: S8 | S16 | S32 Specifies to monitor an n-bit access width at the selected address. |
Data | Specifies the Data on which watchpoint has been set. |
DataMask | Specifies data mask used for comparison. Bits set to 1 are masked out, so not taken into consideration during data comparison. Please note that for certain cores not all Bit-Mask combinations are supported by the core-debug logic. On some cores only complete bytes can be masked out (e.g. PIC32) or similar. |
AddrMask | Specifies the address mask used for comparison. Bits set to 1 are masked out, so not taken into consideration during address comparison. 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
si
This command selects a target interface.
Syntax
si <Interface>
Parameter | Meaning |
---|---|
Interface | Can be any supported target interface (e.g SWD, JTAG, ICSP, FINE, ...) |
Example
si JTAG
sleep
Waits the given time (in milliseconds).
Syntax
sleep <Delay>
Parameter | Meaning |
---|---|
Delay | Amount of time to sleep in ms. |
Example
sleep 200
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
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
stepover
Target needs to be halted before calling this command. Executes a stepover on the target, similar how a debugger does it. The instruction is overstepped even if it is breakpointed. Prints out the disassembly of the instruction to be stepped over. By default this command has a timeout of five seconds.
Note
For more information see SetTimeoutCmd
Syntax
stepover
unlock
This command unlocks a device which has been accidentally locked by malfunction of user software.
Syntax
unlock <DeviceName>
Parameter | Meaning |
---|---|
DeviceName | Name of the device family to unlock. Supported Devices: LM3Sxxx Kinetis EFM32Gxxx |
Example
unlock Kinetis
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
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
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
Note
The command overrides the VTref pin and once set the pin will be ignored. To activate the pin again call the VTREF command with a voltage of 0V.
w1
The command writes one single byte to the target system.
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 0x10, 0xFF
w2
The command writes a unit of 16-bits to the target system.
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, 0xFFFF
w4
The command writes a unit of 32-bits to the target system.
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, 0xAABBCCFF
WebUSBDisable
Disables WebUSB on J-Link. The WebUSB configuration applies nonvolatile after power cycling the probe.
Syntax
WebUSBDisable
WebUSBEnable
Enables WebUSB on J-Link. The WebUSB configuration applies nonvolatile after power cycling the probe.
Syntax
WebUSBEnable
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}
writecsr
Writes a specific CSR (Control Status Register) on a RISC-V based target.
Note
Writes to known CSRs (like X1) may not be written to HW directly but with the next g or s command.
Syntax
writecsr <RegIndex>, [,<RegSizeBytes>]
Parameter | Meaning |
---|---|
RegIndex | Index of CSR register to write |
Data | Data to write |
RegSizeBytes | Optional. Specifies length of CSR register in bytes. If omitted RegSize is assumed to be XLEN (32-bit on RV32, 64-bit on RV64). |
Example
writecsr 0x1001, 0x11223344 or writecsr 0x1001, 0x11223344, 8
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 |
Data32Hex | Data to write |
Example
// // Write DP SELECT register: Select AP 0 bank 15 // WriteDP 2, 0x000000F0
wreg
Writes into a register. The value is written into the register on CPU start.
Syntax
wreg <RegName>,
Parameter | Meaning |
---|---|
RegName | Register to write to. |
Data | Data to write to the specified register. |
Example
wreg R14, 0xFF
Command line options
J-Link Commander can be started with different command line options for test and automation purposes. In the following, the command line options which are available for J-Link Commander are explained. All command line options are case insensitive.
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 |
-NoGui | Starts J-Link Commander in no GUI mode |
-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 |
Detailed description
Following is a detailed description with syntax and examples of the command lines listed above.
-AutoConnect
This command can be used to let J-Link Commander automatically start the connect sequence for connecting to the target when entering interactive mode.
Syntax
-autoconnect <1|0>
Example
JLink.exe -autoconnect 1
-CommanderScript
Similar to -CommandFile.
-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.
-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 | List of supported target devices].
Syntax
-Device <DeviceName>
Example
JLink.exe -Device STM32F103ZE
-ExitOnError
Similar to the exitonerror command.
-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
-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>.
-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”
-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
-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
-NoGui
Starts the J-Link Commander in "no GUI"-mode. Please note that license dialogs are not suppressed in this mode.
Syntax
-NoGui 1
Example
JLink.exe -NoGui 1
NOTE: This command is not yet available. It will be available for Version 6.71d (beta) and V6.74 (release) or later, of the Software and Documentation Pack.
-RTTTelnetPort
This command alters the RTT telnet port. Default is 19021.
Syntax
-RTTTelnetPort <Port>
Example
JLink.exe -RTTTelnetPort 9100
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
-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”
-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
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.
Example
JLink.exe -device STM32F103ZE -CommandFile C:\\CommandFile.jlink
Contents of CommandFile.jlink:
si 1 speed 4000 r h loadbin C:\firmware.bin,0x08000000
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.
Batch processing
Basically, some target configuration settings needs to be specified in J-Link Commander before a target connection can be established. However, the J-Link Commander comes with multiple command line options as well as a so called J-Link Commander Command Script mode, which allows using J-Link Commander in batch processing mode, so that it can be used fully automatic.
The table below describes the different command line arguments, which can be used to run the commander, without the need to input any configuration / commands:
Command line option | Explanation |
---|---|
-device <DeviceName> | Selects the target device. |
-if <TargetInterface> | Configures the target interface. |
-speed <InterfaceSpeed> | Configures the target interface speed. |
-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). |
-autoconnect <Value> | Value==1: Forces the J-Link Commander to connect to the target, automatically. |
-CommanderScript <ScriptPath> | Selects a J-Link Commander Command file which contains the commands for the batch mode. |
-SelectEmuBySN <SerialNo> | Selects a specific J-Link (via its serial number) to connect to. Used in case multiple J-Links are connected to the same PC via USB. |
Example:
JLink.exe -device CC2538SF53 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1 -CommanderScript C:\Work\JLinkCommandFile.jlink
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
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 "loadbin" which may trigger a flash download implicitly where a flash loader is started that takes care of the initialization. Also note that executing a "loadbin" command in advance, does not guarantee that a "verifybin" succeeds because the loadbin commands restores the controller state after it is done. So if the QSPI controller and/or pins were not initialized before the "loadbin" command, they are not after it either. They are only available while "loadbin" is active.