Ubuntu12.10 使用JLink链接开发板用arm-gdb调试ARM程序

Part1 环境搭建和工具安装

1.1 设置交叉编译环境

安装相关的编译工具:html

sudo apt-get install  build-essential gcc-arm-linux-gnueabi

这里我使用的是ubuntu系统源中含有的gcc-arm-linux-gnueabi系列工具,安装完成后具备以下工具:linux

复制代码
arm-linux-gnueabi-addr2line       arm-linux-gnueabi-gcc             arm-linux-gnueabi-gprof           arm-linux-gnueabi-ranlib
arm-linux-gnueabi-ar              arm-linux-gnueabi-gcc-4.7         arm-linux-gnueabi-ld              arm-linux-gnueabi-readelf
arm-linux-gnueabi-as              arm-linux-gnueabi-gcc-ar-4.7      arm-linux-gnueabi-ld.bfd          arm-linux-gnueabi-size
arm-linux-gnueabi-c++filt         arm-linux-gnueabi-gcc-nm-4.7      arm-linux-gnueabi-ld.gold         arm-linux-gnueabi-strings
arm-linux-gnueabi-cpp             arm-linux-gnueabi-gcc-ranlib-4.7  arm-linux-gnueabi-nm              arm-linux-gnueabi-strip
arm-linux-gnueabi-cpp-4.7         arm-linux-gnueabi-gcov            arm-linux-gnueabi-objcopy         
arm-linux-gnueabi-elfedit         arm-linux-gnueabi-gcov-4.7        arm-linux-gnueabi-objdump
复制代码

注意在使用make进行编译源码的时候,设置CROSS_COMPILE参数为: arm-linux-gnueabi-c++

make CROSS_COMPILE=arm-linux-gnueabi-

 

1.2 安装针对arm的gdb

1.2.1 到gdb官网下载源码

因为ubuntu下没有编译好的针对arm平台的gdb,故能够去官网下载: http://ftp.gnu.org/gnu/gdb/ , 能够先经过gdb -v 查看系统合适的版本;redis

$gdb -v
GNU gdb (GDB) 7.5-ubuntu
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/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 "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
$wget http://ftp.gnu.org/gnu/gdb/gdb-7.5.tar.bz2

1.2.2 编译和安装

编译和安装gdb,注意设置目标平台为arm-linux, 另外注意下面红色参数:“--program-prefix=arm-linux-”,该参数使安装后的程序名字为arm-linux-gdb, 防止与系统已经安装的gdb重名;ubuntu

$tar xjf gdb-7.5.tar.bz2
$cd gdb-7.5/
$./configure --target=arm-linux --program-prefix=arm-linux-
$sudo make install

后续能够直接经过命令行 arm-linux-gdb来调用该调试器;工具

 

1.3 下载和使用linux版JLink

可使用JLINK上的序列号进行下载,网址以下:ui

http://www.segger.com/cms/jlink-software.htmlspa

http://www.segger.com/cms/jlink-software.html?step=2&file=JLinkLinux_450i命令行

解压后,链接好开发板,运行Jlink目录中的start脚本或者JLinkExe程序,就能够看到链接成功的消息:调试

usb为jlink支持的命令,表示从usb链接,更多命令能够经过输入 ? 得到。

J-Link>usb
Connecting to J-Link via USB (Port: 0)
Updating firmware:  J-Link ARM V8 compiled Jun 19 2012 11:29:30
Replacing firmware: J-Link ARM V8 compiled Jan 31 2011 18:34:52
Waiting for new firmware to boot
New firmware booted successfully
DLL version V4.50i, compiled Jun 22 2012 19:00:36
Firmware: J-Link ARM V8 compiled Jun 19 2012 11:29:30
Hardware: V8.00
S/N: 17892859 
Feature(s): RDI,FlashDL,FlashBP,JFlash 
VTarget = 0.000V
J-Link>
相关文章
相关标签/搜索