jlink怎么调试linux程序_【转】ubuntu linux下openocd + gdb-insight 用Jlink调试arm程序

本文介绍了如何在Ubuntu 8.04环境下,利用OpenOCD (版本svn 1214) 和 Insight (版本6.8) 调试工具,配合JLink,对基于LPC2294的板子进行ARM程序的调试。首先安装libusb驱动库,接着分别安装并配置OpenOCD和Insight,确保目标为arm-linux-gnueabi。创建openocd.cfg配置文件,并提供了一个GDB初始化脚本示例。最后,通过启动OpenOCD和Insight进行调试。遇到的问题包括输入框无法输入,可能是编译器或TCL库的bug。
摘要由CSDN通过智能技术生成

openocd版本为svn 1214,insight版本为6.8 开发环境为ubuntu-8.04 包都升级到最新。2008.12.8

板子为自己设计的LPC2294的板子,BANK0 为SST39VF1601,BANK1为issi61lv25616al。

首先安装usb驱动库:

下载libusb-0.1.12 (地址google上搜)

解压./configure

make

make install

openocd 安装#./bootstrap

#./configure --enable-jlink (我使用的jtag调试工具是jlink)

#make

#make install

卸载时使用make uninstall即可,当然别删了makefile文件

insight安装

下载 解压

yu@yu-desktop:~/e-work/insight-6.8$ cd ..

yu@yu-desktop:~/e-work$ mkdir insight-arm

yu@yu-desktop:~/e-work$ cd insight-arm

yu@yu-desktop:~/e-work/insight-arm$

../insight-6.8/configure --target=arm-linux-gnueabi --enable-sim --prefix=/usr/local/insight-arm-6.8 --with-termlib=ncurses

我使用的edlk-4.2编译的arm程序,工具前缀都是arm-linux-gnueabi, 所以–target=arm-linux-gnueabi,我们安装到/usr/local/insight-arm-6.8,

因为我们安装的是交叉工具链,有时候需要安装多个版本,所以每个分别安装的不同目录,使用时把相应的目录加入PATH,避免版本之间出错。在工作目录建立source文件,内容为:

///

#export CROSS_COMPILE=arm-elf-

export CROSS_COMPILE=arm-linux-

export PATH=/home/yu/e-work/eldk/usr/bin:/usr/local/insight-arm-6.8/bin:${PATH}

#export PATH=/home/yu/e-work/eldk/usr/bin:/usr/local/insight-arm-6.6/bin:${PATH}

#export GUI_LIBRARY=/usr/local/insight-arm-6.8/lib

echo "Altered environment for u-boot Development"

//

当然要先安装libncurses5及libncurses5-dev(头文件 库等),在新立德软件管理器内搜即可。

在工作目录(我的是/home/yu/e-work)建立openocd.cfg,内容如下:

#daemon configuration

telnet_port 4444

gdb_port 1000

tcl_port 6666

# GDB can also flash my flash!

#gdb_memory_map enable

gdb_memory_map disable #我的insight不支持

#gdb_flash_program enable

gdb_breakpoint_override soft

#gdb_detach reset

#interface

interface jlink

#jtag_speed 0 #Note that the JTAG speed is given in kHz with 0 meaning to autodetect.

#may be I should use jtag_speed 3000, because the speed is too slow!!!! usb drivers's fault???

#jtag_rclk 3000

jtag_speed 3000

#delays on reset lines

jtag_nsrst_delay 200

jtag_ntrst_delay 200

#use combined on interfaces or targets that can't set TRST/SRST separately

#reset_config trst_and_srst srst_pulls_trst

reset_config trst_and_srst

#hard reset the system to a reliable state

#jtag_reset srst

#sleep 500

# It has atmel lpc2294 chip.

source [find lpc2294.cfg]

# The board has a NOR flash on CS0

#flash configuration

#flash bank [driver_options ...]

#flash bank cfi 0x80000000 0x00200000 2 2 0 #jedec_probe #haven't surport FOR sst39vf1601

#Enable use of the DBGRQ bit to force entry into debug mode. This should be safe for all but ARM7TDMI–S cores

# (like Philips LPC).

#arm7_9 dbgrq enable

#if set this command in the upper line, openocd willn't recognize this command!

arm7_9 dbgrq disable

proc psm-c30-a_init { } {

# Force target into ARM state

soft_reset_halt

#force cpu go into Supervisor Mode, and disable IRQ and FIQ

#mww cpsr 0xd3 use this command will make cpu issue data abort

arm7_9 write_xpsr 0xd3 0

#Disable PLL

mww 0xe01fc080 0x0

#remap interrupt vector to onchip flash

mww 0xe01fc040 0x00000001

#init the bus

mww 0xe002c014 0x0f810914

#BCFG0

mww 0xffe00000 0x1000feff

#BFG1

mww 0xffe00004 0x1000feff

#probe on chip flash

flash probe 0

}

$_TARGETNAME configure -event gdb-attach psm-c30-a_init #gdb来连接的时候执行这个事件!

init

//

openocd的文档没有很仔细的看,但是感觉各版本的命令区别很大。

mww命令如果不再事件函数中就会不能识别此指令。arm7_9 dbgrq disable如果放在source [find lpc2294.cfg]前也会不能识别。

所以指令的次序也很重要!可能在搜索到tap之前有些指令还不能执行!

gdb_memory_map disable 是因为我的insight带的gdb编译时默认没有打开parse XML memory map选项,具体怎么打开,还没有看,configure –help应该有。arm7_9 dbgrq disable因为lpc必须关闭。使用arm7_9 write_xpsr 0xd3 0,而不使用mww写cpsr是因为使用后者会报错,提示引起data abort。

reset_config trst_and_srst 我的jtag复位和系统复位是分别控制的。

发现如果使用jtag_rclk 3000,即先使用rclk自己搜索jtag工作频率,速度会很慢。另外我的sst39vf1601不是cfi全兼容的,目前openocd还不支持,但是openocd的maillist上有人修改源码支持,还没有进一步的分析。lpc2294.cfg在openocd源代码的src/target/target目录下有。也要放在当前工作目录,从而使得openocd能找到,我的lpc2294.cfg的内容:

if { [info exists CHIPNAME] } {

set _CHIPNAME $CHIPNAME

} else {

set _CHIPNAME lpc2294

}

if { [info exists ENDIAN] } {

set _ENDIAN $ENDIAN

} else {

set _ENDIAN little

}

if { [info exists CPUTAPID ] } {

set _CPUTAPID $CPUTAPID

} else {

# force an error till we get a good number

# set _CPUTAPID 0xffffffff

set _CPUTAPID 0x4f1f0f0f #此处要修改成你的cpu的id

}

#jtag scan chain

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

set _TARGETNAME [format "%s.cpu" $_CHIPNAME]

target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi-s_r4

$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x40000000 -work-area-size 0x4000 -work-area-backup 0

#flash configuration

#flash bank lpc2000 0 0

#flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 14765 calc_checksum

#主频要修改成此时你的处理器的频率,特别是如果处理器内部已经烧写了程序时,要设置成你的那个程序设置的频率。

#而不是gdb attach时的频率。

#内部flash配置

flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 48000 calc_checksum

# For more information about the configuration files, take a look at:

# openocd.texi

我的gdb初始化脚本文件:

/

#GDB 6.8 and higher set any memory area not in the memory map as inaccessible, this can be changed to the old behaviour by #using the following gdb command.

set mem inaccessible-by-default off

#Previous versions of OpenOCD required the following gdb options to increase the packet size and speed up gdb communication.

#This is now handled in the qSupported PacketSize.

#但是现在如果去掉,还是出现(openocd那边):Warning:acknowledgment received, but no packet pending

#Warning:negative reply, retrying

#Error: GDB missing ack(2) - assumed good

#Warning:negative reply, retrying

#之类的错误,gdb的console窗口也会出现错误。

set remote memory-write-packet-size 1024

set remote memory-write-packet-size fixed

set remote memory-read-packet-size 1024

set remote memory-read-packet-size fixed

target remote localhost:1000

monitor sleep 500

monitor poll

monitor soft_reset_halt

#set fuction breakpoints

#break main

#No symbol table is loaded. Use the "file" command.

#how to load symbol table ???

#load /home/yu/e-work/u-boot-2008.10/u-boot

#continue to run the program

#continue

然后在openocd.cfg所在的目录执行openocd即可启动gdbserver。

然后在工作目录执行source source 建立path,然后执行arm-linux-gnueabi-insight -x insight.gdb /home/yu/e-work/u-boot-2008.10/u-boot

即可启动insight,再dowload即可调试了。可以在insight的cosole窗口通过monitor step等执行openocd的命令,monitor help看看都可以执行那些openocd的指令,help看看可以执行那些gdb的指令。

现在有一个问题是,我编译的insight的tcp端口输入框,watch窗口输入框,无法输入,怀疑是编译器或tcl库的bug。

安装预编译的gnuarm-3.4,其自带的insight-6.1情况依旧,故应该是库的缘故!

也可以使用ddd来调试!

ddd只是各种gdb的一个x-window前端ddd --debugger arm-linux-gdb -x insight.gdb /home/yu/e-work/u-boot-2008.10/u-boot

可启动arm的gdb,所以不用交叉编译。

使用新立德安装即可!!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值