制作S3C6410 的交叉编译链(arm-linux-gcc 4.6.0)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhanglianpin/article/details/22031267

最近在做一些嵌入式的软件开发工作,在Linux下的交叉编译链一直都是使用别人编译好的交叉编译器。想自己制作一个属于自己的交叉编译器,了解一下构建嵌入式系统开发工具的一些方法。

下面说一下大致的方法和步骤。

从gnu网站上下载所需要的源码包,然后进行配置,编译,链接,安装。

还有就是使用第三方用于编译生成交叉编译链的管理工具:crosstool-ng-1.19.0(目前为最新版本)官方网站:http://www.crosstool-ng.org/

所需要的源码包有:GNU Binunitls,GCC, Glibc, Linux内核,gmp,mpfr,等                            所需的软件包大都可以从中国科技大学的镜像服务器上下载:http://oss.ustc.edu.cn

GNU Binunitls是一组二进制工具集。这个工具需要利用i386  linux本身的编译器进行编译,且在i386 linux上运行。编译S3C6410交叉编译链的时候要用到这些工具。

GNU Binunitls主要包括以下工具:

as                                     assembler popularly known as GAS (Gnu ASsembler)
ld                                     linker
gprof                            profiler
addr2line                    convert address to file and line
ar                                     create, modify, and extract from archives
c++filt                             demangling filter for C++ symbols
dlltool                             creation of Windows dynamic-link libraries
gold                             alternative linker
nlmconv                            object file conversion to a NetWare Loadable Module
nm                                    list symbols in object files
objcopy                            copy object files, possibly making changes
objdump                  dump information about object files
ranlib                          generate indexes for archives
readelf                         display content of ELF files
size                                 list total and section sizes
strings                         list printable strings
strip                         remove symbols from an object file
windmc                         generates Windows message resources
windres                          compiler for Windows resource files

其中GCC需要编译两次,第一次编译是生成支持c语言的交叉编译器,目的是用它来交叉编译后面的Glibc库。因为生成完整的GCC交叉编译器需要Glibc库的支持,但是现在还没有用于ARM平台的Glibc库,所以我们先生成一个简化的GCC,用它来编译Glibc,有了Glibc后再重新编译GCC生成完整的ARM-GCC。所以第一次编译GCC的配置选项会禁止很多功能。另外,因为要支持软浮点(Soft Float),GCC需要同时编译GMP和MPFR。GMP是实现任意精度算术运算的软件包,可以完成有符号整数、有理数和浮点数的运算。只要计算机内存的满足需要,GMP的运算精度没有任何限制。MPFR是一个用于高精度浮点运算的C库。


Glibc也就是C库函数,包括分配内存、搜索目录、打开和关闭文件、读和写文件、字符串操作、模式匹配、代数运算等。 libc-ports软件包的作用是移植,把Glibc库移植到ARM平台时需要它,解压后拷贝到glibc目录,并命名为 ports即可。

第二次编译gcc,这次是编译完整的gcc了。

为什么要编译两次GCC

第一遍只编译一个支持c的gcc,原因是要编译出一个支持交叉的c++,必须有一个编译好的用于目标体系平台的glibc,而不是只有glibc的头文件就可以的,好在编译glibc有c支持就够了,所以编译glibc也成了第一遍的gcc唯一的理由和作用。工具链中gcc的第一次和第二次编译都是由主系统的gcc和binutils来完成的(之前没有提及binutils,只是为了理解方便,但实际上编译后是少不了链接过程的,这个过程是要binutils来完成的)。到目前为止只有在编译glibc的时候用到了交叉版本的binutils,其它部分的链接都是由主系统的binutils来完成的。

关于crosstool-ng-1.19.0

crosstool-ng-1.19.0是一个帮助你自动下载源码,提供界面菜单配置,并生成完整makefile的工具。

crosstool-ng-1.19.0参考资料:http://www.crifan.com/files/doc/docbook/crosstool_ng/release/html/crosstool_ng.html


下面说一下我的机器的具体编译步骤。

我是利用crosstool-ng-1.19.0工具编译的gcc4.6.0的交叉编译工具。

编译平台:ubuntu12.04 

编译时的主目录,/home/zhanglianpin

所需具体源码列表:


1,创建一些目录,以备后面编译交叉编译链使用。

在主目录下创建以下目录,

crosstool-ng-1.19.0_build    (用于保存使用crosstool-ng-1.19.0这个工具时所下载的源码文件,解压后的源码,以及编译日志等

crosstool-ng-1.19.0_install    (用于安装crosstool-ng-1.19.0这个工具的目录)

S3C6410/src                       (用于保存下载的源码)

S3C5410/toolchain              (用于保存编译好的交叉编译链)

2,下载crosstool-ng-1.19.0

打开官网(http://www.crosstool-ng.org/),最新版本为crosstool-ng-1.19.0,点击下载,此版本没有补丁文件,如果你所下载的版本有patch,则需要下载下来,使用之前,按照说明先打上补丁。

3,安装crosstool-ng-1.19.0

tag:因为crosstool-ng-1.19.0不允许使用root权限运行,所以,创建目录及安装,请使用非root用户。

将下载的crosstool-ng-1.19.0.tar.bz2复制到主目录,/home/zhanglianpin,然后解压

#tar -zxf  crosstool-ng-1.19.0.tar.bz2 

然后 解压完后主目录下多出一个crosstool-ng-1.19.0的文件夹

#cd  crosstool-ng-1.19.0

#./configure --prefix=/home/zhanglianpin/crosstool-ng-1.19.0_install     //配置crosstool-ng  ,此软件将安装到crosstool-ng-1.19.0_install 的目录下

配置时若提示错误,请参见附录1:使用crosstool-ng 缺少的开发工具。

#sudo make                      //编译crosstool-ng

#sudo make install            //安装crosstool-ng

# echo "PATH=$PATH:/home/zhanglianpin/crosstool-ng-1.19.0_install /bin" >> ~/.bashrc  //为后面调用ct-ng命令增加环境变量
# source ~/.bashrc

# ct-ng help

hens@hens-desktop:/work/tools/crosstool-ng-1.9.3$ ct-ng help

This is crosstool-NG version 1.19.0
Copyright (C) 2008  Yann E. MORIN <yann.morin.1998@free.fr>
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
See below for a list of available actions, listed by category:


Configuration actions:
  menuconfig         - Update current config using a menu based program
  oldconfig          - Update current config using a provided .config as base
  extractconfig      - Extract to stdout the configuration items from a build.log file piped to stdin
  savedefconfig      - Save current config as a mini-defconfig to ${DEFCONFIG}
  defconfig          - Update config from a mini-defconfig ${DEFCONFIG} (default: ${DEFCONFIG}=./defconfig)
  saveconfig         - Save current config as a preconfigured target
  show-tuple         - Print the tuple of the currently configured toolchain
Preconfigured toolchains (#: force number of // jobs):
  list-samples       - prints the list of all samples (for scripting)
  show-<sample>      - show a brief overview of <sample> (list with list-samples)
  <sample>           - preconfigure crosstool-NG with <sample> (list with list-samples)
  build-all[.#]      - Build *all* samples (list with list-samples) and installin ${CT_PREFIX} (which you must set)
Build actions (#: force number of // jobs):
  build[.#]          - Build the currently configured toolchain
  list-steps         - List all build steps
Clean actions:
  clean              - Remove generated files
  distclean          - Remove generated files, configuration and build directories
Distribution actions:
  wiki-samples       - Print a DokuWiki table of samples
  updatetools        - Update the config tools
  tarball            - Build a tarball of the configured toolchain

Environment variables (see /home/zhanglianpin/crosstool-ng/crosstool-ng-1.19.0_install/share/doc/crosstool-ng/ct-ng.1.19.0/0 - Table of content.txt):
  STOP=step          - Stop the build just after this step (list with list-steps)
  RESTART=step       - Restart the build just before this step (list with list-steps)
  CT_PREFIX=dir      - install samples in dir (see action "build-all", above).
  V=0|1|2            - 0 => show only human-readable messages (default)
                       1 => show only the commands being executed
                       2 => show both
Use action "menuconfig" to configure your toolchain
Use action "build" to build your toolchain
Use action "version" to see the version
See "man 1 ct-ng" for some help as well

crosstool-ng安装成功.

4,使用crosstool-ng修改配置,用于生成最后的Makefile文件。

#cd  /home/zhanglianpin/crosstool-ng-1.19.0_build  (以后的操作都在此目录下进行,配置文件,Makefile 下载下来的源码,解压出来的源文件,编译log都放在此目录)


#ct-ng list-samples 

ct-ng  list-samples


Status  Sample name
  LN    config
  MKDIR config.gen
  IN    config.gen/arch.in
  IN    config.gen/kernel.in
  IN    config.gen/cc.in
  IN    config.gen/binutils.in
  IN    config.gen/libc.in
  IN    config.gen/debug.in
[G.X]   alphaev56-unknown-linux-gnu
[G.X]   alphaev67-unknown-linux-gnu
[G.X]   arm-bare_newlib_cortex_m3_nommu-eabi
[G.X]   arm-cortex_a15-linux-gnueabi
[G..]    arm-cortex_a8-linux-gnueabi
[G.X]   arm-cortexa9_neon-linux-gnueabihf
[G..]    arm-davinci-linux-gnueabi
[G..]    armeb-unknown-eabi
[G.X]   armeb-unknown-linux-gnueabi
[G.X]   armeb-unknown-linux-uclibcgnueabi
[G..]    arm-unknown-eabi
[G..]    arm-unknown-linux-gnueabi
[G.X]   arm-unknown-linux-uclibcgnueabi
[G.X]   armv6-rpi-linux-gnueabi
[G..]    avr32-unknown-none
[G..]    bfin-unknown-linux-uclibc
[G..]    i586-geode-linux-uclibc
[G.X]   i586-mingw32msvc,i686-none-linux-gnu
[G.X]   i686-nptl-linux-gnu
[G.X]   i686-unknown-mingw32
[G.X]   m68k-unknown-elf
[G.X]   m68k-unknown-uclinux-uclibc
[G.X]   mips64el-n32-linux-uclibc
[G.X]   mips64el-n64-linux-uclibc
[G.X]   mips-ar2315-linux-gnu
[G..]    mipsel-sde-elf
[G..]    mipsel-unknown-linux-gnu
[G.X]   mips-malta-linux-gnu
[G..]    mips-unknown-elf
[G.X]   mips-unknown-linux-uclibc
[G..]    powerpc-405-linux-gnu
[G.X]   powerpc64-unknown-linux-gnu
[G..]    powerpc-860-linux-gnu
[G.X]   powerpc-e300c3-linux-gnu
[G.X]   powerpc-e500v2-linux-gnuspe
[G..]    powerpc-unknown-linux-gnu
[G..]    powerpc-unknown-linux-uclibc
[G..]    powerpc-unknown_nofpu-linux-gnu
[G.X]   s390-ibm-linux-gnu
[G.X]   s390x-ibm-linux-gnu
[G..]    sh4-unknown-linux-gnu
[G..]    x86_64-unknown-linux-gnu
[G..]    x86_64-unknown-linux-uclibc
[G.X]   x86_64-unknown-mingw32
 L (Local)       : sample was found in current directory
 G (Global)      : sample was installed with crosstool-NG
 X (EXPERIMENTAL): sample may use EXPERIMENTAL features
 B (BROKEN)      : sample is currently broken

以上列出了所有的配置samples,我们编译的是S3C6410的交叉编译链(一般还用于嵌入式linux的开发),所以我们选择arm-unknown-linux-gnueabi这个配置文件,在这个配置文件基础上再增加自己的配置。

#ct-ng  arm-unknown-linux-gnueabi 

下面就可以直接依据此配置文件来配置自己的交叉编译链属性了。

#ct-ng menuconfig

接着会打开配置界面菜单。


S3C6410的CPU架构 为ARMV6的,对其进行配置。此菜单的操作方式很简单,选中条目,Enter键进入条目,若是需要填写的条目,按enter键进入编辑。若是需要选择的条目,按空格键选择或者取消选择。(有*号表示选择上,没有*号表示没有选择上)。 使用tab键来选择 <select>  <exit> <help> .

 1)、已下载源码包存放路径和交叉编译器的安装路径。
Paths and misc options  --->Local tarballs directory  
  (/home/zhanglianpin/S3C6410/src ) Local tarballs directory   保存源码包路径

Paths and misc options  --->Prefix directory   
  (home/zhanglianpin/S3C6410/toolchain/${CT_TARGET}) Prefix directory  交叉编译器的安装路径

这两个选项请依据你的实际情况来修改。

 Paths and misc options  --->[*] Debug crosstool-NG                                           
    [ ]   Pause between every steps (NEW)                            
   [ *]   Save intermediate steps (NEW)                             
   [ ]   Interactive shell on failed commands (NEW) 

选择Debug crosstool-NG  ,会多出一个子菜单,选中Save intermediate steps (NEW)   ,此选项是提供从上一步错误的地方继续编译,而不是从头编译,这样可以节约大量时间。具体使用方法见附录二:从出错的那一步恢复重新继续编译方法

Paths and misc options  --->(2) Number of parallel jobs (NEW)

此选项为增加编译时的并行进程数,以增加运行效率,加快编译。

我使用虚拟机编译,我选择的是2.此选项根据自己机器情况选择。

Paths and misc options的其他选项默认。

2)Target options --->
 *** Target optimisations ***   

这个选项是针对ARM11处理器的,是核心配置,请谨慎配置。具体配置含义参考,附录三:CPU参数参数含义

Target options --->Architecture level 
写上:armv6

Target options --->Emit assembly for CPU
写上:arm1176jzf-s

Target options --->Tune for CPU (NEW) 

写上:arm1176jzf-s

3)一些个性化的修改(可以不修改)
Toolchain options  --->
       *** Tuple completion and aliasing ***  
       (S3C6410) Tuple's vendor string 
这样产生的编译器前缀就是:arm-S3C6410-linux-gnueabi-

4) Operating System  --->

Linux kernel version (3.10.2)  --->

选择你编译所需要的linux内核版本号。

5)Binary utilities  ---> 

配置GNU Binunitls版本及其他选项。

6)  C compiler (gcc)  --->                                       
    [ ] Show Linaro versions (NEW)                                 
       gcc version (4.8.1)  --->                                   
        *** Additional supported languages: ***               
    [ *] C++                                                      
    [ ] Fortran (NEW)                                       
    [ ] Java (NEW)      

选择gcc版本,并设置交叉编译链支持的语言,这里只设置成支持c、c++      

7) C library (eglibc)  --->                      

 eglibc version (2_17)  --->  

   [*] Force unwind support (READ HELP!) (NEW)

选择glibc版本,并把Force unwind support (READ HELP!) (NEW)选项选中。否则,编译glibc时出错。

8) Debug facilities  --->  

其子选项都选上,都是一些调试选项。

9) Companion libraries  --->    

     GMP version (5.1.1)  --->                                    
      MPFR version (3.1.2)  --->                                   
      ISL version (0.11.1)  --->                                  
      CLooG version (0.18.0)  --->                                
      MPC version (1.0.1)  --->                                    
        *** Companion libraries common options ***                     
    [ *] Check the companion libraries builds (!!! READ HELP!!!) (NEW)

选择其他相关库的版本号,并将Check the companion libraries builds (!!! READ HELP!!!) (NEW)选中,检查 companion libraries的版本信息。

最后保存配置。进行下一步编译。

tag:crosstool-ng 会根据你所设置的源码版本下载相应的源码包,如果你想加速编译过程,你可以根据配置的源码包版本自行下载,然后放到你指定的源码存放路径。(此编译环境为/home/zhanglianpin/S3C6410/src )。

#ct-ng build 

[INFO ]  Performing some trivial sanity checks
[INFO ]  Build started 20120524.143846
[INFO ]  Building environment variables
[EXTRA]  Preparing working directories
[EXTRA]  Installing user-supplied crosstool-NG configuration
[EXTRA]  =================================================================
[EXTRA]  Dumping internal crosstool-NG configuration
[EXTRA]    Building a toolchain for:
[EXTRA]      build  = i686-pc-linux-gnu
[EXTRA]      host   = i686-pc-linux-gnu
[EXTRA]      target = arm-S3C6410-linux-gnueabi
[EXTRA]  Dumping internal crosstool-NG configuration: done in 0.20s (at 00:04)
[INFO ]  =================================================================
[INFO ]  Retrieving needed toolchain components' tarballs
[EXTRA]    Retrieving 'ncurses-5.7'
[EXTRA]    Saving 'ncurses-5.7.tar.gz' to local storage
[INFO ]  Retrieving needed toolchain components' tarballs: done in 22.27s (at 00:26)
[INFO ]  =================================================================
[INFO ]  Extracting and patching toolchain components
[EXTRA]    Extracting 'linux-2.6.39.2'
[EXTRA]    Patching 'linux-2.6.39.2'
[EXTRA]    Extracting 'gmp-4.3.2'
[EXTRA]    Patching 'gmp-4.3.2'
[EXTRA]    Extracting 'mpfr-2.4.2'
[EXTRA]    Patching 'mpfr-2.4.2'
[EXTRA]    Extracting 'libelf-0.8.13'
[EXTRA]    Patching 'libelf-0.8.13'
[EXTRA]    Extracting 'binutils-2.19.1'
[EXTRA]    Patching 'binutils-2.19.1'
[EXTRA]    Extracting 'gcc-4.6.0'
[EXTRA]    Patching 'gcc-4.6.0'
[EXTRA]    Extracting 'glibc-2.9'
[EXTRA]    Patching 'glibc-2.9'
[EXTRA]    Extracting 'glibc-ports-2.9'
[EXTRA]    Patching 'glibc-ports-2.9'
[EXTRA]    Extracting 'dmalloc-5.5.2'
[EXTRA]    Patching 'dmalloc-5.5.2'
[EXTRA]    Extracting 'duma_2_5_15'
[EXTRA]    Patching 'duma-2_5_15'
[EXTRA]    Extracting 'gdb-6.8a'
[EXTRA]    Patching 'gdb-6.8a'
[EXTRA]    Extracting 'ncurses-5.9'
[EXTRA]    Patching 'ncurses-5.9'
[EXTRA]    Extracting 'expat-2.1.0'
[EXTRA]    Patching 'expat-2.1.0'
[EXTRA]    Extracting 'ltrace-0.5.3'
[EXTRA]    Patching 'ltrace-0.5.3'
[EXTRA]    Extracting 'strace-4.5.19'
[EXTRA]    Patching 'strace-4.5.19'
[INFO ]  Extracting and patching toolchain components: done in 211.31s (at 03:58)
[INFO ]  =================================================================
[INFO ]  Installing kernel headers
[EXTRA]    Installing kernel headers
[EXTRA]    Checking installed headers
[INFO ]  Installing kernel headers: done in 11.32s (at 04:09)
[INFO ]  =================================================================
[INFO ]  Installing GMP
[EXTRA]    Configuring GMP
[EXTRA]    Building GMP
[EXTRA]    Installing GMP
[INFO ]  Installing GMP: done in 283.14s (at 08:52)
[INFO ]  =================================================================
[INFO ]  Installing MPFR
[EXTRA]    Configuring MPFR
[EXTRA]    Building MPFR
[EXTRA]    Installing MPFR
[INFO ]  Installing MPFR: done in 52.61s (at 09:45)
[INFO ]  =================================================================
[INFO ]  Installing binutils
[EXTRA]    Configuring binutils
[EXTRA]    Building binutils
[EXTRA]    Installing binutils
[INFO ]  Installing binutils: done in 178.97s (at 12:44)
[INFO ]  =================================================================
[INFO ]  Installing static core C compiler
[EXTRA]    Configuring static core C compiler
[EXTRA]    Building static core C compiler
[EXTRA]    Installing static core C compiler
[INFO ]  Installing static core C compiler: done in 336.89s (at 18:21)
[INFO ]  =================================================================
[INFO ]  Installing C library headers
[EXTRA]    Configuring C library
[EXTRA]    Installing C library headers
[INFO ]  Installing C library headers: done in 45.14s (at 19:06)
[INFO ]  =================================================================
[INFO ]  Installing C library start files
[EXTRA]    Configuring C library
[WARN ]    Removing "-pipe" for use with glibc>=2.6
[EXTRA]    Building C library start files
[EXTRA]    Installing C library start files
[INFO ]  Installing C library start files: done in 35.80s (at 19:42)
[INFO ]  =================================================================
[INFO ]  Installing shared core C compiler
[EXTRA]    Configuring shared core C compiler
[EXTRA]    Building shared core C compiler
[EXTRA]    Installing shared core C compiler
[INFO ]  Installing shared core C compiler: done in 373.23s (at 25:55)
[INFO ]  =================================================================
[INFO ]  Installing C library
[EXTRA]    Configuring C library
[WARN ]    Removing "-pipe" for use with glibc>=2.6
[EXTRA]    Building C library
[EXTRA]    Installing C library
[EXTRA]    Fixing C library linker scripts
[INFO ]  Installing C library: done in 1118.93s (at 44:34)
[INFO ]  =================================================================
[INFO ]  Installing final compiler
[EXTRA]    Configuring final compiler
[EXTRA]    Building final compiler
[EXTRA]    Installing final compiler
[INFO ]  Installing final compiler: done in 914.62s (at 59:49)
[INFO ]  =================================================================
[INFO ]  Installing libelf for the target
[EXTRA]    Configuring libelf
[EXTRA]    Building libelf
[EXTRA]    Installing libelf
[INFO ]  Installing libelf for the target: done in 14.22s (at 60:03)
[INFO ]  =================================================================
[INFO ]  Installing binutils for target
[EXTRA]    Configuring binutils for target
[EXTRA]    Building binutils' libraries (libiberty bfd) for target
[EXTRA]    Installing binutils' libraries (libiberty bfd) for target
[INFO ]  Installing binutils for target: done in 169.56s (at 62:53)
[INFO ]  =================================================================
[INFO ]  Installing dmalloc
[EXTRA]    Configuring dmalloc
[EXTRA]    Building dmalloc
[EXTRA]    Installing dmalloc
[INFO ]  Installing dmalloc: done in 17.31s (at 63:10)
[INFO ]  =================================================================
[INFO ]  Installing D.U.M.A.
[EXTRA]    Copying sources
[EXTRA]    Building libraries 'libduma.a libduma.so.0.0.0'
[EXTRA]    Installing libraries 'libduma.a libduma.so.0.0.0'
[EXTRA]    Installing shared library link
[EXTRA]    Installing wrapper script
[INFO ]  Installing D.U.M.A.: done in 2.73s (at 63:13)
[INFO ]  =================================================================
[INFO ]  Installing cross-gdb
[EXTRA]    Configuring cross-gdb
[EXTRA]    Building cross-gdb
[EXTRA]    Installing cross-gdb
[INFO ]  Installing cross-gdb: done in 324.74s (at 68:38)
[INFO ]  =================================================================
[INFO ]  Installing native gdb
[EXTRA]    Building static target ncurses
[EXTRA]    Building static target expat
[EXTRA]    Configuring native gdb
[EXTRA]    Building native gdb
[EXTRA]    Installing native gdb
[EXTRA]    Cleaning up ncurses
[INFO ]  Installing native gdb: done in 521.52s (at 77:19)
[INFO ]  =================================================================
[INFO ]  Installing gdbserver
[EXTRA]    Configuring gdbserver
[EXTRA]    Building gdbserver
[EXTRA]    Installing gdbserver
[INFO ]  Installing gdbserver: done in 14.75s (at 77:34)
[INFO ]  =================================================================
[INFO ]  Installing ltrace
[EXTRA]    Copying sources to build dir
[EXTRA]    Configuring ltrace
[EXTRA]    Building ltrace
[EXTRA]    Installing ltrace
[INFO ]  Installing ltrace: done in 5.92s (at 77:40)
[INFO ]  =================================================================
[INFO ]  Installing strace
[EXTRA]    Configuring strace
[EXTRA]    Building strace
[EXTRA]    Installing strace
[INFO ]  Installing strace: done in 24.17s (at 78:04)
[INFO ]  =================================================================
[INFO ]  Cleaning-up the toolchain's directory
[INFO ]    Stripping all toolchain executables
[EXTRA]    Installing the populate helper
[EXTRA]    Installing a cross-ldd helper
[EXTRA]    Creating toolchain aliases
[EXTRA]    Removing access to the build system tools
[INFO ]  Cleaning-up the toolchain's directory: done in 2.28s (at 78:07)
[INFO ]  Build completed at 20120524.155653
[INFO ]  (elapsed: 78:06.56)
[INFO ]  Finishing installation (may take a few seconds)...

编译成功。

#cd /home/zhanglianpin/S3C6410/toolchain/bin

#ls

arm-linux-as                            arm-s3c6410-linux-gnueabi-gcov
arm-linux-c++                           arm-s3c6410-linux-gnueabi-gdb
arm-linux-gcc                           arm-s3c6410-linux-gnueabi-gdbtui
arm-linux-gdb                           arm-s3c6410-linux-gnueabi-gprof
arm-linux-ld                            arm-s3c6410-linux-gnueabi-ld
arm-s3c6410-linux-gnueabi-addr2line     arm-s3c6410-linux-gnueabi-ld.bfd
arm-s3c6410-linux-gnueabi-ar            arm-s3c6410-linux-gnueabi-ldd
arm-s3c6410-linux-gnueabi-as            arm-s3c6410-linux-gnueabi-nm
arm-s3c6410-linux-gnueabi-c++           arm-s3c6410-linux-gnueabi-objcopy
arm-s3c6410-linux-gnueabi-cc            arm-s3c6410-linux-gnueabi-objdump
arm-s3c6410-linux-gnueabi-c++filt       arm-s3c6410-linux-gnueabi-populate
arm-s3c6410-linux-gnueabi-cpp           arm-s3c6410-linux-gnueabi-ranlib
arm-s3c6410-linux-gnueabi-ct-ng.config  arm-s3c6410-linux-gnueabi-readelf
arm-s3c6410-linux-gnueabi-elfedit       arm-s3c6410-linux-gnueabi-size
arm-s3c6410-linux-gnueabi-g++           arm-s3c6410-linux-gnueabi-strings
arm-s3c6410-linux-gnueabi-gcc           arm-s3c6410-linux-gnueabi-strip
arm-s3c6410-linux-gnueabi-gcc-4.6.0

5,建立一些软链接,建立环境变量。

1)sudo vim  /etc/profile,在其中文件的末尾添加这样一行:PATH=$PATH:/home/zhanglianpin/S3C6410/toolchain/bin,其实是我的工具的路径,可以根据实际需要来设定。

2)  source /etc/profile   使修改生效,不用重新登陆。

3)  arm-hens-linux-gnueabi-gcc -v  就会有如下的信息

Using built-in specs.
COLLECT_GCC=./arm-linux-gcc
COLLECT_LTO_WRAPPER=/opt/S3C6410/arm-s3c6410-linux-gnueabi/bin/../libexec/gcc/arm-s3c6410-linux-gnueabi/4.6.0/lto-wrapper
Target: arm-s3c6410-linux-gnueabi
Configured with: /home/jihai/crosstool-ng-1.19.0_build/.build/src/gcc-4.6.0/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-s3c6410-linux-gnueabi --prefix=/home/jihai/crosstools/S3C6410/arm-s3c6410-linux-gnueabi --with-sysroot=/home/jihai/crosstools/S3C6410/arm-s3c6410-linux-gnueabi/arm-s3c6410-linux-gnueabi/sysroot --enable-languages=c,c++ --with-arch=armv6 --with-cpu=arm1176jzf-s --with-tune=arm1176jzf-s --with-float=hard --with-pkgversion='crosstool-NG 1.19.0' --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/home/jihai/crosstool-ng-1.19.0_build/.build/arm-s3c6410-linux-gnueabi/buildtools --with-mpfr=/home/jihai/crosstool-ng-1.19.0_build/.build/arm-s3c6410-linux-gnueabi/buildtools --with-mpc=/home/jihai/crosstool-ng-1.19.0_build/.build/arm-s3c6410-linux-gnueabi/buildtools --with-ppl=no --with-isl=no --with-cloog=no --with-libelf=no --enable-threads=posix --enable-target-optspace --disable-nls --with-system-zlib --disable-multilib --with-local-prefix=/home/jihai/crosstools/S3C6410/arm-s3c6410-linux-gnueabi/arm-s3c6410-linux-gnueabi/sysroot --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.6.0 (crosstool-NG 1.19.0) 



经验总结:

1,编译不一定一次就成功,除非你对使用的工具和交叉编译链的制作非常了解。当出现错误时,不要放弃,从网上查找资料,分析出出错的原因并修复。

2,要注意理清你所使用的工具和所有源码的关系,以及编译交叉编译链的大致步骤和策略,做一个整体的了解。以积累经验,用于制作其他嵌入式开发工具。





附录一:使用crosstool-ng 缺少的开发工具

configure: error: missing required tool: bison

在Ubuntu下,解决办法是:

sudo apt-get install bison

configure: error: missing required tool: flex

在Ubuntu下,解决办法是:

sudo apt-get install flex

configure: error: missing required tool: gperf

在Ubuntu下,解决办法是:

sudo apt-get install gperf
configure: error: missing required tool: makeinfo

在Ubuntu下,解决办法是:

sudo apt-get install texinfo

configure: error: could not find GNU awk

在Ubuntu下,解决办法是:

sudo apt-get install gawk

configure: error: could not find GNU libtool >= 1.5.26

在Ubuntu下,解决办法是:

sudo apt-get install libtool

configure: error: could not find GNU automake >= 1.10

在Ubuntu下,解决办法是:

sudo apt-get install automake

configure: error: could not find curses header, required for the kconfig frontends

在Ubuntu下,解决办法是:

sudo apt-get install libncurses5-dev

附录二:从出错的那一步恢复重新继续编译方法

=================================================================
[INFO ]  Installing MPC for host
[EXTRA]    Configuring MPC
[EXTRA]    Building MPC
[EXTRA]    Installing MPC
[INFO ]  Installing MPC for host: done in 182.22s (at 27:10)
[EXTRA]  Saving state to restart at step 'binutils_for_host'...
[INFO ] 
 =================================================================
[INFO ]  Installing binutils for host
[EXTRA]    Configuring binutils
[ERROR]    configure: error: cannot create configure.lineno; rerun with a POSIX shell
[ERROR]
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing binutils for host'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_binutils_backend[scripts/build/binutils/binutils.sh@205]
[ERROR]  >>        called from: do_binutils_for_host[scripts/build/binutils/binutils.sh@92]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632


修复错误后,接着上次编译的结果继续编译。

#ct-ng binutils_for_host(后面加个“+”号表示恢复上次编译环境)

附录三:CPU参数参数含义

以上这几个参数是如何得出的可以参考gcc的man手册,你可以在你下载的gcc-4.3.2.tar.bz2解压后找到,她的位置是gcc-4.3.2/gcc/doc/gcc.1。打开方式:

man ./gcc.1

你可以在其中找到:

......
 ARM Options
......
-mcpu=name   (
Emit assembly for CPU)
           This specifies the name of the target ARM processor. GCC uses this
           name to determine what kind of instructions it can emit when gener‐
           ating assembly code. Permissible names are: arm2, arm250, arm3,
           arm6, arm60, arm600, arm610, arm620, arm7, arm7m, arm7d, arm7dm,
           arm7di, arm7dmi, arm70, arm700, arm700i, arm710, arm710c, arm7100,
           arm7500, arm7500fe, arm7tdmi, arm7tdmi-s, arm8, strongarm, stron‐
           garm110, strongarm1100, arm8, arm810, arm9, arm9e, arm920, arm920t,
           arm922t, arm946e-s, arm966e-s, arm968e-s, arm926ej-s, arm940t,
           arm9tdmi, arm10tdmi, arm1020t, arm1026ej-s, arm10e, arm1020e,
           arm1022e, arm1136j-s, arm1136jf-s, mpcore, mpcorenovfp,
           arm1156t2-s, arm1176jz-s, arm1176jzf-s, cortex-a8, cortex-r4, cor‐
           tex-m3, xscale, iwmmxt, ep9312.

       -mtune=name   
(Tune for CPU)
           This option is very similar to the -mcpu= option, except that
           instead of specifying the actual target processor type, and hence
           restricting which instructions can be used, it specifies that GCC
           should tune the performance of the code as if the target were of
           the type specified in this option, but still choosing the instruc‐
           tions that it will generate based on the cpu specified by a -mcpu=
           option. For some ARM implementations better performance can be
           obtained by using this option.

       -march=name  
(Architecture level) 
           This specifies the name of the target ARM architecture. GCC uses
           this name to determine what kind of instructions it can emit when
           generating assembly code. This option can be used in conjunction
           with or instead of the -mcpu= option. Permissible names are:
           armv2, armv2a, armv3, armv3m, armv4, armv4t, armv5, armv5t,
           armv5te, armv6, armv6j, armv6t2, armv6z, armv6zk, armv7, armv7-a,
           armv7-r, armv7-m, iwmmxt, ep9312.




没有更多推荐了,返回首页