J-Link Commander

摘自:J-Link Commander - SEGGER Wiki

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.

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.

Note:

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
ExitExitClose J-Link connection and quit
ExitOnErrorEoEExit on error
SleepSleepWaits the given time (in milliseconds)
LogLogEnables log to file
ExpDevListExpDevListExport device names from DLL internal device list to text file
ExpDevListXMLExpDevListXMLExport device names from DLL internal device list to XML file
Configuration - J-Link
USBUSBConnect to J-Link via USB
IPIPConnect to J-Link via TCP/IP or to Remote Server
SelectProbeSelPrbShow list of all connected probes via specified interface. The Probe to communicate with can then be selected
ShowEmuListShowEmuListShow list of all connected probes via specified interface
PowerPowerSwitch power supply for target (5V-Supply pin) on or off
VTREFVTREFSet fixed value for VTref on J-Link
VCOMVCOMEnable/disable VCOM Takes effect after power cycle of the probe
RebootRebootReboot the connected probe.
UptimeUptimeShow Probe uptime since boot.
ShowFWInfoFShow firmware info
ShowHWStatusStShow hardware status
LicenseLicenseShow list of all available license commands
IPAddrIPAddrShow/Assign IP address and subnetmask of/to connected Probe
GWAddrGWAddrShow/Assign network gateway address of/to connected Probe
DNSAddrDNSAddrShow/Assign network DNS server address of/to connected Probe
ShowConfConfShow configuration of the connected Probe
CalibrateCalibCalibrate the target current measurement
Configuration - Target (CPU)
ConnectConConnect to target device
DeviceDeviceSelect specific device J-Link shall connect to
SelectInterfaceSISelect target interface
SpeedSpeedSet target interface speed
LELEChange mode to little endian
BEBEChange mode to big endian
Debugging
HaltHHalt CPU
IsHaltedIHReturn current CPU state
WaitHaltWHWait until CPU is halted or timeout is reached
GoGStart CPU if halted
ResetRReset CPU
ResetXRXReset CPU with delay after reset
RSetTypeRstSet the current reset type
StepSExecute step(s) on the CPU
ISISIdentify length of scan chain select register
MSMSMeasure length of scan chain
RegsRegsDisplay CPU register contents
RRegRRegRead register
WRegWRegWrite register
MoEMoEShows mode-of-entry (CPU halt reason)
SetBPSetBPSet breakpoint
ClearBPClrBPClear breakpoint
SetWPSetWPSet watchpoint
ClearWPClrWPClear watchpoint
VCatchVCWrite vector catch
SetPCSetPCSet the PC to specified value
ReadAPReadAPRead CoreSight AP register
WriteAPWriteAPWrite CoreSight AP register
ReadDPReadDPRead CoreSight DP register
WriteDPWriteDPWrite CoreSight DP register
RCP15ExRCERead CP15 register
WCP15ExWCEWrite CP15 register
TermTermVisualize printf output using DCC (SEGGER DCC handler running on target)
Debugging - Memory operation
MemMemRead memory and show corresponding ASCII values
Mem8Mem8Read 8-bit items
Mem16Mem16Read 16-bit items
Mem32Mem32Read 32-bit items
Write1W1Write 8-bit items
Write2W2Write 16-bit items
Write4W4Write 32-bit items
Write8W8Write 64-bit items
Debugging - JTAG related
JTAGConfJTAGConfSet number of IR/DR bits before Target device
JTAGIdIRead JTAG Id
WJTAGIRWJIRWrite JTAG command (IR)
WJTAGDRWJDRWrite JTAG data (DR)
WJTAGRawWJRWrite Raw JTAG data
ResetTAPRTAPReset TAP Controller using state machine (111110)
ResetTRSTRTReset TAP Controller using nTRST
Debugging - ICE
ICEICEShow state of the embedded ICE macrocell (ICE breaker)
ReadICERIRead Ice register
WriteICEWIWrite Ice register
TRACE
TClearTCClear TRACE buffer
TSetSizeTSSSet TRACE size of trace buffer
TSetFormatTSFSet TRACE Format
TShowRegionsTSRShow TRACE Regions (and analyze trace buffer)
TStartTStartStart TRACE
TStopTStopStop TRACE
SWO
SWOSpeedSWOSpeedShow supported SWO speeds
SWOStartSWOStartStart SWO
SWOStopSWOStopStop SWO
SWOStatSWOStatDisplay SWO status
SWOReadSWOReadRead and display SWO data
SWOShowSWOShowRead and analyze SWO data
SWOFlushSWOFlushFlush SWO data
SWOViewSWOViewView SWO terminal data
Flash programming
EraseEraseErase flash (range) of selected device
LoadFileLoadFileLoad data file into target memory
SaveBinSaveBinSave target memory range into binary file
VerifyBinVerifyBinVerfy if specified bin file is at the specified target memory location
Flasher File I/O Commands
FWriteFWr(Flasher only) Write file to probe
FReadFRd(Flasher only) Read file from probe
FShowFShow(Flasher only) Read and display file from probe
FDeleteFDel(Flasher only) Delete file on probe
FSizeFSz(Flasher only) Display size of file on probe
FListFList(Flasher only) List directory on probe
SecureAreaSecureArea(Flasher only) Creates/Removes secure area on probe
Measurement and test commands
PowerTracePowerTracePerform power trace (not supported by all models)
TestWSpeedTestWMeasure download speed into target memory
TestRSpeedTestRMeasure upload speed from target memory
TestCSpeedTestCMeasure CPU speed
TestNWSpeedTestNWMeasure network download speed
TestNRSpeedTestNRMeasure network upload speed
MRMRMeasure RTCK react time
J-Link Pin control
ClockCOutput clock(s) on the TCK pin
Clock00C00Output clock(s) on the TCK pin, with TDI == 0 and TMS == 0
ClrTCKTCK0Clear TCK pin
SetTCKTCK1Set TCK pin
ClrTDITDI0Clear TDI pin
SetTDITDI1Set TDI pin
ClrTMSTMS0Clear TMS pin
SetTMSTMS1Set TMS pin
ClrTRSTTRST0Clear TRST pin
SetTRSTTRST1Set TRST pin
ClrRESETR0Clear RESET pin
SetRESETR1Set RESET pin

?

Show information about all commands or one specific command.

Syntax

? [<Command>]

ParameterMeaning
<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>

ParameterMeaning
0Exit on error is off.
1Exit on error is on.

Sleep

Waits the given time. Usually used for J-Link Command Scripts.

Syntax

Sleep <Delay>

ParameterMeaning
DelayAmount of time to sleep in ms.
Example

Sleep 100

Log

Enables log to file.

Syntax

Log <filename>

ParameterMeaning
FilenameLog filename
Example

Log "C:\Users\User\Desktop\MyLogFile.log"

ExpDevList

Export device names from DLL internal device list to text file.

Syntax

ExpDevList <Filename>

ParameterMeaning
FilenamePath 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>

ParameterMeaning
FilenamePath 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>]

ParameterMeaning
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>]

ParameterMeaning
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> ...]

ParameterMeaning
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> ...]

ParameterMeaning
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]

ParameterMeaning
StateOn: Power supply on.
Off: Power supply off.
permSets 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]>

ParameterMeaning
Value[mV]Value, VTref is supposed to be set to in millivolt.
Example

VTREF 3300

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 CommandMeaning
addStore a custom license on J-Link. Syntax: LicAdd <LicName>
eraseErase all custom licenses on J-Link.
showShow 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>

ParameterMeaning
DeviceNameValid device name: Device is selected.
 ?: Shows device selection dialog.
Example

Device STM32F407VE

SelectInterface

Select target interface.

Short command

SI

Syntax

SelectInterface <Interface>

ParameterMeaning
InterfaceAny supported target interface (e.g SWD, JTAG, ICSP, FINE, ...)
Example

SelectInterface SWD

Speed

Set target interface speed.

Syntax

Speed <Setting>

ParameterMeaning
SettingDecimal 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>]

ParameterMeaning
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>

ParameterMeaning
DelayAfterResetDelay in ms.
Example

RX 1000

RSetType

Set the current reset type.

Short command

Rst

Syntax

RSetType [<Type>]

ParameterMeaning
TypeDesired 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>

ParameterMeaning
ScanChainScan 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>

ParameterMeaning
RegIndexRegister to read.
Example

RReg "R15 (PC)"

WReg

Write register.

Short command

WReg

Syntax

WReg <RegName> <Value>

ParameterMeaning
RegNameRegister to write to.
DataData 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]

ParameterMeaning
AddrAddress to be breakpointed.
A/TOnly for ARM7/9/11 and Cortex-R4 devices:
A: ARM mode
T: THUMB mode
W/HOnly for MIPS devices:
W: MIPS32 mode (Word)
H: MIPS16 mode (Half-word)
S/HS: 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)>]]]

ParameterMeaning
AddrAddress to be breakpointed.
AccessTypeTrigger on:
  • R: Read access
  • W: Write access
  • ANY: Any access
Size
  • S8: 8-bit size
  • S16: 16-bit size
  • S32: 32-bit size
  • ANY: Any size
DataMaskIgnore data bits set to 1.
AddrMaskIgnore 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>

ParameterMeaning
AddrAddress 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>

ParameterMeaning
RegIndexIndex 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>

ParameterMeaning
RegIndexIndex of AP register to write
Data32HexData 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>

ParameterMeaning
RegIndexIndex 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>

ParameterMeaning
RegIndexIndex of DP register to write
Data32HexData 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)

ParameterMeaning
ZoneName of memory zone to access.
AddrStart address.
NumItemsNumber 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)

ParameterMeaning
ZoneName of memory zone to access.
AddrStart address.
NumItemsNumber 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)

ParameterMeaning
ZoneName of memory zone to access.
AddrStart address.
NumItemsNumber 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)

ParameterMeaning
ZoneName of memory zone to access.
AddrStart address.
Data8-bits of data to write.
Example

W1 0x0 01

Write2

Write 16-bit items.

Short command

W2

Syntax

W2 [<Zone>:]<Addr> (hex)

ParameterMeaning
ZoneName of memory zone to access.
AddrStart address.
Data16-bits of data to write.
Example

W2 0x0 0011

Write4

Write 32-bit items.

Short command

W4

Syntax

W4 [<Zone>:]<Addr> (hex)

ParameterMeaning
ZoneName of memory zone to access.
AddrStart address.
Data32-bits of data to write.
Example

W4 0x0 00112233

Write8

Write 64-bit items.

Note:
Supported since V7.86b
Short command

W8

Syntax

W8 [<Zone>:]<Addr> (hex)

ParameterMeaning
ZoneName of memory zone to access.
AddrStart address.
Data64-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
ParameterMeaning
IRPreSum 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.
DRPreNumber 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)>]

ParameterMeaning
InsturctionInsturction to send as hexadecimal value.
IRLenInstruction register length of the current selected device.

WJTAGDR

Write JTAG data (DR).

Short command

WJDR

Syntax

WJTAGDR <Data64(hex)> <NumBits(dec)>

ParameterMeaning
Data64Data to send.
NumBitsNumber of bits to send.

WJTAGRaw

Write Raw JTAG data.

Short command

WJR

Syntax

WJTAGRaw <NumBits(dec)> <TMS(hex)> <TDI(hex)>

ParameterMeaning
NumBitsNumber of bits to send.
TMSTMS Data to send (hex) in reverse bit order.
TDITDI 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)

ParameterMeaning
RegIndexRegister index of register to read from.

WriteICE

Write Ice register.

Short command

WI

Syntax

WI <RegIndex> <Data(hex)>

ParameterMeaning
RegIndexRegister index of register to read from.
DataData to write (in hex).

TClear

Clear trace buffer.

Short command

TC

TSetSize

Set size of trace buffer.

Short command

TSS

Syntax

TSS <Size(hex)>

TSetFormat

Set trace format Format.

Short command

TSF

Syntax

TSF <Format>

ParameterMeaning
FormatTrace format. Valid parameter valuse: 4/8/16.

TShowRegions

Show trace regions (and analyze trace buffer).

Short command

TSR

TStart

Start trace.

TStop

Stop trace.

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>]

ParameterMeaning
FilenameSource filename.
AddrOnly used for .bin files. Ignored for other formats.
Destination address. If not passed, 0x0 is assumed.
ResetUsed 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>

ParameterMeaning
FilenameDestination file
AddrSource address.
NumBytesNumber 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>

ParameterMeaning
FilenameSample bin.
AddrStart 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>]]

ParameterMeaning
EmuFileFile name to write to.
HostFileSource file on the host
OffsetSpecifies the offset in the file, at which data writing is started.
NumBytesMaximum 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>]]

ParameterMeaning
EmuFileFile name to read from.
HostFileDestination file on the host.
OffsetSpecifies the offset in the file, at which data reading is started.
NumBytesMaximum 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>]]

ParameterMeaning
FileNameSource file name to read from the Flasher.
-aIf set, Input will be parsed as text instead of being shown as hex.
OffsetSpecifies the offset in the file, at which data reading is started.
NumBytesMaximum 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>

ParameterMeaning
FileNameFile 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>

ParameterMeaning
FileNameSource 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>]

ParameterMeaning
RepCountNumber 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 optionExplanation
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: exit code - How to execute echo %errorlevel% in java - Stack Overflow

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.

JLinkCommander JLinkCommandStrings.png

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值