ubuntu 下达建略

网上找来找去,安装和使用ecos3.0的文档很少,也本着让自己记住和熟练的目 的,记下本文。

(系统环境:Ubuntu 8.10)

1.首先安装Tcl解释器和libstdc++5:

myz@ubuntu:~/work$sudo apt-get install tcl8.5 libstdc++5

2.然后按照ecos官网提示,下载文件ecos-install.tcl:

myz@ubuntu:~/work$wget --passive-ftp ftp://ecos.sourceware.org/pub/ecos-install.tcl

3.运行这个文件:

myz@ubuntu:~/work$ sh ecos-install.tcl
eCos installer v2.0.1 starting...
Written and maintained by Jonathan Larmour <[email protected]>
Retrieving installer metadata information...
**************************************************
---------------------------------------------------------
Available distribution sites:
[1]    ftp://mirrors.kernel.org/sources.redhat.com/ecos
[2]    http://mirrors.kernel.org/sources.redhat.com/ecos
[3]    ftp://mirror.aarnet.edu.au/pub/sourceware/ecos
[4]    http://mirror.aarnet.edu.au/pub/sourceware/ecos
[5]    ftp://ftp.mirrorservice.org/sites/sources.redhat.com/pub/ecos
[6]    http://www.mirrorservice.org/sites/sources.redhat.com/pub/ecos
[7]    ftp://gd.tuwien.ac.at/opsys/ecos
[8]    http://gd.tuwien.ac.at/opsys/ecos
[9]    ftp://ftp.funet.fi/pub/mirrors/sources.redhat.com/pub/ecos
[10]    ftp://ftp.gwdg.de/pub/misc/sources.redhat.com/ecos
[11]    http://ftp.gwdg.de/pub/misc/sources.redhat.com/ecos
[12]    ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/sources.redhat.com/ecos
[13]    http://ftp-stud.fht-esslingen.de/pub/Mirrors/sources.redhat.com/ecos
[14]    ftp://bo.mirror.garr.it/mirrors/sourceware.org/ecos
[15]    http://bo.mirror.garr.it/mirrors/sourceware.org/ecos
[16]    ftp://ftp.u-aizu.ac.jp/pub/gnu/cygnus/ecos
[17]    ftp://ftp.chg.ru/pub/sourceware/ecos
[18]    ftp://ftp.sun.ac.za/pub/mirrorsites/sourceware.org/pub/ecos
[19]    http://ftp.sun.ac.za/ftp/pub/mirrorsites/sourceware.org/pub/ecos
[20]    ftp://ftp.twaren.net/Unix/Sourceware/ecos
[21]    http://ftp.twaren.net/Unix/Sourceware/ecos
[22]    ftp://mirror.facebook.com/sourceware/ecos
[23]    http://mirror.facebook.com/sourceware/ecos
[24]    http://sources-redhat.mirrors.airband.net/ecos
[25]    ftp://ecos.sourceware.org/pub/ecos
Please select a distribution site: 18
---------------------------------------------------------
Please select a directory for installation
[Default /home/myz/ecos]:
---------------------------------------------------------
Available prebuilt GNU tools:
[1]    arm-eabi
[2]    arm-elf (old)
[3]    i386-elf
[4]    m68k-elf
[5]    mipsisa32-elf
[6]    powerpc-eabi
[7]    sh-elf
[q]    Finish selecting GNU tools
("*" indicates tools already selected)
Please select GNU tools to download and install: 1
[*]    arm-eabi
[2]    arm-elf (old)
[3]    i386-elf
[4]    m68k-elf
[5]    mipsisa32-elf
[6]    powerpc-eabi
[7]    sh-elf
[q]    Finish selecting GNU tools
("*" indicates tools already selected)
Please select GNU tools to download and install: q
Directory /home/myz/ecos does not exist... creating.
Entering /home/myz/ecos
Retrieving GNU tools for arm-eabi
**************************************************
Retrieving eCos version 3.0
**************************************************
Downloads complete.
If you wish to disconnect from the internet you may do so now.
Unpacking ecoscentric-gnutools-arm-eabi-20081213-sw.i386linux.tar.bz2...
Unpacking ecos-3.0.i386linux.tar.bz2...
Generating /home/myz/ecos/ecosenv.sh
Generating /home/myz/ecos/ecosenv.csh
---------------------------------------------------------
In future, to establish the correct environment for eCos,
run one of the following commands:
   . /home/myz/ecos/ecosenv.sh         (for sh/bash users); or
   source /home/myz/ecos/ecosenv.csh     (for csh/tcsh users)
It is recommended you append these commands to the end of your
shell startup files such as $HOME/.profile or $HOME/.login
---------------------------------------------------------
Installation complete!

4.安装过程中,我选择了(1)arm-eabi 用于ARM (ARM7TDMI, ARM9, XScale)开发。

在我的安装目录~/ecos中,目录和主要文件为:

ecos3.0 ===> ecos3.0源文件

gnutools ===> arm-eabi交叉编译工具

ecosenv.csh ===> csh下环境变量设定脚本

ecosenv.sh ===> bash下环境变量设定脚本

5. 运行环境变量设定脚本文件,使系统可以找到arm-eabi工具:

myz@ubuntu:~/ecos$source ecosenv.sh

检查一下:

myz@ubuntu:~/ecos$echo $PATH

/home/myz/ecos/gnutools/arm-eabi/bin:/home/myz/ecos/ecos-3.0/tools/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:/usr/games:/usr/local/real:.
6. 试用arm-eabi:

新建一个hello.c:

int main()  {  return 0;  }

myz@ubuntu:~/work$arm-eabi-gcc -o hello hello.c

出现如下错误信息:/home/myz/ecos/gnutools/arm- eabi/bin/../lib/gcc/arm-eabi/4.3.2/../../../../arm-eabi/bin/ld: crt0.o: No such file: No such file or directory collect2: ld returned 1 exit status
出了什么事呢?Go google......

Hello World C program using Android Toolchain  

一文中,对用arm-eabi编译andriod代码,做了详细的分析。

参考该文,加上-nostdlib选项:

myz@ubuntu:~/work$arm-eabi-gcc - nostdlib -o hello hello.c

编译有成功,但出现一个warning:

/home/myz/ecos/gnutools/arm-eabi/bin/../lib/gcc/arm-eabi/4.3.2/../../../../arm-eabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 00008000
先放 着,以后解决它。

myz@ubuntu:~/work$file hello

hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV ), statically linked , not stripped
对比一下用arm-linux-3.4.1编译出来的:

myz@ubuntu:~/work$arm-linux-gcc -o hello hello.c

hello: ELF 32-bit LSB executable, ARM, version 1, for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped

最后总结:

安装基本上完成,但没有完全成功,中间出了点warning事件。察觉到arm- eabi 的代码是 statically linked 的,没有调用arm-eabi的库,并且找不 到 _start的符号地址。这个问题,在学习(2)中试着解决。

你可能感兴趣的:(ubuntu 下达建略)