ARM CPU挂死和总线挂死的DS-5调试方法

DS-5以及配套的DSTREAM/RealView是对ARM处理器进行裸机调试的利器,本文将针对工作中常见的CPU挂死情况,进行具体分析,将介绍如何区分CPU挂死以及通过CSAT区分总线挂死的具体操作步骤。

DSTREAM/RealView的连接方式如下:

 调试器和目标ARM处理器之间是通过 JTAG连接起来的,JTAG则和芯片内部的调试IP相连接,在ARM规范里面,这个调试IP叫做ARM CoreSight,通过ARM CoreSight,我们可以调试挂在CoreSight之上的所有IP,包括处理器,总线,PMU等等等等。

 一个更加具体的CoreSight 连接方式如下图所示,这是通过DS5配置工具从一个具体的SOC中导出来的拓扑图:

可以看到,JTAG口通过TDI/TDO将CoreSight DebugPort串联起来,通过CSDP,可以访问处理器等相关IP。

通过RealView JTAG调试CPU的情况:

如果CPU挂死了怎么办?

比如下图这种情况,通过DS-5已经无法正常和CPU进行通信:

可以看到,通过debugger已经无法正常连接到A7处理器了,DS5报:

"Unable to stop device Cortex-A7, Cannot attain state requested!"

这个时候就需要另外一个工具了,它叫做csat,全称是(core sight access tool),顾名思义就是访问coresight的一个工具,它没有IDE,是一个命令行工具。

根据上面的拓扑图,在CPU无法成功连接的时候,我们依然可以通过CoreSight去访问其它的IP,包括总线.

下面我们试一下,下面展示一段通过CSAT的调试会话,需要注意的是,在使用CSAT连接目标平台前,必须关闭DS5的调试连接,否则CSAT会连接失败

Environment configured for ARM DS-5 (build 5190027)
Please consult the documentation for available commands and more details

C:\Program Files\DS-5\bin>csat
###############################################
#  CSAT -   CoreSight Access Tool      v2.0.7 #
#                                             #
#      [with Trace Commands v 2.0.1.1]        #
#                                             #
#      Copyright 2007-2011 ARM Limited        #
###############################################


CoreSight Component Data file read successfully.

%>con usb

Attempting to connect to ...USB
Connected to:ARM RealView ICE
Base H/W: V1 Rev G-01
TurboTAP Rev: 1.93
Firmware: 4.31.0, Build 33
%>chain dev=auto clk=A
Jtag clock set to 50000000A
ID:0 ARMCS-DP
%>help
:       Execute system command
alias   Alias a command name : alias cmd alias_name
cfb     Configure the RVI box.
cfg     Configure a RVI template
cfgbox  Configure the RVI box.
cfgtplate       Configure a RVI template
chain   Set or autodetect scan chain and jtag clock frequency
chn     Set or autodetect scan chain and jtag clock frequency
con     connect to an RVI unit via TCP or USB.
connect connect to an RVI unit via TCP or USB.
cscomp  Defaults for coresight component instances
cti     Coresight Register Component
dapenum Enumerate the AP units on the DAP.
dcn     Disconnect from RVI unit
devclose        Close the connection to the target device.
devopen Open a connection to a target device on the scan chain.
dfl     Load a file (bin or elf)
dfs     Save memory data to binary file
disconnect      Disconnect from RVI unit
dmf     Fill memory using the DAP.
dmr     Read memory using the DAP.
dmw     Write memory using the DAP.
dpe     Enumerate the AP units on the DAP.
dpfload Load a file (bin or elf)
dpfsave Save memory data to binary file
dpmemfill       Fill memory using the DAP.
dpmemread       Read memory using the DAP.
dpmemwrite      Write memory using the DAP.
dpregread       Read a DAP register.
dpregwrite      Write a DAP register.
drr     Read a DAP register.
drw     Write a DAP register.
dvc     Close the connection to the target device.
dvo     Open a connection to a target device on the scan chain.
echo    echo back whatever you just typed
etb     Coresight ETB component
etm     Coresight Register Component
exit    Exit program.
itm     Coresight Register Component
log     Control logging.
opt     set default options
options set default options
pmua9   Coresight Register Component
ptm     Coresight Register Component
reset   Reset the system, tap or via control register.
rnt     run a test on the system
rst     Reset the system, tap or via control register.
runtest run a test on the system
rviscan Scan for RVI units.
rvs     Scan for RVI units.
stm     Coresight Register Component
system  Execute system command
tfun    Coresight Register Component
tpiu    Coresight Register Component
trace   Control Trace Unit
trc     Control Trace Unit
v7dbg   Coresight V7 Debug component
batch   Run batch file
abort   Abort current command
abortall        Abort all commands
%>dvo 0
Open connection to device ID : 0x5BA00477, version 0x00000006
Msg returned with RVMOpenConn: ARM-DP Template using Rv-Msg.
%>dmr 0 0 1
0x00000000 : 0xEA00000D
%>dmr 0 0x00000000 0x60
0x00000000 : 0xEA00000D 0xEAFFFFFE 0xEAFFFFFE 0xEAFFFFFE
0x00000010 : 0xEAFFFFFE 0xEAFFFFFE 0xEA000001 0xEAFFFFFE
0x00000020 : 0xEA000003 0xE24EE004 0xE92D5FFF 0xEB0027AB
0x00000030 : 0xE8FD9FFF 0xE3A0605C 0xEA00003B 0xE3A00001
0x00000040 : 0xE3A01000 0xE3A02000 0xE3A03000 0xE3A04000
0x00000050 : 0xE3A05000 0xE3A06000 0xE3A07000 0xE3A08000
0x00000060 : 0xE3A09000 0xE3A0A000 0xE3A0B000 0xE3A0C000
0x00000070 : 0xE59F0204 0xE5901000 0xE3A03902 0xE0012003
0x00000080 : 0xE3520000 0x0A000006 0xE59F21F0 0xE3C11902
0x00000090 : 0xE3C118FF 0xE3C114FF 0xE1811002 0xE5801000
0x000000A0 : 0xEA000005 0xE3082001 0xE3C11102 0xE3C110FF
0x000000B0 : 0xE3C11CFF 0xE1811002 0xE5801000 0xE59F11C0
0x000000C0 : 0xE30E2FE8 0xE5913000 0xE30F4FFF 0xE0033004
0x000000D0 : 0xE1520003 0x1A00000E 0xE59F11A8 0xE5912000
0x000000E0 : 0xE3A03001 0xE1822003 0xE5812000 0xE59F0198
0x000000F0 : 0xE5901000 0xE5911000 0xE59F3190 0xE0011003
0x00000100 : 0xE35104EA 0x1A000002 0xE590F000 0xE59F0180
0x00000110 : 0xE590F000 0xE59F117C 0xE59F217C 0xE5913000
0x00000120 : 0xE1520003 0x1A000000 0xEAFFFFF7 0xE10F2000
0x00000130 : 0xE3C2201F 0xE38220D2 0xE121F002 0xE59FD15C
0x00000140 : 0xE10F0000 0xE3C0001F 0xE3800013 0xE38000C0
0x00000150 : 0xE3C00C02 0xE121F000 0xEE110F10 0xE3C00005
0x00000160 : 0xE3C00B06 0xEE010F10 0xEE110F10 0xE3C00A02
0x00000170 : 0xEE010F10 0xE59F1128 0xE5912000 0xE3C22001
%>dfs 0 0x00000000 0x60 save.bin
Successfully Saved data to file : save.bin
%>exit
executing exit command....Disconnected from device.
Disconnected from vehicle.
Done
CSAT exiting

C:\Program Files\DS-5\bin>

上面的例子使用CSAT读取了一段内存数据,我们断开CSAT,重新用DS5连接,dump同样一段数据,看是否一致:

经过对比后,通过CSAT获取到的内存数据和通过DS5得到的相同地址的数据是完全一致的,这说明CSAT的连接是正确的。

csat下通过dfs命令,也可以像DS5一样将数据dump出来保存为文件,上面展示了dfs命令导出save.bin文件的操作,我们观察以下save.bin的内容:

 也和上面通过DS5以及直接CSAT dmr得到的数据完全一致。

至此,我们介绍完了CSAT的用法。

通过这个例子看出来,ARM的生态完善不是一蹴而就的,经过这么多年的发展,其它的CPU已经很难跟得上了,毕竟,针对这个例子来说,如果CPU挂死了,我们还有CSAT可以用,不是么?

附图,关于上面使用命令的解释:


结束!

Guess you like

Origin blog.csdn.net/tugouxp/article/details/119486580