gdb本地调试版本移植至ARM-Linux系统

发表时间:2023-12-12 11:16

QQ截图20231212142320.jpg

移植ncurses库

本文使用的ncurses版本为ncurses-5.9.tar.gz

下载地址:https://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz


1.       将ncurses压缩包拷贝至Linux主机或使用wget命令下载并解压


tar-zxvf ncurses-5.9.tar.gz


2.       解压后进入到ncurses-5.9目录下


cdncurses-5.9


3.       在ncurses-5.9目录下创建编译完成后生成文件位置

mkdiroutput

cdoutput

mkdirarm-linux

4.       生成Makefile文件

./configure--target=arm-none-linux-gnueabi --prefix=$PWD/output/arm-linux   --enable-termcap --with-shared --without-ada

l   --target表示编译器的前缀,需要根据编译的不同需求进行修改

l   --prefix表示编译完成后生成文件的位置

l   --nable-termcap表示 关键代码使用 termcap(terminalcapabilities)数据库 [自动检测]

l   --with-shared表示动态编译


5.       编译

make

当遇到如下报错时

Makefile:794:recipe for target '../obj_s/lib_gen.o' failed

make[1]:*** [../obj_s/lib_gen.o] Error 1

make[1]:Leaving directory '.../ncurses-5.9/ncurses'

Makefile:109:recipe for target 'all' failed

make:*** [all] Error 2


需要进入ncurses-5.9/include文件夹,修改 curses.tail 文件下的如下内容,将注释 /* generated */ 去掉

externNCURSES_EXPORT(bool)    mouse_trafo(int*, int*, bool);         /* generated*/


6.       安装

Makeinstall


7.       安装完成后会在/output/arm-linux目录下生成库文件,我们只需将lib目录下的libncurses.so.5 库拷贝至开发板



移植gdb

本文使用的gdb版本为gdb-7.12.tar.gz

下载地址:https://ftp.gnu.org/gnu/gdb/gdb-7.12.tar.gz


1.       将gdb压缩包拷贝至Linux主机或使用wget命令下载并解压


tar-zxvf gdb-7.12.tar.gz


2.       解压后进入到ncurses-5.9目录下


cdgdb-7.12


3.       生成Makefile文件

./configure -host=arm-none-linux-gnueabi CC=/home/vanxoak/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc   --enable-shared--prefix=$PWD/output/arm-linux --disable-werror --without-x --disable-gdbtk--disable-tui --without-included-regex --without-included-gettextLDFLAGS="-L$PWD/../output/arm-linux/lib"CPPFLASS="-I$PWD/../output/arm-linux/include"

l   --host=arm-none-linux-gnueabi 用arm-none-linux-gnueabi编译

l   CC为交叉编译器绝对路径

l   --enable-shared 动态编译

l   prefix=“$PWD/output/arm-linux” 安装目录

l   --disable-werror 屏蔽werror报警

l   --without-x 取消x windows 支持

l   --disable-gdbtk 取消gdbtk

l   --disable-tui 取消tui 界面

l   --without-included-gettext 去掉用于多语言处理的gettext库

l   "LDFLAGS=XXX"指交叉编译完成的ncurse的lib目录路径

l   "CPPFLAGS=XXX"指是交叉编译完成的ncurse的include目录路径


4.       编译

make

5.       安装

makeinstall


安装完成后会在.../gdb-7.12/output/arm-linux/bin/目录下生成gdb可执行程序。


移植至HDT3-EVM 开发板

1.       将libncurses.so.5库 文件拷贝至/usr/lib目录下,若/usr目录下无lib目录可手动创建mkdir lib

2.       将gdb程序拷贝至/bin目录下

T3.JPG


测试调试

1.   编写可执行测试程序,示例hello.c代码如下,该代码执行后会打印Hello World

#include<stdio.h>

intmain(int argc, char *argv[])

{

    printf("Hello World\n");

    return 0;

}

2.   使用交叉编译器进行编译,需要注意的是,要使用gdb调试程序,需要在使用交叉编译器编译源代码时加上 " -g " 参数保留调试信息,否则不能使用GDB进行调试且报如下最后一行所示错误:

/home# gdb hello

GNUgdb (GDB) 7.12

Copyright(C) 2016 Free Software Foundation, Inc.

LicenseGPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

Thisis free software: you are free to change and redistribute it.

Thereis NO WARRANTY, to the extent permitted by law. Type "show copying"

and"show warranty" for details.

ThisGDB was configured as "arm-none-linux-gnueabi".

Type"show configuration" for configuration details.

Forbug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>.

Findthe GDB manual and other documentation resources online at:

<http://www.gnu.org/software/gdb/documentation/>.

Forhelp, type "help".

Type"apropos word" to search for commands related to "word"...

Readingsymbols from hello...(no debugging symbols found)...done.


3.       使用交叉编译器编译测试程序

arm-none-linux-gnueabi-gcc-g   -o hello hello.c


4.       将生成的hello文件拷贝至HDT3-EVM 开发板上并使用sync命令保存


5.       输入gbd命令启动gdb程序

/home# gdb

GNUgdb (GDB) 7.12

Copyright(C) 2016 Free Software Foundation, Inc.

LicenseGPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

Thisis free software: you are free to change and redistribute it.

Thereis NO WARRANTY, to the extent permitted by law. Type "show copying"

and"show warranty" for details.

ThisGDB was configured as "arm-none-linux-gnueabi".

Type"show configuration" for configuration details.

Forbug reporting instructions, please see:

<http://www.gnu.org/software/gdb/bugs/>.

Findthe GDB manual and other documentation resources online at:

<http://www.gnu.org/software/gdb/documentation/>.

Forhelp, type "help".

Type"apropos word" to search for commands related to "word".

(gdb)


上述代码(gdb)为GBD内部命令引导符,表示等待用户输入gbd命令


6.       使用 " file hello " 命令载入被调试的测试程序

(gdb)file hello

Readingsymbols from hello...done.


显示Reading symbols from hello...done.表示被测程序加载成功


7.       使用 " r "命令执行调试测试程序

(gdb)r

Startingprogram: /home/hello

HelloWorld

[Inferior1 (process 849) exited normally]

如上述代码显示 " Hello World " 即表示hello程序执行完成



(gdb)help

Listof classes of commands:

aliases-- Aliases of other commands

breakpoints-- Making program stop at certain points

data-- Examining data

files-- Specifying and examining files

internals-- Maintenance commands

obscure-- Obscure features

running-- Running the program

stack-- Examining the stack

status-- Status inquiries

support-- Support facilities

tracepoints-- Tracing of program execution without stopping the program

user-defined-- User-defined commands

Type"help" followed by a class name for a list of commands in that class.

Type"help all" for the list of all commands.

Type"help" followed by command name for full documentation.

Type"apropos word" to search for commands related to "word".

Commandname abbreviations are allowed if unambiguous.


文章列表
RK3506 AMP简介及万象奥科AMP方案介绍RK3506是瑞芯微公司推出的一款高性能处理器,该芯片采用三核Cortex-A7与单核Cortex-M0的异构设计,A7核主频可达1.5GHz,M0核可达200MHz,支持在物理隔离的核心上部署不同操作系统:A7可运行Linux系统处理复杂应用,M0核则运行RT-Thread实时系统或MCU-HAL层驱动,实现计算资源与实时性的最优配置。这种混...
样品信息产品名称:HD-RK3506G-IOT评估板(基于RK3506核心板)产品厂商:武汉万象奥科电子有限公司1. 概述1.1     试验仪器试验项目型号规格设备名称厂商校准有效期EFTEFT61004TA-2216脉冲群发生器Prima2025-10-14ESDESD61002TA静电放电发生器Prima2025-10-14EATGT-TH-S-225Z恒温恒湿试验箱高天2025-10...
RK3506,运行Linux系统,上电开机到显示界面启动完成到底有多快?基于万象奥科HD-RK3506-IoT评估板,一起看一下实测数据!测试准备:HD-RK3506-IoT评估板一套RGB接口5寸显示屏一套电源(带开关)一套上电准备,设置好录像与计时。上电开机,启动观察。启动完成!不到2秒完成界面启动!武汉万象基于瑞芯微RK3506G处理器的核心板(35mm*35mm)震撼上市,首件特价2...
工业网关(Industrial Gateway)是工业物联网(IIoT)的核心枢纽,负责连接现场设备(如PLC、传感器、仪器仪表)与云端管理系统,实现数据采集、协议转换、边缘计算等功能。瑞芯微推出的RK3506处理器,凭借多核异构架构、工业级可靠性、丰富外设接口,成为新一代工业网关的理想计算平台。本文将解析RK3506如何解决工业网关的关键需求,并探讨其典型应用场景。  一、工业网关的核心挑...
在工业自动化领域,HMI+PLC一体机正成为越来越多设备制造商的选择。这种将人机界面(HMI)和可编程逻辑控制器(PLC)集成在一起的设备,不仅节省了空间,还简化了系统架构。而要实现这样的集成设计,处理器的选择尤为关键。一、HMI+PLC一体机的核心需求现代工业设备对HMI+PLC一体机提出了更高要求:1. 实时控制能力:PLC部分需要确保控制周期在1ms以内2. 流畅的人机交互:HMI界面...
在电力自动化领域,DTU(配电终端单元)和FTU(馈线终端单元)是配电网智能化升级的核心设备。它们负责实时监测电力运行状态、快速隔离故障、优化电能分配,是保障电网稳定运行的“神经末梢”。  然而,随着智能电网的发展,传统单片机方案已难以满足多任务并行处理、高精度数据采集、低延迟通信等需求。此时,瑞芯微RK3506凭借多核异构架构、工业级可靠性、丰富外设接口,成为新一代DTU/FTU的理想计算...
这款“单片机”有些特殊!硬件资源集成了:ü   1.5GHz超高主频ü   1Gb内存、2Gb Flashü   支持2路百兆网口ü   6路串口、2路CAN FDü   MIPI与LCDü   USB、SPI、IIC、PWM、SAI、IO…软件资源支持:ü   RT-Threadü   Linuxü   RT-Thread + Linux混合部署还有一大特点:ü   支持在Windows下...
1、RK3506 CAN总线测试概述使用USBCANFD-200U测试HD-RK3506-EG1200网关的CAN接口性能与稳定性。HD-RK3506-EG1200 的CAN接口同时支持CAN2.0和CANFD模式。所以分别进行测试。2、RK3506 CAN总线测试步骤HD-RK3506-EG1200网关的CAN接口支持CAN2.0和CANFD硬件传输协议,分开测试两种硬件接口协议的收发功能...
武汉万象奥科电子有限公司
服务热线:027-59218026
销售邮箱:sales@vanxoak.com
主营产品:ARM核心板、ARM工控板
工业网关、软硬件定制设计
地址:武汉东湖新技术开发区大学园路长城园路8号海容基孵化园B5

扫描二维码
关注公众号
产品及方案咨询
专业专注   合作共赢
移动电话:181 2058 0511 (湖北)
移动电话:175 7010 9551 (华南、华中)
移动电话:133 0386 9667 (华东、华北)