ecos 3.0 編譯
版權宣告:轉載時請以超鏈結形式標明文章初始出處和作者資訊及本聲明
本文參考並依照實際環境修改
http://charliejade.blogbus.com/logs/38830916.html
20091110 初步安裝編譯完成
(系統環境:colinux + Ubuntu 9.04)
我是用colinux建立好網路環境再用PUTTY連過去編譯
底下 紅色字 是我有卡到的地方 藍色字是下的指令
0.編譯之前請先裝 build-essential
不裝的話後面都不能跑的 一開始我就是沒裝 結果一直出現Unable to figure out how to do 64 bit arithmetic 比對之前在別台已經裝好的ecos 才發現 很多lib沒裝到
sudo apt-get install build-essential
1.裝載Tcl譯程式和libstdc++5:
root@colinux:~/work$sudo apt-get install tcl8.5 libstdc++5
2.然后按照ecos官網輔助說明,下載檔案ecos-install.tcl:
任選一個吧
wget --passive-ftp ftp://ftp.csie.nctu.edu.tw/pub/Unix/CYGNUS/ecos/ecos-install.tcl
wget --passive-ftp ftp://ftp.twaren.net/pub/Unix/Sourceware/ecos/ecos-install.tcl
wget --passive-ftp ftp://ftp.cis.nctu.edu.tw/pub/csie/Software/Unix/CYGNUS/ecos/ecos-install.tcl
3.執行這個檔案:
root@colinux:~/work$ sh ecos-install.tcl
eCos installer v2.0.1 starting...
Written and maintained by Jonathan Larmour
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!
如果上面步驟有說PORXY錯誤那就換一個網址重做一次吧
記得如果已經有下檔案了 要先砍掉
4.裝載過程中,我選取了(1)arm-eabi 用于ARM (ARM7TDMI, ARM9, XScale)開發。
在我的裝載目錄/opt/ecos中,目錄和主要檔案為:
ecos3.0 ===> ecos3.0來源檔
gnutools ===> arm-eabi交叉編譯工具
ecosenv.csh ===> csh下環境變數設定程式檔
ecosenv.sh ===> bash下環境變數設定程式檔
5. 執行環境變數設定程式檔檔案,使系統可以找到arm-eabi工具:
root@colinux:/opt/ecos$source ecosenv.sh
檢查一下:
root@colinux:/opt/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:.
環境這樣就大致ok了開始編譯囉
編譯ECOS
基本上是參照:http://mkl-note.blogspot.com/2008/07/ecos-building-note.html
由于他所用的是cvs版的,我用的是三月的ecos3.0發布版本,有些指令和目錄架構不太一樣了。
1. 裝載必須的包檔案(若下一步驟中出現configure: error: unable to locate Tcl configuration file tclConfig.sh錯誤就是沒有裝載必要的包,小心!)
root@colinux:/opt/ecos/ecos3.0$sudo apt-get install tcl tcl-dev automake autoconf2.13 texinfo tk tk-dev
2. 建立一個ecos-host
(詳見README.host和README.txt)
root@colinux:/opt/ecos/ecos3.0$mkdir ecos-host; cd ecos-host
3. 配置一下,注意:在ecos-host目錄下進行,并且根據文件要求,在每次添加新的驅動時必須在頂層configure一下。選項--with-tcl-version=8.4是必須的,否則出現找不到tclConfig.sh錯誤。
(或者參照http://mkl-note.blogspot.com/2008/07/ecos-building-note.html中的:TCL_INC_DIR=/usr/include/tcl8.4 ../configure --host=i686-linux-gnu --with-tcl-version=8.4 我沒有試過。)
root@colinux:/opt/ecos/ecos3.0/ecos-host$../configure --host=i686-linux-gnu --with-tcl-version=8.4
4. make一下
root@colinux:/opt/ecos/ecos3.0/ecos-host$make CFLAGS="-march=i686" CXXFLAGS="-march=i686"
5. install (注意若裝載在預設目錄下要有許可權)
root@colinux:/opt/ecos/ecos3.0/ecos-host$sudo make install
6. 檢視支援的裝置清單,清單太長,在此省略
root@colinux:/opt/ecos/ecos3.0/ecos-host$cd ..
root@colinux:/opt/ecos/ecos-3.0$./ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig list
7. 生成redboot
root@colinux:/opt/ecos/ecos-3.0$ mkdir ecos-build-redboot
root@colinux:/opt/ecos/ecos-3.0$ cd ecos-build-redboot
建立arm9 目標
root@colinux:/opt/ecos/ecos-3.0/ecos-build-redboot$ ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig new excalibur_arm9 redboot
U CYGPKG_HAL_ARM_ARM9_ARM922T, new inferred value 1
U CYGSEM_HAL_USE_ROM_MONITOR, new inferred value 0
U CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK, new inferred value 0
輸入配置檔案
root@colinux:/opt/ecos/ecos-3.0/ecos-build-redboot$ ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig import ../packages/hal/arm/arm9/excalibur/v3_0/misc/redboot_RAM.ecm
建立樹
root@colinux:/opt/ecos/ecos-3.0/ecos-build-redboot$ ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig tree
編譯
root@colinux:/opt/ecos/ecos-3.0/ecos-build-redboot$make
看一下結果檔吧
root@colinux:/opt/ecos/ecos-3.0/ecos-build-redboot$ ls install/bin
redboot.bin redboot.elf redboot.hex redboot.img redboot.srec
我們要的redboot.*就生成了。
8. 生成kernel core
root@colinux:/opt/ecos/ecos-3.0/ecos-build-redboot$ cd ..
root@colinux:/opt/ecos/ecos-3.0$ mkdir ecos-build-kernel;cd ecos-build-kernel
root@colinux:/opt/ecos/ecos-3.0/ecos-build-kernel$ ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig new excalibur_arm9 kernel
U CYGPKG_HAL_ARM_ARM9_ARM922T, new inferred value 1
root@colinux:/opt/ecos/ecos-3.0/ecos-build-kernel$ ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig resolve
建立樹
root@colinux:/opt/ecos/ecos-3.0/ecos-build-kernel$ ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig tree
編譯
root@colinux:/opt/ecos/ecos-3.0/ecos-build-kernel$ make
看一下結果檔吧
root@colinux:/opt/ecos/ecos-3.0/ecos-build-kernel$ ls install/lib/
extras.o libextras.a libtarget.a target.ld vectors.o
root@colinux:/opt/ecos/ecos-3.0/ecos-build-kernel$ ls /opt/ecos/ecos-3.0/packages/hal/arm/arch/v3_0/src/
arm.ld context.S hal_mk_defs.c redboot_linux_exec.c
arm_stub.c hal_misc.c hal_syscall.c vectors.S
9. 生成網路層
root@colinux:/opt/ecos/ecos-3.0/ecos-build-kernel$ cd ..
root@colinux:/opt/ecos/ecos-3.0$ mkdir ecos-build-net; cd ecos-build-net
root@colinux:/opt/ecos/ecos-3.0/ecos-build-net$ ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig new excalibur_arm9 net
U CYGPKG_HAL_ARM_ARM9_ARM922T, new inferred value 1
U CYGBLD_ISO_STRUCTTIMEVAL_HEADER, new inferred value
U CYGBLD_ISO_FNMATCH_HEADER, new inferred value
檢查衝突
root@colinux:/opt/ecos/ecos-3.0/ecos-build-net$ ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig resolve
建立樹
root@colinux:/opt/ecos/ecos-3.0/ecos-build-net$ ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig tree
編譯
root@colinux:/opt/ecos/ecos-3.0/ecos-build-net$ make
看一下結果檔吧
root@colinux:/opt/ecos/ecos-3.0/ecos-build-net$ ls install/lib
extras.o libextras.a libtarget.a target.ld vectors.o
10. 生成eCos hello程式
root@colinux:/opt/ecos/ecos-3.0/ecos-build-net$ cd ..
root@colinux:/opt/ecos/ecos-3.0$ mkdir hello-app; cd hello-app
複製例子程式到目前目錄下
root@colinux:/opt/ecos/ecos-3.0/hello-app$ cp ../examples/hello.c ../examples/build_Makefile ../examples/build_Make.params .
使檔案有執行許可權
root@colinux:/opt/ecos/ecos-3.0/hello-app$ chmod +x build_Makefile build_Make.params
root@colinux:/opt/ecos/ecos-3.0/hello-app$ SRCS=hello.c DST=hello ./build_Makefile ../ecos-build-net
編譯
root@colinux:/opt/ecos/ecos-3.0/hello-app$ make
arm-eabi-gcc -c -finline-limit=7000 -Wall -Wpointer-arith -Wstrict-prototypes -Wundef -Wno-write-strings -mno-thumb-interwork -mcpu=arm9 -g -O2 -ffunction-sections -fdata-sections -fno-exceptions -I/home/myz/ecos/ecos-3.0/ecos-build-net/install/include hello.c
arm-eabi-gcc -mno-thumb-interwork -mcpu=arm9 --no-target-default-spec -Wl,--gc-sections -Wl,-static -g -O2 -nostdlib -L/home/myz/ecos/ecos-3.0/ecos-build-net/install/lib -Ttarget.ld hello.o -o hello
看一下結果檔吧
root@colinux:/opt/ecos/ecos-3.0/hello-app$ ls
build_Makefile build_Make.params hello hello.c hello.o Makefile Make.params
用objcopy轉換格式
root@colinux:/opt/ecos/ecos-3.0/hello-app$ arm-eabi-objcopy -O srec hello hello.srec -v
copy from `hello'
[elf32-littlearm] to `hello.srec' [srec]
root@colinux:/opt/ecos/ecos-3.0/hello-app$ arm-eabi-objcopy -O binary hello hello.bin -v
copy from `hello' [elf32-littlearm] to `hello.bin' [binary]
root@colinux:/opt/ecos/ecos-3.0/hello-app$ ls
build_Makefile hello hello.c hello.srec Make.params
build_Make.params hello.bin hello.o Makefile
總結:
這裡大致完就完成了
基本上上面有用到 ../ecos-host/tools/src/tools/configtool/standalone/common/ecosconfig 這個的 直接打 ecosconfig 應該可以直接用
ecosconfig 其實就是一個智能化的建立工具,利用它可以生成我們想要的工程,修改配置,加減包,生成Makefile,最后生成之后就可以用make直接呼叫Makefile,產生目標檔案。
ecosconfig是一個指令行工具,其實eCos也提供了一個GUI的工具configtool,和ecosconfig 都位于tools/bin目錄下。
因為我是用colinux 所以pc端須在裝xming 才能開囉(請看續集)
留言列表