Eclipse调试arm裸机程序
一、集成开发环境
系统:win7 VMware ubuntu14.10
软件:eclipse, GDB Sever, Jlink
硬件: Jlink
准备工作: Jlink链接电脑, nand Flash启动开发板
pasting
二、安装GDB软件
下载 GDB ftp://sourceware.org/pub/gdb/releases/
在/home 目录下存放gdb-7.8压缩包
然后在/pot 下建立一个arm和gdb7.8作为安装目录#cd /opt #mkdir arm
#cd /arm #mkdir gdb7.8
解 压:#cd /home
#tar xvzf gdb-7.8.tar.gz
target指明编译生成的GDB用于调试ARM-LINUX程序,prefix指明安装目录
如果出现以下错误
执行#apt-get install libncurses5-dev
#make clean
#make
#make install
在文件末端加上export PATH=$PATH:/usr/local/arm-gdb/bin/
#gedit /etc/profile
注销后重新登录
三、安装Jlink软件
下载 Jlink: https://www.segger.com/jlink-software.html
pasting
四、安装Eclipse软件
打开ubuntu软件管理器,搜索eclipse并安装
启动eclipse 建立一个工作目录
一路next,进行安装。
然后重启eclipse
使用eclipse进行开发
建立一个Leds目录存放源代码,代码不能直接放在工作目录workspace下,需另建目录。
把代码复制进Leds
新建工程 File->New->Project
选择Leds目录
注意Makefile的编写,这是一个timer的例子。要把.bin替换成all
Build All
右键Leds
mini2440初始化代码
- # connect to the J-Link gdb server
- target remote localhost:2331
- # Set JTAG speed to 30 kHz
- monitor endian little
- monitor speed 30
- # Reset the target
- monitor reset
- monitor sleep 10
- #
- # CPU core initialization (to be done by user)
- #
- # Set the processor mode
- monitor reg cpsr = 0xd3
- #config MMU 配置MMU
- #flush v3/v4 cache
- monitor cp15 7, 7, 0, 0 = 0x0
- #/* flush v4 TLB 协处理器*/
- monitor cp15 8, 7, 0, 0 = 0x0
- #disable MMU stuff and caches
- monitor cp15 1, 0, 0, 0 =0x1002
- #Peri port setup
- monitor cp15 15, 2, 0, 4 = 0x70000013
- #disable watchdog kangear 关闭看门狗
- monitor MemU32 0x53000000 = 0x00000000
- monitor sleep 10
- #disable interrupt kangear 关闭中断
- monitor MemU32 0x4A000008 = 0xffffffff
- monitor MemU32 0x4A00001C = 0x7fff
- #set clock
- #initialize system clocks --- locktime register
- monitor MemU32 0x4C000000 = 0xFF000000
- #initialize system clocks --- clock-divn register
- monitor MemU32 0x4C000014 = 0x5 #CLKDVIN_400_148
- #initialize system clocks --- mpll register
- monitor MemU32 0x4C000004 = 0x7f021 #default clock
- #config sdram
- monitor MemU32 0x53000000 0x00000000
- monitor MemU32 0x4A000008 0xFFFFFFFF
- monitor MemU32 0x4A00001C 0x000007FF
- monitor MemU32 0x53000000 0x00000000
- monitor MemU32 0x56000050 0x000055AA
- monitor MemU32 0x4C000014 0x00000007
- monitor MemU32 0x4C000000 0x00FFFFFF
- monitor MemU32 0x4C000004 0x00061012
- monitor MemU32 0x4C000008 0x00040042
- monitor MemU32 0x48000000 0x22111120
- monitor MemU32 0x48000004 0x00002F50
- monitor MemU32 0x48000008 0x00000700
- monitor MemU32 0x4800000C 0x00000700
- monitor MemU32 0x48000010 0x00000700
- monitor MemU32 0x48000014 0x00000700
- monitor MemU32 0x48000018 0x0007FFFC
- monitor MemU32 0x4800001C 0x00018005
- monitor MemU32 0x48000020 0x00018005
- monitor MemU32 0x48000024 0x008E0459
- monitor MemU32 0x48000028 0x00000032
- monitor MemU32 0x4800002C 0x00000030
- monitor MemU32 0x48000030 0x00000030
- # Setup GDB for faster downloads
- #set remote memory-write-packet-size 1024
- monitor speed auto
- break _start
- load
此过程需要保持JLinkGDBServer在链接状态
按F5即可调试
退出Debug模式