嵌入式调试——gdb环境搭建
2014-09-24 15:53
309 查看
一、准备工作
1.下载gdb软件包
http://www.gnu.org/software/gdb/download/
(我下载的是gdb7.7版本)
2.安装必须的软件或工具(以下在ubuntu上)
sudo apt-get install texinfo
sudo apt-get install libncurses5-dev
sudo apt-get install m4
sudo apt-get install flex
sudo apt-get install bison
二、编译得到gdb
GDB使用了autoconf/automake,因此编译时只需配置configure脚本的--target,--host,--prefix等参数就可实现方便的移植。
--target:指定编译环境,一般设置为交叉编译器前缀,ix86-linux,arm-linux等
--prefix;指定安装路径。
--host:指定编译后文件运行平台,一般设置为交叉编译器前缀,ix86-linux,arm-linux等
--program-prefix:将生成可执行文件前加前缀
1)sudo mkdir /opt/gdb7.7
2)./configure --target=mips-linux-uclibc --prefix=/opt/gdb7.7
3)make
4)sudo make install
三、通过板子交叉编译GDBServer(因为这个server要运行在板子上)
1) ./configure --target=mips-linux-uclibc --host=mips-linux-uclibc
2) make CC=/opt/openwrt/bin/mips-linux-uclibc-gcc
(这里需要说明一下,为什么要用mips-linux-uclibc,因为这里我用的板子是mips架构的,提供的工具链就是mips-linux-uclibc-gcc
我看其他arm版的工具链也有许多不同,--taget和--host都必须指定一下,要不然出错。另一个mips-linux-uclibc-gcc这个地方我用的绝对路径,因为我安装了多个mips gcc,而且名称也一样,容易导致出错)
四、测试
测试文件编译
mips-linux-uclibc-gcc -g gdbtest.c -o gdbtest
将gdbtest和gdbserver两个文件拷贝到主机的/tftpboot目录下
host pc ip:192.168.0.67
board ip:192.168.0.50
通过tftp将gdbtest和gdbserver down下来
chmod +x gdbtest
chmod +x gdbserver
client board:
#./gdbserver 192.168.0.67:7788 gdbtest
host pc:
#./opt/gdb7.7/mips-linux-uclibc-gdb gdbtest(加粗部分,因为系统中存在其他同名gdb)
(gdb)target remote 192.168.0.50:7788
五如何利用串口调试
如果你用串口1 调试hello 的话,你就要现在板子上运行命令:
gdbserver hello /dev/ttyS0
(详情可以参考gdbserver 目录下的readme 文件),这时gdbserver 就在等待gdb 的应答信号了。)
然后在pc 机上运行命令:
xxx-linux-gdb hello
在xxx-linux-gdb 里敲入入下命令:
(gdb) set remotedevice /dev/ttyS0
(这里设置串口1)
(gdb) set remote baud 9600
(这里设置串口波特率)
(gdb) set debug remote
(可选)
(gdb) target remote /dev/ttyS0
操作到这儿,gdb 就应该和gdbserver 联系上了
1.下载gdb软件包
http://www.gnu.org/software/gdb/download/
(我下载的是gdb7.7版本)
2.安装必须的软件或工具(以下在ubuntu上)
sudo apt-get install texinfo
sudo apt-get install libncurses5-dev
sudo apt-get install m4
sudo apt-get install flex
sudo apt-get install bison
二、编译得到gdb
GDB使用了autoconf/automake,因此编译时只需配置configure脚本的--target,--host,--prefix等参数就可实现方便的移植。
--target:指定编译环境,一般设置为交叉编译器前缀,ix86-linux,arm-linux等
--prefix;指定安装路径。
--host:指定编译后文件运行平台,一般设置为交叉编译器前缀,ix86-linux,arm-linux等
--program-prefix:将生成可执行文件前加前缀
1)sudo mkdir /opt/gdb7.7
2)./configure --target=mips-linux-uclibc --prefix=/opt/gdb7.7
3)make
4)sudo make install
三、通过板子交叉编译GDBServer(因为这个server要运行在板子上)
1) ./configure --target=mips-linux-uclibc --host=mips-linux-uclibc
2) make CC=/opt/openwrt/bin/mips-linux-uclibc-gcc
(这里需要说明一下,为什么要用mips-linux-uclibc,因为这里我用的板子是mips架构的,提供的工具链就是mips-linux-uclibc-gcc
我看其他arm版的工具链也有许多不同,--taget和--host都必须指定一下,要不然出错。另一个mips-linux-uclibc-gcc这个地方我用的绝对路径,因为我安装了多个mips gcc,而且名称也一样,容易导致出错)
四、测试
测试文件编译
mips-linux-uclibc-gcc -g gdbtest.c -o gdbtest
将gdbtest和gdbserver两个文件拷贝到主机的/tftpboot目录下
host pc ip:192.168.0.67
board ip:192.168.0.50
通过tftp将gdbtest和gdbserver down下来
chmod +x gdbtest
chmod +x gdbserver
client board:
#./gdbserver 192.168.0.67:7788 gdbtest
host pc:
#./opt/gdb7.7/mips-linux-uclibc-gdb gdbtest(加粗部分,因为系统中存在其他同名gdb)
(gdb)target remote 192.168.0.50:7788
五如何利用串口调试
如果你用串口1 调试hello 的话,你就要现在板子上运行命令:
gdbserver hello /dev/ttyS0
(详情可以参考gdbserver 目录下的readme 文件),这时gdbserver 就在等待gdb 的应答信号了。)
然后在pc 机上运行命令:
xxx-linux-gdb hello
在xxx-linux-gdb 里敲入入下命令:
(gdb) set remotedevice /dev/ttyS0
(这里设置串口1)
(gdb) set remote baud 9600
(这里设置串口波特率)
(gdb) set debug remote
(可选)
(gdb) target remote /dev/ttyS0
操作到这儿,gdb 就应该和gdbserver 联系上了
相关文章推荐
- 嵌入式调试中gdb+gdbserver 调试环境搭建
- 建立嵌入式gdb调试环境
- 嵌入式arm linux环境中gdb+gdbserver调试
- 调试内核Ubuntu 搭建嵌入式开发环境-续
- 【嵌入式Linux学习七步曲之第二篇 ARM+Linux开发环境】gdb+gdbserver的方式进行ARM程序调试
- 2440 中 gdb gdbserver 调试环境搭建
- 建立嵌入式gdb调试环境
- 嵌入式arm linux环境中gdb+gdbserver调试
- 搭建MIPS平台GDB调试环境
- 采用eclipse + gdb来搭建调试qemu源码的环境
- 【嵌入式Linux学习七步曲之第二篇 ARM+Linux开发环境】gdb+gdbserver的方式进行ARM程序调试
- arm-linux-gdb+gdbserver环境搭建以及远程调试 及调试core文件
- 纯Linux下的 ARM裸机调试环境搭建(GDB + JLink)
- Insight 和 gdbserver 搭建ARM远程调试环境
- 在嵌入式开发环境里调试,用gdb和gdbserver调试应用程序。
- 建立嵌入式gdb调试环境
- 嵌入式开发交叉调试环境搭建
- 基于GDB的交叉调试环境搭建
- win7下搭建Qt开发环境(MinGW 4.4、Qt library 4.8.5、Qt Creator3.0和gdb调试)亲测成功啦
- arm-linux-gdb+gdbserver环境搭建以及远程调试