电竞比分网-中国电竞赛事及体育赛事平台

分享

Openocd 安裝并在Eclipse環(huán)境下通過J-Link調(diào)試

 幸福的樂土 2012-01-10

一,安裝前準備

1,軟件安裝平臺:CentOS 5.5

2,開發(fā)板硬件環(huán)境:Mini2440

3,下載最新版http:///projects/openocd/,當(dāng)前版本oenocd-0.4.0

安裝時參考文章http://www./nl1031/blog/09-11/180036_21ebd.html

博主hy343說,很重要的一步是安裝libusb工具。不安裝,編譯openocd 時會提示找不到usb.h文件,該文件即為libusb工具的頭文件。該工具可在sourceforge上找到。但是我在安裝之前沒有安裝這個libusb庫,也沒發(fā)現(xiàn)有報錯問題,這可能與具體的系統(tǒng)軟件環(huán)境有關(guān)。

 

二,安裝過程(安裝時還要注意參考OpenOCD Manual)

1,解壓當(dāng)前目錄下

[root@localhost ~]# unzip  /smbroot/openocd-0.4.0.zip

3,進入openocd目錄

[[root@localhost ~]# cd openocd-0.4.0

[root@localhost openocd-0.4.0]#

[root@localhost openocd-0.4.0]# ls

aclocal.m4  config.guess  configure.in  doc          ltmain.sh    NEWS    TODO

AUTHORS     config.h.in   contrib       Doxyfile.in  Makefile.am  README  tools

ChangeLog   config.sub    COPYING       INSTALL      Makefile.in  src

compile     configure     depcomp       install-sh   missing      tcl

[root@localhost openocd-0.4.0]#

4,執(zhí)行 configure 配置命令

在執(zhí)行配置命令之前,先了解下相關(guān)配置選項的作用。

有關(guān)configure 配置參數(shù)可參考http://lindyml.blog.163.com/blog/static/59311828200932102619827/

--prefix=PREFIX 用來指定安裝位置,默認是安裝在/usr/local/下

--enable-FEATURE用來啟用被禁用的特性,F(xiàn)EATURE是特性的名字

root@localhost openocd-0.4.0]# ./configure --enable-jlink

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

...... ......

config.status: executing depfiles commands

config.status: executing libtool commands

[root@localhost openocd-0.4.0]#

5,然后執(zhí)行make 編譯和make install安裝

[root@localhost openocd-0.4.0]#  make

...... ......

[root@localhost openocd-0.4.0]# make install

...... ......

make  install-data-hook

make[3]: Entering directory `/root/openocd-0.4.0'

for i in $(find ./tcl -name '*.cfg' -o -name '*.tcl' | sed -e 's,^./tcl,,'); do \
                j="/usr/local/share/openocd/scripts/$i" && \
                mkdir -p "$(dirname $j)" && \
                /usr/bin/install -c -m 644 ./tcl/$i $j; \
        done

make[3]: Leaving directory `/root/openocd-0.4.0'

make[2]: Leaving directory `/root/openocd-0.4.0'

make[1]: Leaving directory `/root/openocd-0.4.0'

[root@localhost openocd-0.4.0]#

6,查看安裝結(jié)果,

[root@localhost openocd-0.4.0]# openocd -v

Open On-Chip Debugger 0.4.0 (2011-03-28-11:40)

Licensed under GNU GPL v2

For bug reports, read
        http://openocd./doc/doxygen/bugs.html

[root@localhost openocd-0.4.0]#

清除安裝時產(chǎn)生的中間文件

[root@localhost openocd-0.4.0]# make distclean

Making distclean in doc

..... ......

rm -f Makefile

[root@localhost openocd-0.4.0]#

 

三,調(diào)試測試

1,在啟動OpenOCD連接JLink之前需要進行配置,可以用OpenOCD的幫助命令看有那些命令可以用來和OpenOCD進行交互操作,當(dāng)然需要看下OpenOCD Manual來了解這些命令怎么使用。

[root@localhost ~]# openocd --h
Open On-Chip Debugger 0.4.0 (2011-03-28-11:40)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd./doc/doxygen/bugs.html
Open On-Chip Debugger
Licensed under GNU GPL v2
--help       | -h       display this help
--version    | -v       display OpenOCD version
--file       | -f       use configuration file <name>
--search     | -s       dir to search for config files and scripts
--debug      | -d       set debug level <0-3>
--log_output | -l       redirect log output to file <name>
--command    | -c       run <command>
--pipe       | -p       use pipes for gdb communication
[root@localhost ~]#

2,進入到Leds工程目錄下,用vi命令新建一個配置openocd.cfg

[root@localhost Leds]# vi openocd.cfg

然后將以下內(nèi)容粘貼其中

#The configuration script can be divided in the following 5 sections:
#-------------------------------------------------------------------------
#No.1 the interface configuration
#-------------------------------------------------------------------------
 interface jlink

#-------------------------------------------------------------------------
#No.2 daemon configuration
#------------------------------------------------------------------------
     #The default telnet port setup
 #----------------------------------------------------------------
 telnet_port 4444

 #----------------------------------------------------------------
 #The default tcl port setup 
 #----------------------------------------------------------------
 #tcl_port 6666

   #----------------------------------------------------------------
 #GDB setup
 #----------------------------------------------------------------
 gdb_port 2331
 
 #----------------------------------------------------------------
 #gdb breakpoint override <hard|soft|disabled>
 #Note that GDB will use hardware breakpoints
 #if the memory map has been set up for flash regions.
 #----------------------------------------------------------------
 #gdb_breakpoint_override hard

 #----------------------------------------------------------------
 #gdb memory map <enable|disable>
 #enable when to set hardware breakpoints, and program flash
 #using the gdb load command,enable is default.
 #----------------------------------------------------------------
 #gdb_memory_map enable
 #gdb_flash_program enable

#-------------------------------------------------------------------------
#No.3 target configuration
#-------------------------------------------------------------------------
if { [info exists CHIPNAME] } {
   set _CHIPNAME $CHIPNAME
} else {
   set _CHIPNAME s3c2440
}
if { [info exists ENDIAN] } {
   set _ENDIAN $ENDIAN
} else {
  # this defaults to a bigendian
   set _ENDIAN little
}
if { [info exists CPUTAPID ] } {
   set _CPUTAPID $CPUTAPID
} else {
  # force an error till we get a good number
   set _CPUTAPID 0x0032409d
}
#-------------------------------------------------------------------------
#No.4 jtag scan chain
#-------------------------------------------------------------------------
 #In order for OpenOCD to control a target, a JTAG tap must be defined
 #/created.
 #jtag newtap CHIPNAME TAPNAME configparams ....
 #Required configparams
 # -irlen NUMBER - the length in bits of the instruction register
 # -ircapture NUMBER - the ID code capture command.
 # -irmask NUMBER - the corresponding mask for the ir register.
 #Optional configparams
 #-expected-id NUMBER By default it is zero. If non-zero represents the
 #expected tap ID used when the Jtag Chain is examined. See below.
 # -disable
 # -enable By default not specified the tap is enabled.
 #newtap is a sub command of the "jtag" command.

 jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0x0f -expected-id $_CPUTAPID

 target create mini2440 arm920t -endian $_ENDIAN -chain-position $_CHIPNAME.cpu -variant arm920t

 mini2440 configure -work-area-virt 0 -work-area-phys 0x200000 -work-area-size 0x4000 -work-area-backup 1


 
 #------------------------------------------------
 # ARM SPECIFIC
 #------------------------------------------------

 targets
 #arm7_9 dcc_downloads enable
 #arm7_9 fast_memory_access enable
 #arm7_9 dbgrq enable

 #----------------------------------------------------------------
 # JTAG ADAPTER SPECIFIC
 #----------------------------------------------------------------
 #To set the JTAG frequency(khz)
 jtag interface
  jtag_khz 12000

#-------------------------------------------------------------------------
#No.5 flash configuration
#-------------------------------------------------------------------------
 #fash bank cfi <base> <size> <chip width> <bus width> <target#>
 #[jedec_probe|x16 as x8]
 #chip width and bus width are specified in bytes.
 # 1MBx16 NOR Flash
 #flash bank cfi 0x40000000 0x200000 2 2 mini2440 #jedec_probe
 
 # NAND flash
 #nand device s3c2440 mini2440

 #----------------------------------------------------------------
 #reset configuration
 #----------------------------------------------------------------
 #How long (in milliseconds) OpenOCD should wait after deasserting nSRST
 #before starting new JTAG operations.
 #----------------------------------------------------------------
 jtag_nsrst_delay 100

 #----------------------------------------------------------------
 #it are useful if reset circuitry (like a big resistor/capacitor,reset
 #supervisor, or on-chip features). This keeps the signal asserted for
 #some time after the external reset got deasserted.
 #----------------------------------------------------------------
 jtag_ntrst_delay 100

 #-----------------------------------------------------------------
 #reset_config <signals> [combination] [trst type] [srst type]
 #[combination] is an optional value specifying broken reset signal.
 #The default behaviour if no option given is `separate'.
 #The [trst type] and [srst type] parameters allow the driver type of
 #the reset lines to be specified. Possible values are `trst_push_pull'
 # (default) and `trst_open_drain' for the test reset signal, and
 #`srst_open_drain' (default) and `srst_push_pull' for the system reset.
 #-----------------------------------------------------------------
 reset_config trst_and_srst

 

保存并退出,有關(guān)openocd腳本編寫可以參考
/usr/local/share/openocd/scripts/board 和usr/local/share/openocd/scripts/target相關(guān)內(nèi)容

3,確保j-link正確連到了CentOS

Openocd 安裝并在Eclipse環(huán)境下通過J-Link調(diào)試 - singleboy - singleboy的博客

 啟動openocd服務(wù)

在啟動時最好測試一下,有時會出現(xiàn)如下情形

[root@localhost Leds]# JLinkExe
SEGGER J-Link Commander V4.22 ('?' for help)
Compiled Dec 17 2010 17:41:09
Can not connect to J-Link via USB.
J-Link>

如果上面鏈接不上的情形,就先斷開和CentOS的連接,并在windows下啟動J-Link Commander,如下圖所示

Openocd 安裝并在Eclipse環(huán)境下通過J-Link調(diào)試 - singleboy - singleboy的博客

可以看到連接成功,這時再重新斷開windows連到CentOS,然后執(zhí)行usb連接命令

J-Link>usb
Connecting to J-Link via USB (Port: 0)
DLL version V4.22, compiled Dec 17 2010 17:41:06
Firmware: J-Link ARM V8 compiled Dec  1 2015 11:42:48
Hardware: V8.00
S/N: 20080643
Feature(s): RDI,FlashDL,FlashBP,JFlash,GDBFull
VTarget = 3.254V
Info: TotalIRLen = 4, IRPrint = 0x01
Info: CP15.0.0: 0x41129200: ARM, Architecure 4T
Info: CP15.0.1: 0x0D172172: ICache: 16kB (64*8*32), DCache: 16kB (64*8*32)
Info: Cache type: Separate, Write-back, Format A
Found 1 JTAG device, Total IRLen = 4:
 #0 Id: 0x0032409D, IRLen: 04, Unknown device
Found ARM with core Id 0x0032409D (ARM9)
JTAG speed: 100 kHz
J-Link>

4,啟動openocd服務(wù)

[root@localhost Leds]# openocd
Open On-Chip Debugger 0.4.0 (2011-03-28-11:40)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd./doc/doxygen/bugs.html
force hard breakpoints
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain
12000 kHz
jtag_nsrst_delay: 100
jtag_ntrst_delay: 100
trst_and_srst separate srst_gates_jtag trst_push_pull srst_open_drain
Info : J-Link initialization started / target CPU reset initiated
Info : J-Link ARM V8 compiled Dec  1 2015 11:42:48
Info : JLink caps 0xb9ff7bbf
Info : JLink hw version 80000
Info : JLink max mem block 9576
Info : Vref = 3.254 TCK = 1 TDI = 0 TDO = 1 TMS = 0 SRST = 1 TRST = 0

Info : J-Link JTAG Interface ready
Info : clock speed 12000 kHz
Info : JTAG tap: s3c2440.cpu tap/device found: 0x0032409d (mfg: 0x04e, part: 0x0324, ver: 0x0)
Info : Embedded ICE version 2
Info : s3c2440.cpu: hardware has 2 breakpoint/watchpoint units

5,在另一個終端中啟動調(diào)試程序

在終端的命令行調(diào)試程序有兩種調(diào)試方式:

A,直接調(diào)用openocd調(diào)試命令進行調(diào)試

【1】openocd常用命令

<1>連接命令

telnet ip port :ip表示遠程或本地主機(如localhost),port表示端口號,即配置腳本中telnet_port指定端口號。

<2>目標板狀態(tài)處理命令(Target state handling)

poll :查詢目標板當(dāng)前狀態(tài)。
halt :中斷目標板的運行。
resume [address] :恢復(fù)目標板的運行,如果指定了address,則從address 處開始運行。
step [address] :單步執(zhí)行,如果指定了address,則從address 處開始執(zhí)行一條指令。
reset :復(fù)位目標板。

<3>斷點命令

bp <addr> <length> [hw] :在地址addr 處設(shè)置斷點,指令長度為length,hw 表示硬件斷點。
rbp <addr> :刪除地址addr 處的斷點。

<4>內(nèi)存訪問指令(Memory access commands)

mdw ['phys'] <addr> [count] :顯示從(物理)地址addr 開始的count(缺省是1)個字(4 字節(jié))。
mdh ['phys'] <addr> [count] :顯示從(物理)地址addr 開始的count(缺省是1)個半字(2 字節(jié))。
mdb ['phys'] <addr> [count] :顯示從(物理)地址addr 開始的count(缺省是1)個字節(jié)。
mww ['phys'] <addr> <value> :向(物理)地址addr 寫入一個字,值為value。
mwh ['phys'] <addr> <value> :向(物理)地址addr 寫入一個半字,值為value。
mwb ['phys'] <addr> <value> :向(物理)地址addr 寫入一個字節(jié),值為value。

load_image <file> <address> [‘bin’|‘ihex’|‘elf’] :
將文件<file>載入地址為address 的內(nèi)存,格式有‘bin’、‘ihex’、‘elf’。
dump_image <file> <address> <size> :
將內(nèi)存從地址address 開始的size 字節(jié)數(shù)據(jù)讀出,保存到文件<file>中。
verify_image <file> <address> [‘bin’|‘ihex’|‘elf’]:
將文件<file>與內(nèi)存address 開始的數(shù)據(jù)進行比較,格式有‘bin’、‘ihex’、‘elf’。

<5>CPU 架構(gòu)相關(guān)命令(Architecture Specific Commands)

reg: 打印寄存器的值。
arm7_9 fast_memory_access ['enable'|'disable'] :使能或禁止“快速的內(nèi)存訪問”。
arm mcr cpnum op1 CRn op2 CRm value :修改協(xié)處理器的寄存器,比如:arm mcr 15 0 1 0 0 0 關(guān)閉MMU。
arm mrc cpnum op1 CRn op2 CRm:讀出協(xié)處理器的寄存器,比如:arm mcr 15 0 1 0 0讀出cp15協(xié)處理器的寄存器1。
arm920t cp15 regnum [value] :修改或讀取cp15 協(xié)處理器的寄存器,比如arm920t cp15 2 0 關(guān)閉MMU。
virt2phys virtual_address: 獲得虛擬地址對應(yīng)的物理地址。

<6>其他命令
script <file> :執(zhí)行file 文件中的命令。

【2】啟動openocd調(diào)試器

[root@localhost ~]# telnet localhost 4444
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Open On-Chip Debugger
>


【3】命令測試

> poll
background polling: on
TAP: s3c2440.cpu (enabled)
target state: running
> halt
target state: halted
target halted in ARM state due to debug-request, current mode: System
cpsr: 0x6000005f pc: 0x33f08f7c
MMU: enabled, D-Cache: enabled, I-Cache: enabled
> arm920t cp15 2 0
2: 00000000
> step
target state: halted
target halted in ARM state due to single-step, current mode: System
cpsr: 0x6000005f pc: 0x33f08f80
MMU: disabled, D-Cache: disabled, I-Cache: disabled
【4】加載測試文件

> load_image leds_elf
360 bytes written at address 0x30000000
downloaded 360 bytes in 0.092932s (3.783 kb/s)
>

【5】恢復(fù)運行
> resume
這時可以看到mini2440上led在閃爍

【6】暫停后退出調(diào)試

> halt
target state: halted
target halted in ARM state due to debug-request, current mode: System
cpsr: 0x6000005f pc: 0x33f08f58
MMU: disabled, D-Cache: disabled, I-Cache: disabled
> exit
Connection closed by foreign host.
[root@localhost ~]#

B,在新打開的終端中用GDB中用dgb端口進行連接

【1】GDB常用命令

<1>啟動/退出

gdb [FILE] 或xxx-xxxx-xxxx-xxxx-gdb [FILE]:x表示前綴字符,啟動gdb,調(diào)試FILE(也可以先不指定文件)。

quit 退出gdb。

<2>連接操作

target remote ip:port :遠程連接,ip表示主機IP地址或主機名(如localhost),port表示端口號,即配置腳本中g(shù)db_port指定端口號。

<3>文件操作

file <FILE> :載入文件FILE,注意:不會下載到目標板上。
load [FILE] :把文件下載到目標板上,如果不指定FILE,則下載之前指定過的(比如file 命令指定的,或是gdb 運行時指定的文件)。

<4>查看源程序

list <FUNCTION>: 列出某個函數(shù)FUNCTION。
list <LINENUM> :以當(dāng)前源文件的某行LINENUM為中間顯示一段源程序。
list 接著前一次繼續(xù)顯示。
break *<address> :在某個地址上設(shè)置斷點,比如 break *0x84。
list - :顯示前一次之前的源程序。
list <FILENAME:FUNCTION>或list <FILENAME:LINENUM>:顯示指定文件的一段程序。
info source: 查看當(dāng)前源程序。
info stack :查看堆棧信息。
info args: 查看當(dāng)前的參數(shù)。

<5>斷點操作

break <FUNCTION> :在函數(shù)入口設(shè)置斷點。
break <LINENUM> :在當(dāng)前源文件的某一行上設(shè)置斷點。
break <FILENAME:LINENUM> :在指定源文件的某一行上設(shè)置斷點。
info br :查看斷點。
delete <number>: 刪除斷點。
diable <number>: 禁止斷點。
enable <number> :使能斷點。

<6>監(jiān)視點(watch)操作

watch <EXPRESSION> :當(dāng)指定變量被寫時,程序被停止。
rwatch <EXPRESSION> :當(dāng)指定變量被讀時,程序被停止。

<7>數(shù)據(jù)操作

print < EXPRESSION > :查看數(shù)據(jù)。
set varible=value :設(shè)置變量。
x /NFU ADDR: 檢查內(nèi)存值。
① N 代表重復(fù)數(shù)
② F 代表輸出格式
x :16 進制整數(shù)格式
d :有符號十進制整數(shù)格式
u :無符號十進制整數(shù)格式
f :浮點數(shù)格式
③ U 代表輸出格式:
b :字節(jié)(byte)
h :雙字節(jié)數(shù)值
w :四字節(jié)數(shù)值
g :八字節(jié)數(shù)值
比如“x /4ub 0x0”將會顯示0 地址開始到4 個字節(jié)。

<8>執(zhí)行程序

step :單步執(zhí)行,會跟蹤進入一個函數(shù)。

next :單步執(zhí)行,指令則不會進入函數(shù)。
nexti :單步執(zhí)行,執(zhí)行一條匯編指令。
continue 繼續(xù)執(zhí)行程序,加載程序后也可以用來啟動程序

<9>幫助

help [command] :列出幫助信息,或是列出某個命令的幫助信息。

<10>其他命令

monitor <command …> :調(diào)用gdb 服務(wù)器軟件的命令,比如:“monitor mdw 0x0”就是調(diào)用openocd 本身的命令

“mdw 0x0”。

 

【2】 啟動調(diào)試程序

[root@localhost ~]# arm-none-eabi-gdb
GNU gdb (Sourcery G++ Lite 2010.09-51) 7.2.50.20100908-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http:///licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-eabi".
For bug reporting instructions, please see:
<https://support./GNUToolchain/>.
(gdb)

【3】建立gdb和openocd之間的連接
(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0x33f08f58 in ?? ()
(gdb)

【4】停止開發(fā)板上其它可能運行的程序
(gdb) monitor halt
target state: halted
target halted in ARM state due to debug-request, current mode: System
cpsr: 0x6000005f pc: 0x33f08f7c
MMU: enabled, D-Cache: enabled, I-Cache: enabled
(gdb)
【5】禁止MMU

(gdb) monitor arm920t cp15 2 0
2: 00000000
(gdb) monitor step
target state: halted
target halted in ARM state due to single-step, current mode: System
cpsr: 0x6000005f pc: 0x33f08f80
MMU: disabled, D-Cache: disabled, I-Cache: disabled
(gdb)
【6】下載elf鏡像文件
(gdb) load leds_elf
Loading section .text, size 0x168 lma 0x30000000
Start address 0x30000000, load size 360
Transfer rate: 4 KB/sec, 360 bytes/write.
(gdb)

【7】進入開始執(zhí)行調(diào)試

<1>設(shè)置斷點(break point)

(gdb) b main
Breakpoint 1 at 0x300000c8: file leds.c, line 19.
(gdb)

<2>單步運行(next)

(gdb) n
20              rGPBUP  = 0x7ff;
<3>退出調(diào)試(quit命令)

(gdb) q
A debugging session is active.

        Inferior 1 [Remote target] will be killed.

Quit anyway? (y or n) y
[root@localhost Leds]#

至此在命令行執(zhí)行調(diào)試成功。
 

 四,在Eclipse IDE中編譯并連接上openocd 調(diào)試(注意不要關(guān)閉openocd 運行的終端) 

 在Eclipse IDE中編譯并連接上J-Link GDB Server 調(diào)試(注意不要關(guān)閉JLinkGDBServer運行的終端) 

有兩種方法可以實現(xiàn):

第一種方法:通過ZylinCDT嵌入式調(diào)試插件

1,安裝嵌入式調(diào)試插件ZylinCDT。ZylinCDT是一個非常優(yōu)秀的交叉調(diào)試插件,操作簡單,具體操作步驟:

首先確認你的操作系統(tǒng)可以上網(wǎng)(實際的、虛擬機里的都一樣);

然后在Eclipse的菜單里選擇Help->Software Updates;選擇Available Software選項卡,點Add Site按鈕;

輸入地址http://www./zylincdt,列表里就多了一項;刷新之后點上面的Install按鈕安裝。

2,在Eclipse環(huán)境下導(dǎo)入現(xiàn)有的工程Leds.rar

執(zhí) 行Eclipse->File->New->Makefile Project with Existing Code,在Existing Code Location 欄點擊Browse按鈕,定位到現(xiàn)有的工程Leds,然后在Toolchain for Indexer Settings欄的列表框中選中ARM Linux GCC(Sourcery G++ Lite),如下圖所示,點擊Finish關(guān)閉對話框。

J-Link for Linux安裝并在Eclipse環(huán)境下鏈接J-Link GDB Severer調(diào)試 - singleboy - singleboy的博客


 

3,修改Makefile以使用現(xiàn)有的arm-none-eabi-gcc編譯器 

將文件中的arm-elf-替換為arm-none-eabi-,并用賦給變量CROSS=arm-none-eabi-,如下圖所示。然后按Ctrl+B編譯。


 

J-Link for Linux安裝并在Eclipse環(huán)境下鏈接J-Link GDB Severer調(diào)試 - singleboy - singleboy的博客


 
4, 點擊Run->Debug Configurations,如圖,在左側(cè)列表項中的Zylin Embedded debug(Native)上雙擊,在右側(cè)的Name欄保留默認的debug configuration名稱,在Main選項頁的Project(optional)欄右側(cè)點擊Browse按鈕定位到Leds工程所在的工程目錄。

J-Link for Linux安裝并在Eclipse環(huán)境下鏈接J-Link GDB Severer調(diào)試 - singleboy - singleboy的博客

5,在Debugger選項頁的Debugger Options欄的Main選項頁上,在GDB debugger欄輸入arm-none-eabi-gdb,然后將GDB command file欄的內(nèi)容清空。如下圖所示 

J-Link for Linux安裝并在Eclipse環(huán)境下鏈接J-Link GDB Severer調(diào)試 - singleboy - singleboy的博客

6, 在Commands選項頁的'Initialize' commands欄內(nèi),如下圖所示,將下列內(nèi)容粘貼進去:

Openocd 安裝并在Eclipse環(huán)境下通過J-Link調(diào)試 - singleboy - singleboy的博客

 

target remote localhost:2331

monitor halt

monitor arm920t cp15 2 0

monitor step

load

b main

點擊Apply按鈕,然后點擊Close關(guān)閉對話框。

7,配置外部工具,目的是能在Eclipse中啟動openocd服務(wù)

執(zhí) 行Run->External Tools->External Tools Configurations...,打開如下圖所示對話框,在左側(cè)列表Program上雙擊,然后在右側(cè)Name欄輸入OpenOCD,在 Location 欄按圖示定位到openocd命令所在位置,在Working Directory 欄定位到當(dāng)前工作目錄,在Arguments欄輸入openocd命令啟動參數(shù),這里不帶參數(shù),該命令則會按默認在當(dāng)前工作目錄下查找 openocd.cfg文件。

Openocd 安裝并在Eclipse環(huán)境下通過J-Link調(diào)試 - singleboy - singleboy的博客

設(shè)置完成后,切換到build選項頁,去掉勾選的Build before launch選項。
Openocd 安裝并在Eclipse環(huán)境下通過J-Link調(diào)試 - singleboy - singleboy的博客
設(shè)置完成后,點擊Apply按鈕,然后點擊Run按鈕啟動openocd服務(wù)。

8,開始調(diào)試

按下F11或執(zhí)行Run->Debug命令,啟動Debug程序,可以看到主界面底部的Console控制臺顯示初始化文件正在執(zhí)行的過程。最后停在main函數(shù)中設(shè)定的斷點處。

Openocd 安裝并在Eclipse環(huán)境下通過J-Link調(diào)試 - singleboy - singleboy的博客

按下F8可以跳到設(shè)置的main斷點處。

Openocd 安裝并在Eclipse環(huán)境下通過J-Link調(diào)試 - singleboy - singleboy的博客

 

按下F5或者F6可以單步執(zhí)行。按下Ctrl+F2或者Run->Terminate終止調(diào)試。

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多