首页 > 代码库 > ARM交叉编译工具制作V2

ARM交叉编译工具制作V2

      此篇是《Ubuntu ARM交叉编译工具链制作过程》的升级版本。

    本文主机环境为Ubuntu10.04.4桌面版

    内核:2.6.32

    GCC:4.4.3

---------------------------------------------------转载请注明:xiaobin_hlj80---- 

Z.前期准备(使用root权限)

   安装系统补丁258个(2014-11-24)

一、主机环境

   1. 更改shell为bash

          如果运行

          ls -la /bin/sh

          看到是 dash ,则请运行以下命令

          sudo dpkg-reconfigure dash

          选择 no 以删除 dash

    2. 更改awk为gawk   

         #sudo update-alternatives --config awk

    3. 安装samba

         文件共享用

 

二、软件环境

            安装如下软件(apt-get install)

    1. gperf

    2. bison

    3. flex

    4. texinfo

          如不安装错误提示:Missingrequired tool: makeinfo

    5. patch

    6. libtool

          如不安装错误提示:Couldnot find GNU libtool >= 1.5.26

    7. automake

          如不安装错误提示:Could not find GNU automake >=1.10

    8. libncurses5-dev

         如不安装错误提示:Could not find curses header, requiredfor the kconfig frontends

 

     以下为build时需要的

    9. build-essential

          g++

    10. libexpat-dev

          Cross-gdb

 

以下为可选

    11. cvs

    12. subversion

             svn

    13. zlib1g-dev

 

Y. 安装crosstool-ng

   1. 解压缩

           tar jxvf crosstool-ng-1.19.0.tar.bz2

   2. 配置

           ./configure --prefix=/usr/local/ctng

   3. 生成

          make

   4. 安装

          sudo make install

 

 X. 配置crosstool-ng

  1. 增加安装路径到系统路径中

          exportPATH=$PATH:/usr/local/ctng/bin

  2. 建立一个临时目录

         # cd ~

        # mkdir toolchain-build

 

  3. 拷贝预配置文件到临时目录

      # cd /usr/local/ctng/lib/ct-ng.1.19.0/samples

      /usr/local/ctng/lib/ct-ng.1.19.0/samples#cp arm-unknown-linux-gnueabi/* ~/toolchain-build/

     # cd ~

     # cd toolchain-build

    ~/toolchain-build# mv crosstool.config .config

  4. 执行菜单配置(menuconfig)

      ~/toolchain-build# ct-ngmenuconfig

 

  修改默认选项,以适应目标板。

         a. Paths and misc options

        1)crosstool-NG behavior

        2)Paths

        3)Downloading

        4)Extracting

        5)Build behavior

         (2) Number of parallel jobs

        6)Logging

      b.Target options

       Target Architecture (arm)

        1)Generic target options

        2)Target optimizations

          (1) Floating point (softfp(FPU))

        3)arm other options

      c.Toolchain options

        1)General toolchain options

        2)Tuple completion and aliasing

          (1) softfp

        3)Toolchain type

        4)Build system

        5)Misc options

 

      d.Operating System

        Linux kernel version (2.6.32.61)

        1)Common kernel options

        2)linux other options

      e.Binary utilities

       Binuary format: (ELF)

          Binutils version (2.19.1a)

      f.C Compiler

        CCompiler (gcc)

       gcc version (4.3.2)

        1)Additional supported languages

        2)gcc other options

          (1) Use system zlib

        3)Optimisation features

        4)Settings for libraries running on target

        5)Misc. obscure options

 

      g.C-library

        Clibrary (glibc)

       glibc version (2.9)

 

      h.Debug facilities

 

      i.Companion libraries

       GMP version (4.3.2)

       MPFR version (2.4.2)

 

        1)libelf version needed to build for target

          libelf version (0.8.13)

        2)Companion libraries common options

 

  5. 下载文件

      把较大的安装文件(bz2)拷贝到$HOME/src(默认目录)下。

    (1) binutils-2.19.1a.tar.bz2

    (2) gcc-4.3.2.tar.bz2

    (3) gdb-6.8a.tar.bz2

    (4) glibc-2.9.tar.bz2

    (5) linux-2.6.32.61.tar.bz2

 

  6. 生成交叉编译环境

      # ct-ng build

 

附:

    安装过程

at91@ubuntu:~/toolchain-build$ ct-ng build
[INFO ]  Performing some trivial sanity checks
[INFO ]  Build started 20141130.230825
[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-softfp-linux-gnueabi
[EXTRA]  Dumping internal crosstool-NG configuration: done in 0.08s (at 00:01)
[INFO ]  =================================================================
[INFO ]  Retrieving needed toolchain components' tarballs
[EXTRA]    Retrieving 'gmp-4.3.2'
[EXTRA]    Saving 'gmp-4.3.2.tar.bz2' to local storage
[EXTRA]    Retrieving 'mpfr-2.4.2'
[EXTRA]    Saving 'mpfr-2.4.2.tar.xz' to local storage
[EXTRA]    Retrieving 'libelf-0.8.13'
[EXTRA]    Saving 'libelf-0.8.13.tar.gz' to local storage
[EXTRA]    Retrieving 'glibc-ports-2.9'
[EXTRA]    Saving 'glibc-ports-2.9.tar.bz2' to local storage
[EXTRA]    Retrieving 'dmalloc-5.5.2'
[EXTRA]    Saving 'dmalloc-5.5.2.tgz' to local storage
[EXTRA]    Retrieving 'duma_2_5_15'
[EXTRA]    Saving 'duma_2_5_15.tar.gz' to local storage
[EXTRA]    Retrieving 'ncurses-5.9'
[ERROR]   
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Retrieving needed toolchain components' tarballs'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: do_debug_gdb_get[scripts/build/debug/300-gdb.sh@735]
[ERROR]  >>        called from: do_debug_get[scripts/build/debug.sh@21]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@581]
[ERROR]  >>
[ERROR]  >>  For more info on this error, look at the file: 'build.log'
[ERROR]  >>  There is a list of known issues, some with workarounds, in:
[ERROR]  >>      '/usr/local/ctng/share/doc/crosstool-ng/ct-ng.1.19.0/B - Known issues.txt'
[ERROR]   
[ERROR]  (elapsed: 19:34.11)
[19:35] / make: *** [build] Error 1
at91@ubuntu:~/toolchain-build$ ct-ng build
[INFO ]  Performing some trivial sanity checks
[INFO ]  Build started 20141130.232953
[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-softfp-linux-gnueabi
[EXTRA]  Dumping internal crosstool-NG configuration: done in 0.07s (at 00:01)
[INFO ]  =================================================================
[INFO ]  Retrieving needed toolchain components' tarballs
[EXTRA]    Retrieving 'ncurses-5.9'
[EXTRA]    Saving 'ncurses-5.9.tar.gz' to local storage
[EXTRA]    Retrieving 'expat-2.1.0'
[EXTRA]    Saving 'expat-2.1.0.tar.gz' to local storage
[EXTRA]    Retrieving 'ltrace_0.5.3.orig'
[EXTRA]    Saving 'ltrace_0.5.3.orig.tar.gz' to local storage
[EXTRA]    Retrieving 'strace-4.5.19'
[EXTRA]    Saving 'strace-4.5.19.tar.bz2' to local storage
[INFO ]  Retrieving needed toolchain components' tarballs: done in 363.91s (at 06:05)
[INFO ]  =================================================================
[INFO ]  Extracting and patching toolchain components
[EXTRA]    Extracting 'linux-2.6.32.61'
[EXTRA]    Patching 'linux-2.6.32.61'
[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.1a'
[EXTRA]    Patching 'binutils-2.19.1a'
[EXTRA]    Extracting 'gcc-4.3.2'
[EXTRA]    Patching 'gcc-4.3.2'
[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 122.16s (at 08:07)
[INFO ]  =================================================================
[INFO ]  Installing GMP for host
[EXTRA]    Configuring GMP
[EXTRA]    Building GMP
[EXTRA]    Installing GMP
[INFO ]  Installing GMP for host: done in 92.38s (at 09:39)
[INFO ]  =================================================================
[INFO ]  Installing MPFR for host
[EXTRA]    Configuring MPFR
[EXTRA]    Building MPFR
[EXTRA]    Installing MPFR
[INFO ]  Installing MPFR for host: done in 29.47s (at 10:09)
[INFO ]  =================================================================
[INFO ]  Installing binutils for host
[EXTRA]    Configuring binutils
[EXTRA]    Building binutils
[EXTRA]    Installing binutils
[INFO ]  Installing binutils for host: done in 106.15s (at 11:55)
[INFO ]  =================================================================
[INFO ]  Installing pass-1 core C compiler
[EXTRA]    Configuring gcc
[EXTRA]    Building gcc
[EXTRA]    Installing gcc
[INFO ]  Installing pass-1 core C compiler: done in 342.05s (at 17:37)
[INFO ]  =================================================================
[INFO ]  Installing kernel headers
[EXTRA]    Installing kernel headers
[EXTRA]    Checking installed headers
[INFO ]  Installing kernel headers: done in 4.34s (at 17:42)
[INFO ]  =================================================================
[INFO ]  Installing C library headers & start files
[EXTRA]    Configuring C library
[EXTRA]    Installing C library headers
[EXTRA]    Installing C library start files
[INFO ]  Installing C library headers & start files: done in 29.92s (at 18:11)
[INFO ]  =================================================================
[INFO ]  Installing pass-2 core C compiler
[EXTRA]    Configuring gcc
[EXTRA]    Building gcc
[EXTRA]    Installing gcc
[INFO ]  Installing pass-2 core C compiler: done in 351.52s (at 24:03)
[INFO ]  =================================================================
[INFO ]  Installing C library
[EXTRA]    Configuring C library
[EXTRA]    Building C library
[EXTRA]    Installing C library
[INFO ]  Installing C library: done in 522.75s (at 32:46)
[INFO ]  =================================================================
[INFO ]  Installing final compiler
[EXTRA]    Configuring gcc
[EXTRA]    Building gcc
[EXTRA]    Installing gcc
[INFO ]  Installing final compiler: done in 335.12s (at 38:21)
[INFO ]  =================================================================
[INFO ]  Installing libelf for the target
[EXTRA]    Configuring libelf
[EXTRA]    Building libelf
[EXTRA]    Installing libelf
[INFO ]  Installing libelf for the target: done in 4.16s (at 38:25)
[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 60.76s (at 39:26)
[INFO ]  =================================================================
[INFO ]  Installing dmalloc
[EXTRA]    Configuring dmalloc
[EXTRA]    Building dmalloc
[EXTRA]    Installing dmalloc
[INFO ]  Installing dmalloc: done in 6.45s (at 39:32)
[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 1.28s (at 39:34)
[INFO ]  =================================================================
[INFO ]  Installing cross-gdb
[EXTRA]    Configuring cross-gdb
[EXTRA]    Building cross-gdb
[EXTRA]    Installing cross-gdb
[INFO ]  Installing cross-gdb: done in 146.34s (at 42:00)
[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
[INFO ]  Installing native gdb: done in 210.00s (at 45:30)
[INFO ]  =================================================================
[INFO ]  Installing gdbserver
[EXTRA]    Configuring gdbserver
[EXTRA]    Building gdbserver
[EXTRA]    Installing gdbserver
[INFO ]  Installing gdbserver: done in 5.76s (at 45:36)
[INFO ]  =================================================================
[INFO ]  Installing ltrace
[EXTRA]    Copying sources to build dir
[EXTRA]    Configuring ltrace
[EXTRA]    Building ltrace
[EXTRA]    Installing ltrace
[INFO ]  Installing ltrace: done in 2.56s (at 45:38)
[INFO ]  =================================================================
[INFO ]  Installing strace
[EXTRA]    Configuring strace
[EXTRA]    Building strace
[EXTRA]    Installing strace
[INFO ]  Installing strace: done in 9.81s (at 45:48)
[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 1.42s (at 45:50)
[INFO ]  Build completed at 20141201.001543
[INFO ]  (elapsed: 45:49.64)
[INFO ]  Finishing installation (may take a few seconds)...
[45:50] / at91@ubuntu:~/toolchain-build$ 



ARM交叉编译工具制作V2