本文摘录于:http://blog.sina.com.cn/s/blog_533f26760102vq3s.html
这里只做学习之用
几个常用命令:
usb--------连接目标板
r----------重启目标板
halt-------停止cpu运行的程序
loadbin----加载可执行的二进制文件
g----------跳到代码段地址执行
s----------单步执行(调试用)
setpc-----设置pc寄存器的值(调试用)
setbp-----设置断点
Regs-------读寄存器组织,该命令会把所有的寄存器显示出来
wreg-------写寄存器
mem--------读内存
w4---------写内存
power off mmu---关闭mmu,这个对于裸板调试很重要
w4 cpsr,0x0000001f------切换到系统模式
speed------设置jtag的传输速率
rce 0,c0,c0,0-----设置cp15寄存器的第1个寄存器为0
regs示例:
J-Link>regs
PC = 00002CC2, CycleCnt = 00000000
R0 = 0000004C, R1 = 00000008, R2 = 00000000, R3 = 00000004
R4 = 50001060, R5 = 00000000, R6 = 00000017, R7 = 00000007
R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
R12= 00002AF8
SP(R13)= 20003F5C, MSP= 20003F5C, PSP= FFFFFFFC, R14(LR) = 00002C7B
XPSR = 21000000: APSR = nzCvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000001, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 01
从这里看出和h命令类似
wreg示例:
J-Link>wreg
Illegal register name.
Syntax: wreg <RegName>, <Data>
R0
R1
R2
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13 (SP)
R14
R15 (PC)
XPSR
MSP
PSP
RAZ
CFBP
APSR
EPSR
IPSR
PRIMASK
BASEPRI
FAULTMASK
CONTROL
BASEPRI_MAX
IAPSR
EAPSR
IEPSR
FPSCR
FPS0
FPS1
FPS2
FPS3
FPS4
FPS5
FPS6
FPS7
FPS8
FPS9
FPS10
FPS11
FPS12
FPS13
FPS14
FPS15
FPS16
FPS17
FPS18
FPS19
FPS20
FPS21
FPS22
FPS23
FPS24
FPS25
FPS26
FPS27
FPS28
FPS29
FPS30
FPS31
CycleCnt
J-Link>wreg R0,a5
R0 = 0x000000A5
J-Link>h
PC = 00002CC2, CycleCnt = 00000000
R0 = 000000A5, R1 = 00000008, R2 = 00000000, R3 = 00000004
R4 = 50001060, R5 = 00000000, R6 = 00000017, R7 = 00000007
R8 = FFFFFFFF, R9 = FFFFFFFF, R10= FFFFFFFF, R11= FFFFFFFF
R12= 00002AF8
SP(R13)= 20003F5C, MSP= 20003F5C, PSP= FFFFFFFC, R14(LR) = 00002C7B
XPSR = 21000000: APSR = nzCvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000001, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 01
其他命令:
ite 32-bit items. Syntax: w4 ,(hex)(读内存32字节)
wm Write test words. Syntax: wm
is Identify length of scan chain selectregister
ms Measure length of scan chain. Syntax: ms
mr Measure RTCK react time. Syntax: mr
q Quit(推出)
qc Close JLink connection andquit(关闭jlink连接,并退出)
r Reset target (RESET)(重启目标)
rx Reset target (RESET).Syntax: rx (延时重启)
RSetType Set the current reset type. Syntax:RSetType
Regs Display contents of registers(显示寄存器信息)
wreg Writeregister. Syntax: wreg , (写继承器)
SetBP Setbreakpoint. Syntax: SetBP [A/T][S/H](设置断点)
SetWP SetWatchpoint. Syntax: [R/W] [ [] [A-Mask]](设置监视点)
ClrBP Clearbreakpoint. Syntax: ClrBP (清除断点)
ClrWP Clearwatchpoint. Syntax: ClrWP (清楚监视点)
VCatch Write vector catch.Syntax: VCatch
loadbin Load binary file intotarget memory.(下载bin文件到目标内存)
Syntax: loadbin ,
savebin Saves target memoryinto binary file.(保存BIN文件)
Syntax: savebin , ,
SetPC Setthe PC to specified value. Syntax: SetPC (设置PC(r15)寄存器)
le Change to little endian mode(设置成小端模式)
be Change to big endian mode(设置成大端模式)
log Enables log to file. Syntax:log
unlock Unlocks a device.Syntax: unlock
Type unlockwithout to get a list
ofsupported device names.
nRESET hasto be connected
---- CP15 ------------
rce Read CP15. Syntax: rce , , ,(读CP15)
wce Write CP15. Syntax: wce , , , , (写CP15)
---- ICE -------------
Ice Show state of the embedded ice macrocell (ICEbreaker)
ri Read Ice reg. Syntax: ri(hex)
wi Write Ice reg. Syntax: wi , (hex)
---- ETM -------------
etm Show ETM status
re Read ETM reg. Syntax: re
we Write ETM reg. Syntax: we , (hex)
es Start trace
---- ETB -------------
etb Show ETB status
rb Read ETB register. Syntax:rb
wb Write ETB register. Syntax: wb , (hex)
---- TRACE -----------
TAddBranch TRACE - Add branch instruction to trace buffer.Paras:,
TAddInst TRACE - Add (non-branch) instruction totrace buffer. Syntax:
TClear TRACE - Clearbuffer
TSetSize TRACE - Set Size of trace buffer
TSetFormat TRACE - SetFormat
TSR TRACE - Show Regions (and analyze tracebuffer)
TStart TRACE - Start
TStop TRACE- Stop
---- SWO -------------
SWOSpeed SWO - Show supported speeds
SWOStart SWO - Start
SWOStop SWO - Stop
SWOStat SWO - Display SWOstatus
SWORead SWO - Read and displaySWO data
SWOShow SWO - Read and analyzeSWO data
SWOFlush SWO - Flush data
---- File I/O --------
fwrite Write file toemulator
fread Readfile from emulator
fshow Readand display file from emulator
fdelete Delete file onemulator
fsize Display size of file on emulator
---- Test ------------
thg Run go/halt 1000 times
ts Run step 1000 times
testwspeed Test download speed. Syntax:testwspeed [ []]
testrspeed Test upload speed. Syntax: testrspeed [ [] [s>]]
testcspeed Test CPU speed. Syntax: testcspeed []
---- JTAG ------------
Config Set number of IR/DRbits before ARM device.
Syntax: Config ,
speed SetJTAG speed. Syntax: speed |auto|adaptive, e.g. speed 2000,
speed a
i Read JTAG Id (Host CPU)
wjc Write JTAG command (IR). Syntax: wjc (hex)
wjd Write JTAG data (DR). Syntax: wjd (hex),(dec)
RTAP