免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1145 | 回复: 0
打印 上一主题 下一主题

ubuntu下使用skyeye对u-boot进行源码级调试 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-02-25 10:13 |只看该作者 |倒序浏览

学习嵌入式linux编程一个很好的切入点就是先学习u-boot,u-boot的coding stytle与linux完全一样,而且程序注释丰富,很容易上手,如果能把u-boot完全理解了再转向linux,可以达到事半功倍的效果。可是u-boot发展到现在兼容了很多平台,代码量已经非常大了,程序调用从一个文件夹转到另一个文件夹,转来转去的,如果单纯的看代码的话,一会就头大了。那么可不可以像windows下调试程序一样通过一种方法单步调试u-boot呢,网上很容易找到的有两种方法:一种方法是使用ads+axd来进行源码级调试,这种方法应该是可行的,可是我还没有验证过,因为我手头一没有仿真器,二没有开发板;另一种方法是使用BDI调试,BDI是个啥我现在还没整明白,只知道这东西巨贵,实用性不高。我下面介绍的方法是纯软件的解决方案,不涉及任何硬件,使用的工具及版本如下:
代码:
1、skyeye                            1.2.6-rc1
2、arm-linux-gcc                            2.95.3
3、arm-linux-gdb                            6.8
4、arm-linux-insight                      6.8
5、u-boot                                       1.1.4
host使用的是ubuntu-8.04
本方法是在假定您已经搭好arm-linux交叉编译环境及arm-linux-gdb+insight调试环境的基础上进行的,没搭好的可以参照我之前发的帖子搭一下,
http://forum.ubuntu.org.cn/viewtopic.php?f=97&t=159051
一、编译安装skyeye
假定我的工作目录是~/workspace,下载skyeye-1.2.6_rc1.tar.bz2至工作目录
代码:
kanson@kanson:~/workspace$ tar -jxvf skyeye-1.2.6.tar.bz2
kanson@kanson:~/workspace$ cd skyeye-1.2.6_rc1
kanson@kanson:~/.../skyeye-1.2.6_rc1$ ./configure
kanson@kanson:~/.../skyeye-1.2.6_rc1$ make
kanson@kanson:~/.../skyeye-1.2.6_rc1$ sudo cp skyeye /usr/bin
这样就可以在任何目录使用skyeye了
二、配置u-boot-1.1.4
代码:
kanson@kanson:~/workspace$ tar -jxvf u-boot-1.1.4.tar.bz2
kanson@kanson:~/workspace$ cd u-boot-1.1.4
kanson@kanson:~/.../u-boot-1.1.4$ make smdk2410_config
kanson@kanson:~/.../u-boot-1.1.4$ make
编译时会出现两个错误,解决方法如下:
引用:
make[1]: *** No rule to make target `hello_world.srec', needed by `all'. Stop.
make[1]: Leaving directory `/home/mort/src/targa/u-boot/u-boot-TOT/examples'
make: *** [examples] Error 2
有如下的解决方法:
打开 examples/Makefile
119 $(LIB): .depend $(LIBOBJS)
120 $(AR) crv $@ $(LIBOBJS)
121
122 %: %.o $(LIB)
123 $(LD) -g $(EX_LDFLAGS) -Ttext $(LOAD_ADDR) \
124 -o $@ -e $(/dev/null
128
129 %.bin: %
130 $(OBJCOPY) -O binary $/dev/null
把126行和129行改为:
%.srec: %.o
%.bin: %.o
继续make
在make的过程中,出现:
isystem /usr/local/arm/bin/../lib/gcc-lib/arm-linux/3.2/include -pipe -DCONFIG_ARM -D__ARM__ -march=armv4 -mtune=arm7tdmi -msoft-float -mabi=apcs-gnu -Uarm -Wall -Wstrict-prototypes -c -o hello_world.o hello_world.c
cc1: invalid option `abi=apcs-gnu'
有如下的解决方法:
出错的文件是/cpu/s3c44b0/下的config.mk:将
PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,-mabi=apcs-gnu)
改成:
PLATFORM_CPPFLAGS +=$(call cc-option,-mapcs-32,$(call cc-option,-mabi=apcs-gnu),)
继续make,顺利make出u-boot.bin、u-boot、u-boot.srec
u-boot.bin是不带调制信息的二进制文件
u-boot.bin是包含调制信息的elf文件,也是本方案要使用的文件
u-boot.srec好像是moto的一种文件格式,just forget it
三、仿真前准备工作
创建仿真工作目录
代码:
kanson@kanson:~/.../u-boot-1.1.4$ mkdir skyeye
kanson@kanson:~/.../u-boot-1.1.4$ cd skyeye
创建skyeye配置文件skyeye.conf
代码:
kanson@kanson:~/.../skyeye$ vi skyeye.conf
内容如下:
代码:
#skyeye config file sample
cpu:arm920t
mach:s3c2410x
#all peripherals I/O mapping area
mem_bank: map=I, type=RW, addr=0x48000000, size=0x20000000
mem_bank: map=I, type=RW, addr=0x19000300, size=0x00000020
#physical memory
mem_bank: map=M, type=RW, addr=0x00000000, size=0x00080000, file=./u-boot, boot=yes
mem_bank: map=M, type=RW, addr=0x30000000, size=0x04000000
load_addr:base=0x30000000, mask=0xFFFFFF
将u-boot文件拷入skyeye文件夹,执行如下命令
代码:
kanson@kanson:~/.../skyeye$ skyeye
输出内容如下:
代码:
**************************** WARNING **********************************
If you want to run ELF image, you should use -e option to indicate
your elf-format image filename. Or you only want to run binary image,
you need to set the filename of the image and its entry in skyeye.conf.
***********************************************************************
Your elf file is little endian.
arch: arm
cpu info: armv4, arm920t, 41009200, ff00fff0, 2
mach info: name s3c2410x, mach_init addr 0x806c5c0
Your elf file will be load to: base address=0x30000000,mask=0xffffff
uart_mod:0, desc_in:, desc_out:, converter:
SKYEYE: use arm920t mmu ops
Loaded RAM   ./u-boot
ERROR: s3c2410x_io_write_word(0x4c000000) = 0x00ffffff
ERROR: s3c2410x_io_write_word(0x4c000008) = 0x00048032
U-Boot 1.1.4 (Oct 27 2008 - 11:34:51)
U-Boot code: 33F80000 -> 33F9873C  BSS: -> 33F9C814
RAM Configuration:
Bank #0: 30000000 64 MB
Flash: 512 kB
*** Warning - bad CRC, using default environment
In:    serial
Out:   serial
Err:   serial
ERROR: s3c2410x_io_write_word(0x1900030a) = 0x00000000
SMDK2410 #
表明编译生成的u-boot文件可用,CTRL+C退出skyeye,重新执行如下命令进入skyeye的debug模式
代码:
kanson@kanson:~/.../skyeye$ skyeye -d
输出内容如下:
代码:
**************************** WARNING **********************************
If you want to run ELF image, you should use -e option to indicate
your elf-format image filename. Or you only want to run binary image,
you need to set the filename of the image and its entry in skyeye.conf.
***********************************************************************
Your elf file is little endian.
arch: arm
cpu info: armv4, arm920t, 41009200, ff00fff0, 2
mach info: name s3c2410x, mach_init addr 0x806c5c0
Your elf file will be load to: base address=0x30000000,mask=0xffffff
uart_mod:0, desc_in:, desc_out:, converter:
SKYEYE: use arm920t mmu ops
Loaded RAM   ./u-boot
debugmode= 1, filename = skyeye.conf, server TCP port is 12345
表明skyeye已经进入debug模式等待host端进行连接
再打开一个shell,运行arm-linux-insight(前提是已经安装好了arm-linux-gdb、arm-linux-insight)
代码:
kanson@kanson:~/.../skyeye$ arm-linux-insight u-boot
打开arm-linux-insight,在File-->Target Settings中的设置为
代码:
Connection
Target: Remote/TCP
Hostname:为空
Port:12345
关闭对话框,连接目标板『Run-->Connect to target』,提示连接成功后即可进行单步调试了,
好像不能调试汇编文件(start.S),不知道什么原因,有高手知道为什么麻烦告诉我一下,但可以直接在board.c文件中的start_armboot函数上加断点,从此处开始调试C代码。
下图是我电脑上的截图

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/15201/showart_1842559.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP