Chinaunix首页 | 论坛 | 博客
  • 博客访问: 504348
  • 博文数量: 197
  • 博客积分: 2071
  • 博客等级: 上尉
  • 技术积分: 1307
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-02 09:49
个人简介

prothes 专注嵌入式的ARM linux

文章分类

全部博文(197)

文章存档

2014年(3)

2013年(16)

2012年(108)

2011年(70)

分类:

2011-09-06 13:05:03

Andrew Haung
 
在开发板已经联通后,下一步就是运行程序了,首先使用mini6410 官方提供的leds程序,由ADS编译
 
 
   按其提供方法将其拷入SD卡中可以看到LED的变化。证明代码工作正常.但每次编译后拷入SD卡,拨下再插入开发板启动,这样方法实现很麻烦。因此必须要找一个在线调试方法
 
  第一次调试
----------------------------------------------------------------
 
  J-Link提供一个J-Link的GDB Server,可以提供GDB 的远程接口,可以与交叉调试的GDB进行网络交互进行调试。
   而RVDS 安装后,会自带一个arm-none-eabi-gdb在RVCT的目录下。WINDOWS版本可以直接在DOS窗下运行它.
 
一般的嵌入式LINUX比较熟悉GDB交叉调试技术,它类似如下结构
 
而J-Link GDBServer在这里模拟上述环境里的gdbserver的地位。它是如下的架构
 
因此我们采用如下命令来调试。
 
首先进入开发板的u-boot模式 即在开发板启动时在串口终端长按回车键,按q进入u-boot控制台
 
连好线后,启动J-Link GDB Server.
可以看到它会在本地的TCP 2331端,侦听arm-linux-gdb的调试请求.
 
 
在dos命令窗口,启动arm-none-aeabi-gdb.
 
 
C:\Documents and Settings\hxy>arm-none-eabi-gdb
GNU gdb (CodeSourcery Sourcery G++ Lite 2007q1-3) 6.6.50.20070320-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-mingw32 --target=arm-none-eabi".
For bug reporting instructions, please see:
(gdb)
 
在gdb提示符下输入联接远程gdbserver的命令target remote
  target remote :
 这里输入 target remote 127.0.0.1:2331
当两者联接上后,两个界面均提示联接成功状态
 
 
执行装入程序命令 load xxxx.axf,其中装入位置是是axf链接时指定的 ro_base位置.
装入调试程序符号表 file xxxx.axf.
这里的文件名可以采用绝对路径或相对路径。如WINDOWS必须用/隔开。 e:/tmp/xxx.axf.如果文件存在,可以tab键来补齐完整文件名.
 
以下是运行过程
 

(gdb) target remote 127.0.0.1:2331
Remote debugging using 127.0.0.1:2331
0x00000000 in ?? ()
(gdb) load e:/tmp/mini6410-led.axf
Loading section ER_RO, size 0x8dc lma 0x50000000
Start address 0x5000039c, load size 2268
Transfer rate: 18144 bits in <1 sec, 2268 bytes/write.
(gdb) file e:/tmp/mini6410-led.axf
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
warning: unknown ARM EABI version 0x2000000
Reading symbols from e:/tmp/mini6410-led.axf...done.
 
接下就是运行下载程序,看相关文件,有如下几种方式来运行。一种直接用gdb continue 命令来执行。
它可以简写成c.
 
执行后,LEDS并无反应。
 
另外一种方法是用jump <符号名称>来执行
另外网上提示一种方法,用设置PC寄存器的方法强行执行.
          monitor reg r13 = (0x50000000) #表示设置堆栈顶部是0x50000000
         monitor reg pc = (0x5000039c) #强制把PC寄存器,即当前执行代码地址指向装入的PC地址
  
(gdb) jump 5000039c
Function "5000039c" not defined.
(gdb) monitor reg r13 = (0x50000000)
Failed to read memory from address 0x50000000
(gdb) monitor reg pc = (0x5000039c)
Failed to read memory from address 0x5000039C
 
可以看到两次执行都是内存读取失败。第一次调试,以三种方法失败而告终
 
 
第二次调试
--------------------------------------------------
 
在搜索到  ,即土屋网的超级版本loveshine提供的的命令脚本。你可以把这个脚本命名为 .gdbinit,这样GDB启动时将会自动调用。
 
无论是Windows还是LINUX,如果想自动调用,必须放在$HOME环境变量指向目录当中。
 Windows 用 set HOME来查看它指向路径
 Linux 用 echo $HOME 来查看
 
脚本内容采用
 
# 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
#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
monitor MemU32 0x7e004000  =  0x00000000
monitor sleep 10
#disable interrupt
monitor MemU32 0x71200014  =  0x00000000
monitor MemU32 0x71300014  =  0x00000000
monitor MemU32 0x7120000C  =  0x00000000
monitor MemU32 0x7130000C  =  0x00000000
monitor MemU32 0x71200F00  =  0x00000000
monitor MemU32 0x71300F00  =  0x00000000
#set clock
monitor MemU32 0x7e00f900  =  0x0000801e
monitor MemU32 0x7e00f000  =  0x0000ffff
monitor MemU32 0x7e00f004  =  0x0000ffff
monitor MemU32 0x7e00f020  =  0x01043310
monitor MemU32 0x7e00f00C  =  0xc2150601
monitor MemU32 0x7e00f010  =  0xc2150601
monitor MemU32 0x7e00f024  =  0x00000003
monitor MemU32 0x7e00f014  =  0x00200102
monitor MemU32 0x7e00f018  =  0x00000000
monitor MemU32 0x7e00f01C  =  0x14000007
#config sdram
monitor MemU32 0x7e00f120  =  0x00000008
monitor MemU32 0x7e001004  =  0x00000004
monitor MemU32 0x7e001010  =  0x0000040f
monitor MemU32 0x7e001014  =  0x00000006
monitor MemU32 0x7e001018  =  0x00000001
monitor MemU32 0x7e00101c  =  0x00000002
monitor MemU32 0x7e001020  =  0x00000006
monitor MemU32 0x7e001024  =  0x0000000a
monitor MemU32 0x7e001028  =  0x0000000c
monitor MemU32 0x7e00102c  =  0x0000018f
monitor MemU32 0x7e001030  =  0x0000000c
monitor MemU32 0x7e001034  =  0x00000002
monitor MemU32 0x7e001038  =  0x00000002
monitor MemU32 0x7e00103c  =  0x00000002
monitor MemU32 0x7e001040  =  0x00000002
monitor MemU32 0x7e001044  =  0x00000013
monitor MemU32 0x7e001048  =  0x00000013
monitor MemU32 0x7e00100C  =  0x00010012
monitor MemU32 0x7e00104C  =  0x00000b45
monitor MemU32 0x7e001200  =  0x000150f8
monitor MemU32 0x7e001304  =  0x00000000
monitor MemU32 0x7e001008  =  0x000c0000
monitor MemU32 0x7e001008  =  0x00000000
monitor MemU32 0x7e001008  =  0x00040000
monitor MemU32 0x7e001008  =  0x00040000
monitor MemU32 0x7e001008  =  0x000a0000
monitor MemU32 0x7e001008  =  0x00080032
monitor MemU32 0x7e001004  =  0x00000000
# Setup GDB for faster downloads
#set remote memory-write-packet-size 1024
set remote memory-write-packet-size 4096
set remote memory-write-packet-size fixed
monitor speed 12000
 
仍然跑飞未果.没有看到提示
 
 
第三次调试(成功)
-----------------------------------------------------------------------
将可以成功运行的load asm-led.axf 下载到gdb当中.重复第一次调试命令。运行成功!
而且我没有用初始化代码,可能已经被u-boot初始化,无需要初始化命令,在空板的运行还是需要第二次调试时的初始化代码
 
 这个程序证明,官方是的mini640-led,能在SD卡运行,但无法能在用J-Link调试主要是程序结构的原因.
 
第四次调试(成功)
-----------------------------------------------------------------------------
直接在ADS 1.2选择调试,进入AXD 进行J-Link调试,
  其中asm-led.axf 可以在源码级单步调试。通过LEDS灯判断,其中单步运行的结果正确无褒
 
(一个多星期不断试验,所做的实验都成功了,小小庆祝一下!)
 
 

 
 
阅读(963) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~