『原创』ubuntu下使用skyeye对u-boot进行源码级调试

内核编译和嵌入式产品的设计与开发
回复
dekong
帖子: 29
注册时间: 2008-05-16 13:55

『原创』ubuntu下使用skyeye对u-boot进行源码级调试

#1

帖子 dekong » 2008-10-27 13:29

学习嵌入式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调试环境的基础上进行的,没搭好的可以参照我之前发的帖子搭一下,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 $(<:.o=) $< $(LIB) \
125 -L$(gcclibdir) -lgcc
126 %.srec: %
127 $(OBJCOPY) -O srec $< $@ 2>/dev/null
128
129 %.bin: %
130 $(OBJCOPY) -O binary $< $@ 2>/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代码。
下图是我电脑上的截图
附件
Screenshot-1.png
321kevin
帖子: 6
注册时间: 2008-10-28 20:50

Re: 『原创』ubuntu下使用skyeye对u-boot进行源码级调试

#2

帖子 321kevin » 2008-11-07 14:50

高手问个问题,我打开INSIGHT-6.8后。PORT端口始终是1000,不能更改。HOSTNAME也不能更改。
REMOTE/TCP
HOSTNAME:
PORT:1000
不能更改。。。
mei5150
帖子: 2
注册时间: 2009-01-16 18:56

楼上的朋友,我也遇到相同的问题

#3

帖子 mei5150 » 2009-01-16 20:47

找了个最笨的解决方法:打开insight的终端,输入target remote 127.0.0.1:12345连接skyeye,然后执行step单步执行一下下,然后你就可以在图形界面下操作了。
lyjg1204
帖子: 4
注册时间: 2008-12-06 9:06

新租了一房子想知道是换锁还是换锁芯呢?

#4

帖子 lyjg1204 » 2009-01-17 15:33

新租了一房子,为了安全,想知道是换锁还是换锁芯呢?
在买锁/锁芯的时候,有没有什么需要注意的?
比如说要是只换锁芯,一定要和原来的锁的牌子 型号一致吗?
要是换锁,要不要考虑到防盗门和锁是不是相匹配?
换锁心好了,开锁的孔的下方,在门的侧面有一个螺丝卸下来就能抽出锁芯了.如果插不出来,把外面里面的两个螺丝盖板卸了再卸外面的两个螺丝就能抽出来.之前你到防盗门店去买一个锁心,尺寸一样不过是长短而已.可以量一下龙甲防盗门锁心距离,再去买.就这样锁心在门上然后用尺对一下就可以了,或者没尺用根绳子也可以.
回复