QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 32098|回复: 46

新手手记:一步一步教你在skyeye上运行uboot

[复制链接]
发表于 2005-1-7 06:59:10 | 显示全部楼层 |阅读模式
新手手记:一步一步教你在skyeye上运行uboot
by faif

1. 简介

skyeye是一个很好的,基于各种ARM系列CPU的,SOC和主板级的模拟器。uboot是一个可以在各种cpu(arm,mips,powerpc)的主板上运行的引导程序,相当于PC机的BIOS但是又远远的强于普通的BIOS,比如支持网络引导,引导各种内核,甚至一个简单的shell,等等。他们两个都是基于GPL的开源自由软件。

这篇文章教你怎样在最少量的修改代码的情况下,用skyeye模拟EP7312并在上面运行uboot,给接触嵌入系统的新手一个感性的认识。

2. 建立开发环境

2.1 skyeye模拟器的安装

开发环境是建立在Linux上的。首先下载安装skyeyes-0.8.5.1的源代码包,解压,按照里面的readme安装,注意你的linux要有gtk的支持。安装的时候要以root的身份。在各种linux发行版下的安装注意事项参照论坛的相关帖子。安装成功以后,把skyeye的目标目录加入你的路径,这样你就可以在任何目录下执行skyeye模拟器了。

2.2 交叉编译器的安装

交叉编译器是运行在主机上编译另外一种体系结构的编译器。比如,我的主机是linux在x86上,我现在要编译基于ARM的代码,所以我就不能用普通的编译器而需要交叉编译器。我曾经试过自己从gcc的源代码构建交叉编译器,很麻烦和耗时。uboot的作者同样也开发了一个很好的交叉编译器叫ELDK(Embedded linux development kit)。我就使用这个,当然你也可以使用其他嵌入式公司提供的。你可以从以下的网址查看提供ELDK的镜像:

ELDK Availability: http://www.denx.de/twiki/bin/view/DULG/ELDKAvailability

ELDK有三个版本分别编译MIPS,PPC和ARM。我从下面的镜像下载了基于ARM的交叉编译器:

http://sunsite.utk.edu/ftp/pub/linux/eldk/3.1/arm-linux-x86/iso/

文件为"arm-2004-11-09.iso",它支持ARM7, ARM9, XScale, AT91RM9200 and other ARM based systems。

安装交叉编译器,我将交叉编译器安装到自己的目录“/opt/x86-arm/”里面:
[code:1]/mnt/cdrom/install -d /opt/x86-arm/[/code:1]

等待安装结束以后设置好用户环境:
[code:1]
export PATH="${PATH}:/opt/x86-arm/usr/bin:/opt/x86-arm/bin"
export CROSS_COMPILE=arm-linux-
[/code:1]       
这样你在任何目录也可以访问交叉编译器了。

测试:
[code:1]
arm-linux-gcc -o testarm test.c
file testarm
testarm: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped.
[/code:1]

说明你编译好的文件是ARM上的代码了。你可以用arm-linux-gcc来编译你的文件了。

3. 修改Uboot

从uboot的网站上可以下载到最新的uboot源代码,你可以从以下的网址下载

        http://u-boot.sourceforge.net/
        ftp://ftp.denx.de/pub/u-boot/
       
uboot的源码结构清晰,注释详细,是学习嵌入系统的很好的例子。我下载的是最新的U-Boot-1.1.2。因为我们要模拟EP7312的芯片,而uboot已经支持一个基于EP7312的板子了,所以我们只要对uboot里面有关EP7312的板子的配置略作修改就可以了。uboot里面有关主板的配置文件都在"include/configs/<board_name>.h"下,所以我们找到include/configs/ep7312.h,对它进行修改。
[code:1]
找到
        #define CONFIG_DRIVER_CS8900    1
改为
        #define CONFIG_DRIVER_CS8900    0

找到
        #define CONFIG_COMMANDS               (CONFIG_CMD_DFL | CFG_CMD_JFFS2)
改为
        #define CONFIG_COMMANDS               (CONFIG_CMD_DFL) /*Skyeye doesn't have jffs2*/[/code:1]
       
然后回到uboot的根目录下,配置,编译:
[code:1]
make ep7312_config
make all
[/code:1]
等待结束以后我们会发现u-boot.bin和u-boot两个文件,其中u-boot.bin是raw的二进制文件。u-boot是ELF格式的。

4. 配置skyeye,并运行uboot

首先,新建一个目录代表你的EP7312的主板。这样也可以保持文件的清洁和有序。
[code:1]
mkdir board01
[/code:1]
将你刚才编译成功的u-boot.bin拷贝到这个目录下来。skyeye支持raw binary和ELF的格式,这里我们用raw binary的格式。

编辑skyeye.conf,这个文件是用来配置主板的,详细说明见skyeye的相关文档。我的skyeye.conf如下:
[code:1]
#skyeye config file for uboot
cpu: arm720t
mach: ep7312

mem_bank: map=I, type=RW, addr=0x80000000, size=0x00010000

#skyeye for uboot flash 16M bank 1
mem_bank: map=M, type=RW, addr=0x00000000, size=0x01000000, file=./u-boot.bin,boot=yes

#skyeye for uboot sdram 16m bank 1
mem_bank: map=M, type=RW, addr=0xc0000000, size=0x01000000
[/code:1]
注意这里的内存的地址和容量的分配都是根据uboot里面的ep7312的配置文件调整的。这样也可以是我们对uboot的代码修改做到最小。

这时候你的skyeye-ep7312主板就配置好了。你可以试着运行了。在你现在的目录下打入:
        [code:1]skyeye[/code:1]

然后在skyeye的界面下打入:
[code:1]
        target sim
        run
[/code:1]
这时候你可以看到uboot的启动界面,和提示符,如果你键入“hlep”,可以查看所有uboot支持的命令,键入“version”可以查看当前uboot的版本,等等。

5. 进一步的工作

由于本文是最基本的介绍性的一步一步的指导。有很多工作还要去尝试。比如:

× 由于现在skyeye还不支持flash内存,所以我们是不是可以修改uboot上ep7312相对flash的代码来临时满足我们的需要,不然的话,对于在uboot上面的环境参数的设置,我们只能去修改源码里面的缺省参数。

× Uboot支持8019AS的以太网控制器,skyeye也支持了这个硬件的模拟,我们要进一步的使uboot的网络也在skyeye上用起来?

× 对于模拟flash的开发也可以用uboot来测试。uboot里面各种板子有大量的flash驱动程序。

还望各位高手指教,我进一步修改和提高。
发表于 2005-1-7 11:47:36 | 显示全部楼层
好文!
感谢faif为新手们贡献这样具有指导意义的 Step by Step!
应该收入“本版精华”
回复

使用道具 举报

发表于 2005-1-8 23:41:23 | 显示全部楼层
写得很好!
我按照这篇文章运行uboot成功.
多谢faif的分享!
回复

使用道具 举报

发表于 2005-1-12 10:09:43 | 显示全部楼层
请教楼主,我用cross-2.95.3交叉编译工具,make 时出现
make[1]: Entering directory `/opt/u-boot-1.1.2/examples'
/usr/local/arm/2.95.3/bin/arm-linux-gcc -g  -Os   -fno-strict-aliasing  -fno-common -ffixed-r8 -mshort-load-bytes -msoft-float -D__KERNEL__ -DTEXT_BASE=0xc0f80000 -I/opt/u-boot-1.1.2/include -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/include -pipe  -DCONFIG_ARM -D__ARM__ -mapcs-32 -march=armv4 -mtune=arm7tdmi -Wall -Wstrict-prototypes -g  -Os
  -fno-strict-aliasing  -fno-common -ffixed-r8 -mshort-load-bytes -msoft-float -D__KERNEL__ -DTEXT_BASE=0xc0f80000 -I/opt/u-boot-1.1.2/include -fno-builtin -ffreestanding -nostdinc -isystem /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/include -pipe  -DCONFIG_ARM -D__ARM__ -mapcs-32 -march=armv4 -mtune=arm7tdmi -I.. -Bstatic -T /opt/u-boot-1.1.2/board/ep7312/u-boot.lds -Ttext 0xc0f80000   hello_world.c   -o hello_world
/usr/local/arm/2.95.3/arm-linux/bin/ld: cannot find -lfloat
collect2: ld returned 1 exit status
arm-linux-gcc: file path prefix `static' never used
make[1]: *** [hello_world] Error 1
make[1]: Leaving directory `/opt/u-boot-1.1.2/examples'
make: *** [examples] Error 2

该如何解决啊? thanks
回复

使用道具 举报

 楼主| 发表于 2005-1-13 00:24:12 | 显示全部楼层
有关“cannot find -lfloat ” 的问题比较常见了,是你的交叉编译器出了问题。在构建glibc的时候没有soft float的库,“-msoft-float"要求有这个库。

看你好像用的是uclinux提供的arm交叉编译器,察看一下版本是多少:

[code:1]
arm-linux-gcc -v
[/code:1]

建议你使用本文建议的编译器:ELDK
ELDK基于,gcc3.3.3,并一直被u-boot的作者开发和维护,是个很好的交叉编译器,交叉编译linuxkernel也没有问题,建议使用。
回复

使用道具 举报

发表于 2005-1-21 16:29:33 | 显示全部楼层

ELDK安装后编译u-boot-1.1.2出问题,帮忙看一下

make ep7312_config后
执行make all 出现如下
arm-linux-gcc -v 显示3.3.3


1-20 02:31:02 > 2005-01-18 21:05:37.346299)                                    
make[1]: `.depend' is up to date.                                             
make[1]: warning:  Clock skew detected.  Your build may be incomplete.         
make[1]: Leaving directory `/home/llf/u-boot-1.1.2/examples'                  
make[1]: Entering directory `/home/llf/u-boot-1.1.2/post'                     
make[1]: *** Warning: File `.depend' has modification time in the future (2005-
1-20 02:31:02 > 2005-01-18 21:05:37.699424)                                    
make[1]: `.depend' is up to date.                                             
make[1]: warning:  Clock skew detected.  Your build may be incomplete.         
make[1]: Leaving directory `/home/llf/u-boot-1.1.2/post'                       
make[1]: Entering directory `/home/llf/u-boot-1.1.2/post/cpu'                  
make[1]: *** Warning: File `.depend' has modification time in the future (2005-
1-20 02:31:02 > 2005-01-18 21:05:38.17866                                    
make[1]: `.depend' is up to date.                                             
make[1]: warning:  Clock skew detected.  Your build may be incomplete.         
make[1]: Leaving directory `/home/llf/u-boot-1.1.2/post/cpu'                  
make -C tools all                                                              
make[1]: Entering directory `/home/llf/u-boot-1.1.2/tools'                     
make[1]: *** Warning: File `.depend' has modification time in the future (2005-
1-20 02:31:02 > 2005-01-18 21:05:39.61665                                    
make[1]: *** No rule to make target `/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.
1.66/include/stddef.h', needed by `img2srec.o'.  Stop.                        
make[1]: Leaving directory `/home/llf/u-boot-1.1.2/tools'
回复

使用道具 举报

发表于 2005-1-21 16:31:35 | 显示全部楼层
最后一句

make: *** [tools] Error 2
回复

使用道具 举报

发表于 2005-1-22 20:49:25 | 显示全部楼层
好文!按照楼主所说的把u-boot在skyeye上运行起来了,但现在有个问题,我想通过skyeye来读u-boot的源码(这应该是skyeye的初衷之一吧),应该怎么做呢?但直接编译出来的u-boot好像设不了断点,是不是没有调试信息啊?要是带上调试信息应该怎么该呢?新手,请指教,谢谢!
回复

使用道具 举报

 楼主| 发表于 2005-1-24 19:15:08 | 显示全部楼层
to: q1a1z1
"/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.1.66/include/stddef.h"

It looks you header file is not cross-compiler header file. I doubt if your cross-compiler configuration is right. u-boot should not use any header files from host.

to: 白雪皑皑

I have not tried to use skyeye-gdb to debug U-boot yet. When I have time, I will try then discuss with you. The other old hand may give you suggestions.
回复

使用道具 举报

发表于 2005-1-24 19:56:06 | 显示全部楼层
I have added -g option in Makefile, and made out an u-boot file, but I still can not read the code in the skyeye  
回复

使用道具 举报

发表于 2005-1-27 10:09:03 | 显示全部楼层
我按照楼主的介绍,step by step安装了ELDK,但在make all时还是出现“cannot find -lfloat ”错误。

不知道问题在哪里?

[quote:cb5aea7c22="faif"]有关“cannot find -lfloat ” 的问题比较常见了,是你的交叉编译器出了问题。在构建glibc的时候没有soft float的库,“-msoft-float"要求有这个库。

看你好像用的是uclinux提供的arm交叉编译器,察看一下版本是多少:

[code:1]
arm-linux-gcc -v
[/code:1]

建议你使用本文建议的编译器:ELDK
ELDK基于,gcc3.3.3,并一直被u-boot的作者开发和维护,是个很好的交叉编译器,交叉编译linuxkernel也没有问题,建议使用。[/quote]
回复

使用道具 举报

 楼主| 发表于 2005-2-4 23:24:32 | 显示全部楼层
[quote:12e68f0301="gulite"]我按照楼主的介绍,step by step安装了ELDK,但在make all时还是出现“cannot find -lfloat ”错误。
...
[/quote]

I am not sure then, Please sign up u-boot mailing list and email to ask. the people there are very helpful:

http://lists.sourceforge.net/lists/listinfo/u-boot-users
回复

使用道具 举报

发表于 2005-2-5 09:09:28 | 显示全部楼层
但直接编译出来的u-boot好像设不了断点,是不是没有调试信息啊?要是带上调试信息应该怎么该呢?


编译完u-boot后,在u-boot顶层目录下生成了三个文件
-rwxrwxr-x    1 ywc      ywc        418447 Feb  5 08:45 u-boot
-rwxrwxr-x    1 ywc      ywc        108920 Feb  5 08:45 u-boot.bin
-rwxrwxr-x    1 ywc      ywc        326850 Feb  5 08:45 u-boot.srec
其中u-boot是带调试信息的。
u-boot:      ELF 32-bit LSB executable, ARM, version 1, statically linked, not stripped
u-boot.bin:  data
u-boot.srec: Motorola S-Record; binary data in text format


修改
#skyeye for uboot flash 16M bank 1
mem_bank: map=M, type=RW, addr=0x00000000, size=0x01000000, file=./u-boot.bin,boot=yes

#skyeye for uboot flash 16M bank 1
mem_bank: map=M, type=RW, addr=0x00000000, size=0x01000000, file=./u-boot, boot=yes
回复

使用道具 举报

发表于 2005-2-6 12:38:29 | 显示全部楼层
[quote:e158a92918="halfyear"]
修改
#skyeye for uboot flash 16M bank 1
mem_bank: map=M, type=RW, addr=0x00000000, size=0x01000000, file=./u-boot.bin,boot=yes

#skyeye for uboot flash 16M bank 1
mem_bank: map=M, type=RW, addr=0x00000000, size=0x01000000, file=./u-boot, boot=yes[/quote]

我就是这么做的啊

有人成功的在skyeye上对u-boot进行debug了么?现在放假在家,没办法试验:(
回复

使用道具 举报

发表于 2005-2-15 09:29:54 | 显示全部楼层
[quote:17eda5339c="白雪皑皑"][quote:17eda5339c="halfyear"]
修改
#skyeye for uboot flash 16M bank 1
mem_bank: map=M, type=RW, addr=0x00000000, size=0x01000000, file=./u-boot.bin,boot=yes

#skyeye for uboot flash 16M bank 1
mem_bank: map=M, type=RW, addr=0x00000000, size=0x01000000, file=./u-boot, boot=yes[/quote]

我就是这么做的啊

有人成功的在skyeye上对u-boot进行debug了么?现在放假在家,没办法试验:([/quote]

file=./u-boot.bin可以用的呀,
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-3-29 13:30 , Processed in 0.095914 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表