主题 : Eclipse+Jlink+Fedora实现mini6410单步调试u-boot 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 36528
精华: 2
发帖: 43
金钱: 315 两
威望: 63 点
贡献值: 2 点
综合积分: 126 分
注册时间: 2011-01-17
最后登录: 2012-03-26
楼主  发表于: 2011-12-27 13:16

 Eclipse+Jlink+Fedora实现mini6410单步调试u-boot

管理提醒: 本帖被 xoom 执行加亮操作(2012-01-03)
真杯具啊,上传附件已达到指定个数5个,图片没法插入了·····

Eclipse+Jlink+Fedora实现mini6410单步调试u-boot.zip (566 K) 下载次数:705
注意

linux下编译已经为elf32格式的文件
 (Jlink不能识别,看板子version是否小于1048,请看使用J-LinkADS下调试Mini6410裸机程序的详细步骤(开发文档和教程下)) 
 
因有人问到2440等是否可用,就试了下
如果用SD卡或者Nand U-boot启动来完成初始化,Eclipse可采用如下初始命令,即去掉了初始化CPU等部分,只提供下载等命令:
# connect to the J-Link gdb server
target remote localhost:2331

#target remote 127.0.0.1:2331
# Set JTAG speed to 30 kHz
monitor speed 30

monitor endian little

# 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 10240
set remote memory-write-packet-size fixed
monitor speed 12000
#break start_armboot

break relocate_code
load
break lowlevel_init


load完成后就可以进行jlink单步调试,但要注意修改u-boot的基地址,如原板子上得u-boot在0x57e00000(u-boot-2011.09默认在此),就要修改Makefile中的 echo "RAM_TEXT= 0X57E00000" >> ......config.tmp 为合适的值,如0x58E00000等。

一、需安装的软件:

1jre-6u21-windows-i586.exe

2eclipse

推荐Eclipse Helios Packages (2010 - v 3.6) à Eclipse IDE for C/C++ Developers
Feature List:




org.eclipse.cdt
7.0.0
org.eclipse.cdt.platform
7.0.0
org.eclipse.platform
3.6.0
org.eclipse.rcp
3.6.0

已经包含了CDT 7.0,不需要再装CDT-master了!!!
或者:
Eclipse-SDK-3.6.2-win32        http://www.eclipse.org/downloads/
Cdt-master-7.0 .2.zip         http://www.eclipse.org/cdt/downloads.php  (不需要解压,安装较久)
 


4 Zylin插件           http://opensource.zylin.com/zylincdt            (在线安装)

5 JLinkARM_V410i        http://www.segger.com/cms/jlink-software.html
注意: 对于Jlink的软件包,在V4.10下测试。高版本不一定支持的好。

6Windows下的交叉编译工具(两个工具都试过能在windows下正常编译u-boot)

Sourcery CodeBench Lite Edition for ARM  选择EABI—all versions---Sourcery G++ Lite 2011.03-42
http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite
或者
yagarto-bu-2.20.1_gcc-4.5.1-c-gdb-7.1_eabi    http://www.yagarto.de/#download

 

二、在线查找并安装
1 安装C/C++插件(如果是Eclipse IDE for C/C++ Developers版本省略此步)
      
启动eclipse,点 help->Install new software->Add .然后在弹出的窗口中    Name不用填写,在Location中填写:http://update.eclipse.org/tools/cdt/releases/new,然后点OK,软件会自动查找CDT插件,一路点下去即可
;
2
安装zylincdt
调试插件
       同样重复以上步骤,在Location中填写:http://opensource.zylin.com/zylincdt
下载压缩包来安装:
       1、启动eclipse,点 help->Install new software->Add . 然后在弹出的窗口中Location一栏选择压缩包
       2、勾选要安装的插件,点ok
 

三、连接Jlink

正确连接上mini6410开发板和Jlink,打开gdb server如图所示,可以正确读出ARM11.状态是waiting for connection.
1) 一定不要选adpative否则在调试时会出现连不上,可选择auto或者5k~12000k之一都可以。
2) 需选为little endian


本文就该调试环境来调试uboot来简单介绍一下。在 windows下编译uboot可以参考Build and Debug U-Boot in Eclipse Helios On Window XP一文,我用的是u-boot-2011.09,经过修改Makefilemkconfigsoft link相关部分,在MinGWEclipse下能顺利进行编译。本文介绍另外一种方法,也是liandao大侠提供的方法,只是我做了一些改动。

1、建立工程
new—>projectà须选择 Makefile project with Existing Code->选择samba共享的u-boot-2011.09目录
我是将samba目录映射驱动Z




如果导入不成功,请到linux虚拟机检查samba共享设置,是否勾上writable。我用的Fedora14,附录Asamba相关设置。 


2、设置build相关选项。
 

  工程选项properties—C/C++ Build  
aBuilder Setting Tab



去掉Use default build command ,填上cmd /c remote_build.bat
 

bSetting一栏,勾上elf parse GNU elf parse
并修改GNU elf parseaddr2line.exe c++ filt.exe为你安装到windows的交叉编译工具eabi目录路径。我装的是Sourcery G++ Lite 2011.03-42,所以是arm-2011.03\bin下。


并把project 项中build automatically项取消掉,不让其自动编译。 
 


 

3、添加make distcleanmake mini6410_config
  project->make targetàcreate 填上distclean然后ok
同样增加mini6410_config.(如果是全新的u-boot-2011.09 可尝试smdk_6400) 
 


 

4plink等相关设置
alink.exe C:/Windows/system32
b、建立一文本文件写入:
plink.exe -ssh root@192.168.0.5 -pw 111111 cd /usr/tmp/u-boot-2011.09; time make %1; date;
                linux IP          密码     uboot目录
改名为remote_build.bat,放到/usr/tmp/u-boot-2011.09目录下 
 


 

因我在u-bootMakefine 加入了linux下的交叉编译路径(export CROSS_COMPILE=arm-none-eabi-
)root账户启动时加入了交叉编译器的linux目录,所以不用再remote_build.bat中去执行环境变量。
 

5Debug项设置
run-Debug
双击Zylin embedded debug—》选择下边的u-boot-xx
main一栏选择u-boot
[upload=8]
下面设置Debugger选项卡,GDB debugger设置为arm-none-eabi-gdb.exe.就是我们以后调试用的交叉调试器。把GDB command file: 清空
[upload=9]
下面设置Command选项卡,在’Initialize’ Command 添加下面的初始化mini6410的代码,这个代码是符合Jlink gdbserver的语法结构的。
[upload=10] 

Eclipse+Jlink gdbSever调试mini6410 uboot一文中作者加入了continue,是不能进行单步调试的,切记。



代码如下(做了简单的注释):
# connect to the J-Link gdb server
target remote localhost:2331

#target remote 127.0.0.1:2331
# Set JTAG speed to 30 kHz
monitor speed 30

monitor endian little
# Reset the target
monitor reset
monitor sleep 20
#
# CPU core initialization (to be done by user)
#
# Set the processor mode
monitor reg cpsr = 0xd3

#enable arm instruction set simulation
monitor AllowSimulation 1
#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

#memU8/16/32 read/write byte/half word/word from the address
#monitor memU32 0x7e004000  :read word
monitor MemU32 0x7e004000  =  0x00000000
monitor sleep 100
#disable interrupt
VICINTENCLEAR 寄存器:0无影响 1中断diable
monitor MemU32 0x7120000C  =  0x00000000
monitor MemU32 0x7130000C  =  0x00000000

monitor MemU32 0x71200014  =  0xFFFFFFFF
monitor MemU32 0x71300014  =  0xFFFFFFFF
#
VectAddr写入任何值清除当前中断

monitor MemU32 0x71200F00  =  0x00000000
monitor MemU32 0x71300F00  =  0x00000000
#set clock  
【系统控制器一章中包括时钟和电源控制】
monitor MemU32 0x7e00f000  =  0x0000ffff
monitor MemU32 0x7e00f004  =  0x0000ffff
#monitor MemU32 0x7e00f00C  =  0xc2150603

monitor MemU32 0x7e00f00C  =  0xc2150601
monitor MemU32 0x7e00f010  =  0xc2150601

monitor MemU32 0x7e00f014  =  0x00200102
monitor MemU32 0x7e00f018  =  0x00000000
monitor MemU32 0x7e00f01C  =  0x14000007

monitor MemU32 0x7e00f020  =  0x01043310
monitor MemU32 0x7e00f024  =  0x00000003

monitor MemU32 0x7e00f900  =  0x0000801e
#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 10240
set remote memory-write-packet-size fixed
monitor speed 12000
#break start_armboot

break relocate_code
load
break lowlevel_init

#不能使用continue,否则不能进行单步调试(即会程序自动run)

#continue 
 

source一栏移除default项。

点击Debug按钮,uboot download完成以后,就可以像其他的调试器一样。
如图下载进行中:
 
 [upload=11]

下载完成,设置u-boot代码所在目录
 

Locate File设置start.S的目录
source lookup path 设置project—u-boot-2011.09的目录
然后就可单步step in/step out调试了。
 [upload=12]
 

 

附录A   Fedora14 samba设置及Fedora运行于命令行模式
 

1、  修改 fedora14 /etc/ininttab
26 改为 id :3:initdefault:
再次启动就会停留在命令行登陆模式,如果要进入X-windows,登陆后执行startx即可。
2、  samba
终端:
#yum search samba
#yum install samba.i686
samba GUI配置工具
#yum install system-config-samba.noarch 
 

添加samba共享目录,需勾上writable

 [upload=13]

添加samba用户
 [upload=14]

共享属性设置:share模式,不需输入密码

 [upload=15]

 
[ 此帖被blueleaf_y在2012-01-10 11:59重新编辑 ]
级别: 新手上路
UID: 508
精华: 0
发帖: 45
金钱: 225 两
威望: 45 点
贡献值: 0 点
综合积分: 90 分
注册时间: 2008-04-14
最后登录: 2017-09-13
1楼  发表于: 2013-06-26 19:50
可以观察变量不, 以前我也调试过, 但不可设置变量