洋洋

洋洋的博客

他的个人主页  他的博客

Ubuntu 8.04下搭建uClinux开发环境Skyeye进行仿真

洋洋  2010年01月09日 星期六 18:47 | 2349次浏览 | 4条评论

Ubuntu 8.04下搭建uClinux开发环境Skyeye进行仿真 原文发布在ChinaUnix:http://blog.chinaunix.net/u3/92010/showart_2080217.html

在ubuntu8.04上搭建uClinux编译开发环境Skyeye进行仿真
一、搭建开发环境
www.uclinux.org 上下载以下两个包:
交叉开发工具:arm-elf-tools-20030314.sh
uClinux的源码包:uClinux-dist-20040408.tar.gz
安装交叉开发工具:进入arm-elf-tools-20030314.sh所在的目录,执行以下命令进行安装:

代码:
# chmod +x arm-elf-tools-20030314.sh
# ./arm-elf-tools-20030314.sh

这两条命令首先是加可执行权限,然后安装。
解压uClinux源码包:
用以下命令:

代码:
$tar zxvf uClinux-dist-20030314.tar.gz
************************************************
从网上下载的arm-elf-tools-20030314.sh在安装时遇到很多问题,google了一下,很多同胞也遇到这样的问题。

___________________________________________________________________________________
按照安装说明执行
./arm-elf-tools-20030314.sh
提示: 
bad interpreter: No such file or directory

如果执行
source arm-elf-tools-20030314.sh
提示:
: command not found
'bash: ./arm-elf-tools-20030314.sh: line 4: syntax error near unexpected token `in
'bash: ./arm-elf-tools-20030314.sh: line 4: `case "${SCRIPT}" in

___________________________________________________________________________________
我在ftp://166.111.68.183/pub/embed/uclinux/soft/tools/arm下载arm-elf-tools-20030314.sh后,安装时也出现这种情况,其他很多地方下载的这个文件也有同样的问题,后来找到这个
http://ftp.snapgear.org/pub/snapgear/tools/arm-elf/ ]运行OK ^_^,这里还有一些其他的文件,像GCC,GDB 等等。

___________________________________________________________________________________
在运行.sh文件时还可能出现一下错误:
# chmod +x arm-elf-tools-20030314.sh
# ./arm-elf-tools-20030314.sh

errors:
tail : cannot open `+43' for reading : No such file or directory

gzip:stdin: not in gizp format
tar: This does not look like a tar archive
tar: Error exit delayed from previous errors

解决方案:

Code:
    tail : cannot open `+43' for reading : No such file or directory
   
This error comes out when you use the obsolete option for tail
Code:
    tail +43
   
the latest POSIX standard interprets it as the name of a file. In this case you have to use the correct option
Code:
    tail -n +43
   
However, since you're running a binary file, it is not possible to edit it to change commands. But you can change the POSIX standard to match the one assumed by the installer. Just set the environment variable _POSIX2_VERSION as in
Code:
    export _POSIX2_VERSION=199209
   

___________________________________________________________________________________


二、下载Skyeye 以便进行仿真:

SkyEye 是开源软件的一个项目,SkyEye的目标是在Linux和Windows操作系统里提供一个完全的仿真环境。SkyEye仿真环境相当于一个嵌入式计算机系统,你可以在SkyEye里运行一些嵌入式Linux操作系统,如ARMLinux,uClinux,uc/OS-II(ucos-ii)等,并能分析和调试它们的源代码。
如果你想知道关于SkyEye和嵌入式系统更详细的信息,请访问下面的站点:
www.SkyEye.org
http://www.skyeye.org/index_cn.html

安装SkyEye
网上介绍了很多安装方法,其实在ubuntu里面安装最方便:

代码:
root@yuanyangliu-Linux:~# apt-get install skyeye


这样,一个最新版的skyeye1.2.3就安装好了。
在shell 里面直接键入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.
***********************************************************************

big_endian is false.
Failed to open skyeye config file skyeye.conf in the same directory
error: No such file or directory
------------------------- SkyEye -V1.2 ---------------------------
Usage: SkyEye [options] -e program [program args]
Default mode is STANDALONE mode
------------------------------------------------------------------
Options:
-e exec-file        the (ELF executable format)kernel file name.
-l load_address,load_address_mask
                    Load ELF file to another address, not its entry.
-b                  specify the data type is big endian when non "-e" option.
-d                  in GDB Server mode (can be connected by GDB).
-c config-file      the skyeye configure file name.
-h                  The SkyEye command options, and ARCHs and CPUs simulated.
------------------------------------------------------------------
----------- Architectures and CPUs simulated by SkyEye-------------
-------- ARM architectures ---------
at91
lpc
s3c4510b
s3c44b0x
s3c44b0
s3c3410x
ep7312
lh79520
ep9312
cs89712
sa1100
pxa_lubbock
pxa_mainstone
at91rm92
s3c2410x
s3c2440
sharp_lh7a400
ns9750
lpc2210
ps7500
integrator
-------- BlackFin architectures ----
bf533

表明你的skyeye 已经安装好了,可以随时使用了。
当然,如果你的源里面没有 skyeye,就尝试从下面的方法安装:
首先下载skyeye:
下载地址: http://gro.clinux.org/projects/skyeye/
在这个网址里面有如下两个版本,我建议用1.2.2版本的,1.2.3版本的在安装时往往存在一些问题
skyeye_1_2_2_Rel.tar.bz2
skyeye_1_2_3_Rel.tar.bz2

因为在安装skyeye 时会用到一些别的包,所以在新立得软件包管理器中找到下面的软件包: binutils-dev[这个问题也有很多人遇到,在Ubuntu下直接 apt-get install binutils-dev]  标记并安装
下面是关于这个软件包的描述
The GNU binary utilities (BFD development files)
This package includes header files and static libraries necessary to build
programs which use the GNU BFD library, which is part of binutils. Note
that building Debian packages which depend on the shared libbfd is Not
Allowed.

最后使用make命令进行软件的安装,编译完毕后会在binary生成一个skyeye可执行文件,该文件就是skyeye模拟器了。
使用make命令的时候可以加入一些选项参数,例如:
不允许DBCT
$make NO_DBCT=1
不支持LCD
$make NO_LCD=1
不支持BFD库
$make NO_BFD=1
不支持网络设备
$make NO_NET=1
如果在binary目录下生成了skyeye文件,那么安装成功。
为了可以在shell 里面直接运用skyeye命令,将这个路径 /source/skyeye_1_2_2_Rel/binary  加入到系统环境变量中

代码:
$gedit /etc/environment

找到有PATH那一行,加入skyeye 路径,比如下面所示
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/slickedit/bin:/source/skyeye_1_2_2_Rel/binary"

----------[如果通过 apt-get install skyeye 安装的则不用手动添加路径到环境变量中]
***********************************************************************************
源码安装步骤总结:
1.解压下载的源码包,并进入源码所在目录
2. ./configure --target=arm-elf --prefix=/usr/local --without-gtk-prefix --without-gtk-exec-prefix --disable-gtktest[configure命令所带的选项意义查看man页]
3.make lib   [make lib 来编译第三方的库]
4.make       [make 来编译 skyeye 的源代码]
5.make install_lib
6.make install
7.make clean
***********************************************************************************

三、测试arm-elf-tool 的工作情况
建立一个源文件键入以下代码:

代码:
/*test.c*/
#include <stdio.h>

int main()
{
        int i;
        for(i=0;i<6;i++)
        {
                printf("i=%d\n",i);
                printf("Hello,embedded linux!\n");
        }
        return 0;
}


用以下命令进行编译:

代码:
root@yuanyangliu-Linux:/source/work/test# arm-elf-gcc -Wl,-elf2flt -o test test.c
root@yuanyangliu-Linux:/source/work/test# ls
test  test.c  test.gdb

可以看到编译输出两个文件:test和test.gdb,表示编译成功
其中-elf2flt参数是将elf文件格式转为flat文件格式,这个工具是在你安装交叉编译器产生的.
也可以写一个makefile测试,下面是我写的一个,仅供参考:

代码:
#begin
CC=arm-elf-gcc
LDFLAGS=-Wl,-elf2flt
LIBS=
OBJS=test.o
all:test
hello(OBJS)
   $(CC) $(CFLAGS) $(LDFLAGS) -o hello $(OBJS)   
clean:
   rm -rf *.o *.elf *.gdb test   
#end



执行make 命令后编译成功,最后也生成了test文件,我们来看一下这个test文件

代码:
root@yuanyangliu-Linux:/source/work/test# file test
test: BFLT executable - version 4 ram


可以看到生成的文件格式为BFLT格式,这是目标平台所支持的格式,所以当你试图:./test时,系统会提示:

代码:
root@yuanyangliu-Linux:/source/work/test# ./test
bash: ./test:无法执行二进制文件


我们也可以用下面的命令进行编译生成汇编代码

代码:
root@yuanyangliu-Linux:/source/work/test# arm-elf-gcc -S -o test.S test.c
root@yuanyangliu-Linux:/source/work/test# file test.S
test.S: ASCII assembler program text


用文本编辑器打开这个文件test.S,就可以看到熟悉的ARM 汇编代码了。

四、测试这个程序:

测试这个程序需要用到一个工具skyeye-testsuits,可以在下面的网址下载:
http://gro.clinux.org/projects/skyeye/
网址里面有testsuite2.1.tar.bz2 但是在这里我们直接下载1.2.0版的二进制的工具包,skyeye-binary-testutils-1.2.0.tar.bz2
下载后解压

代码:
root@yuanyangliu-Linux:/source# tar jxvf skyeye-binary-testutils-1.2.0.tar.bz2


进入下面这个目录,这是我们主要用到的目录。

代码:
root@yuanyangliu-Linux:/source# ls skyeye-binary-testutils-1.2.0/at91x40/uclinux2
boot.rom  linux  readme  skyeye.conf


这个目录里面有四个文件,其中linux就是内核映像,boot.rom是要写到Flash里面去的。里面包含文件系统。skyeye.conf是配置文件。
可以在命令行里键入以下代码,

代码:
skyeye -e linux


你看到了什么?没错,我没有骗你

代码:
          ____ _  _
         /  __| ||_|                 
    _   _| |  | | _ ____  _   _  _  _
   | | | | |  | || |  _ \| | | |\ \/ /
   | |_| | |__| || | | | | |_| |/    \
   |  ___\____|_||_|_| |_|\____|\_/\_/
   | |
   |_|


当你看到这幅图片的时候,是不是感觉很爽?
哈哈......Over!
                                                                     洋洋
                                                                 2009.10.27

评论

我的评论:

发表评论

请 登录 后发表评论。还没有在Zeuux哲思注册吗?现在 注册 !
冯莹

回复 冯莹  2010年01月10日 星期日 11:26

ding

1条回复

黄国荣

回复 黄国荣  2010年01月09日 星期六 21:32

Thanks for sharing

1条回复

暂时没有评论

Zeuux © 2024

京ICP备05028076号