Difference between revisions of "J-Link Commander"

From SEGGER Wiki
Jump to: navigation, search
(Verifybin command)
Line 2: Line 2:
   
 
__TOC__
 
__TOC__
  +
  +
= Commands =
  +
The table below lists the available commands of J-Link Commander. All commands are listed in alphabetical order within their respective categories.
  +
<!--LG xxxxxxxxxxx TBD: Detailed descriptions of the commands can be found in the sections that follow. -->
  +
  +
{| class="wikitable"
  +
|-
  +
! Command (short form) !! Explanation
  +
|-
  +
! colspan="2" | Basic
  +
|-
  +
| [[#clrBP | clrBP]] || Clear breakpoint.
  +
|-
  +
| [[#clrWP | clrWP]] || Clear watchpoint.
  +
|-
  +
| [[#device | device]] || Selects a device.
  +
|-
  +
| [[#erase | erase]] || Erase internal flash of selected device.
  +
|-
  +
| [[#exec | exec]] || Execute J-Link Command String.
  +
|-
  +
| [[#exit | exit]] (qc, q) || Closes J-Link Commander.
  +
|-
  +
| [[#exitonerror | exitonerror]] (eoe) || Commander exits after error.
  +
|-
  +
| [[#f | f]] || Prints firmware info.
  +
|-
  +
| [[#go | go]] (g) || Starts the CPU core.
  +
|-
  +
| [[#halt | halt]] (h) || Halts the CPU core.
  +
|-
  +
| [[#hwinfo | hwinfo]] || Show hardware info.
  +
|-
  +
| [[#is | is]] || Scan chain select register length.
  +
|-
  +
| [[#loadfile | loadfile]] || Load data file into target memory.
  +
|-
  +
| [[#log | log]] || Enables log to file.
  +
|-
  +
| [[#mem | mem]] || Read memory.
  +
|-
  +
| [[#mem8 | mem8]] || Read 8-bit items.
  +
|-
  +
| [[#mem16 | mem16]] || Read 16-bit items.
  +
|-
  +
| [[#mem32 | mem32]] || Read 32-bit items.
  +
|-
  +
| [[#mem64 | mem64]] || Read 64-bit items.
  +
|-
  +
| [[#mr | mr]] || Measures reaction time of RTCK pin.
  +
|-
  +
| [[#ms | ms]] || Measures length of scan chain.
  +
|-
  +
| [[#power | power]] || Switch power supply for target.
  +
|-
  +
| [[#r | r]] || Resets and halts the target.
  +
|-
  +
| [[#readAP | readAP]] || Reads from a CoreSight AP register.
  +
|-
  +
| [[#readcsr | readcsr]] || Reads CSR register on a RISC-V based target.
  +
|-
  +
| [[#readDP | readDP]] || Reads from a CoreSight DP register.
  +
|-
  +
| [[#regs | regs]] || Shows all current register values.
  +
|-
  +
| [[#rnh | rnh]] || Resets without halting the target.
  +
|-
  +
| [[#rreg | rreg]] || Shows a specific register value.
  +
|-
  +
| [[#rx | rx]] || Reset target with delay.
  +
|-
  +
| [[#savebin | savebin]] || Saves target memory into binary file.
  +
|-
  +
| [[#setBP | setBP]] || Set breakpoint.
  +
|-
  +
| [[#setPC | setPC]] || Set the PC to specified value.
  +
|-
  +
| [[#SetTimeoutCmd | SetTimeoutCmd]] || Set timeout for the stepover command.
  +
|-
  +
| [[#setWP | setWP]] || Set watchpoint.
  +
|-
  +
| [[#sleep | sleep]] || Waits the given time (in milliseconds).
  +
|-
  +
| [[#speed | speed]] || Set target interface speed.
  +
|-
  +
| [[#st | st]] || Shows the current hardware status.
  +
|-
  +
| [[#step | step]] (s) || Single step the target chip.
  +
|-
  +
| [[#stepover | stepover]] (so) || Execute a stepover.
  +
|-
  +
| [[#unlock | unlock]] || Unlocks a device.
  +
|-
  +
| [[#verifybin | verifybin]] || Compares memory with data file.
  +
|-
  +
| [[#w1 | w1]] || Write 8-bit items.
  +
|-
  +
| [[#w2 | w2]] || Write 16-bit items.
  +
|-
  +
| [[#w4 | w4]] || Write 32-bit items.
  +
|-
  +
| [[#writeAP | writeAP]] || Writes to a CoreSight AP register.
  +
|-
  +
| [[#writecsr | writecsr]] || Writes CSR register on a RISC-V based target.
  +
|-
  +
| [[#writeDP | writeDP]] || Writes to a CoreSight DP register.
  +
|-
  +
| [[#wreg | wreg]] || Write register.
  +
|-
  +
! colspan="2" | Flasher I/O
  +
|-
  +
| [[#fdelete | fdelete]] (fdel) || Delete file on emulator.
  +
|-
  +
| [[#flist | flist]] || List directory on emulator.
  +
|-
  +
| [[#fread | fread]] (frd) || Read file from emulator.
  +
|-
  +
| [[#fshow | fshow]] || Read and display file from emulator.
  +
|-
  +
| [[#fsize | fsize]] (fsz) || Display size of file on emulator.
  +
|-
  +
| [[#fwrite | fwrite]] (fwr) || Write file to emulator.
  +
|-
  +
! colspan="2" | Connection
  +
|-
  +
| [[#ip | ip]] || Connect to J-Link Pro via TCP/IP.
  +
|-
  +
| [[#usb | usb]] || Connect to J-Link via USB.
  +
|-
  +
! colspan="2" | Connection
  +
|-
  +
| [[#VTREF | VTREF]] || Sets a fixed value for VTref on J-Link.
  +
|-
  +
| [[#WebUSBDisable | WebUSBDisable]] || Disables WebUSB on J-Link.
  +
|-
  +
| [[#WebUSBEnable | WebUSBEnable]] || Enables WebUSB on J-Link.
  +
|-
  +
|}
  +
   
 
= Perform flash download =
 
= Perform flash download =

Revision as of 12:01, 13 December 2019

J-Link Commander (JLink.exe) 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 package, which is available for download on the SEGGER webpage.

Commands

The table below lists the available commands of J-Link Commander. All commands are listed in alphabetical order within their respective categories.

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.
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.
sleep Waits the given time (in milliseconds).
speed Set target interface speed.
st Shows the current hardware status.
step (s) Single step the target chip.
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.


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.

JLinkCommander FlashDownload.png

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.

JLinkCommander JLinkCommandStrings.png

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.