使用 crosstool-NG 產生 toolchain


這裡是使用 1.18 版來做
預設都在 HOME 資料夾裡

安裝 crosstool-ng
# cd ~
# wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.18.0.tar.bz2
# tar xf crosstool-ng-1.18.0.tar.bz2
# cd crosstool-ng-1.18.0
# ./configure --prefix=`pwd`/crosstool
# make && make install
# export PATH="${PATH}:`pwd`/crosstool/bin"

# ct-ng help
This is crosstool-NG version 1.18.0
表示安裝成功...


安裝 cross compilier toolchain
# cd ~
# mkdir crosstool
# cd crosstool
# ct-ng list-samples  --> 可以看到支援的平台

[G.X]   arm-cortex_a15-linux-gnueabi
[G..]   arm-cortex_a8-linux-gnueabi
[G..]   arm-davinci-linux-gnueabi
[G..]   arm-unknown-eabi
[G..]   arm-unknown-linux-gnueabi
[G.X]   arm-unknown-linux-uclibcgnueabi
[G..]   x86_64-unknown-linux-gnu
[G..]   x86_64-unknown-linux-uclibc
[G.X]   x86_64-unknown-mingw32

# ct-ng show-arm-unknown-linux-gnueabi  -->  toolchain 環境

    OS             : linux-3.7.3
    Companion libs : gmp-4.3.2 mpfr-2.4.2 libelf-0.8.13
    binutils       : binutils-2.19.1a
    C compiler     : gcc-4.3.2 (C,C++,Fortran,Java)
    C library      : glibc-2.9 (threads: nptl)
    Tools          : dmalloc-5.5.2 duma-2_5_15 gdb-6.8a ltrace-0.5.3 strace-4.5.19

# ct-ng arm-unknown-linux-gnueabi

***********************************************************

Initially reported by: Alexander BIGGA
URL: http://sourceware.org/ml/crossgcc/2008-06/msg00031.html

***********************************************************

Now configured for "arm-unknown-linux-gnueabi"

若沒出現 也可以手動 cp ../crosstool-ng-1.18.0/samples/arm-unknown-linux-gnueabi/crosstool.config .config

# mkdir ~/src
# mkdir ~/x-tools

先建立 src & x-tools 是因為 ct-ng 預設目錄就在這裡,
可在 menuconfig ---> Paths and misc options 裡修改
(${HOME}/src) Local tarballs directory
 (${HOME}/x-tools/${CT_TARGET}) Prefix directory

~/src 是放置下載的檔案
~/x-tools 是放置 toolchain

# ct-ng menuconfig
  Target options -> Architecture level -> armv5te # marvell 88F6282

# ct-ng build  --> 慢慢等吧@@@@

完成後會安裝再 ~/x-tools 裡 
# ll ~/x-tools/
arm-unknown-linux-gnueabi

Toolchain options -> (unknown) Tuple's vendor string
如果把 (unknown) 修改成 (XXX) build 完就會變成 arm-XXX-linux-gnueabi

# ../x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-unknown-linux-gnueabi
Configured with: /home/shyuan/crosstool/.build/src/gcc-4.3.2/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-unknown-linux-gnueabi --prefix=/home/shyuan/x-tools/arm-unknown-linux-gnueabi --with-sysroot=/home/shyuan/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot --enable-languages=c,c++,fortran,java --with-arch=armv5te --with-float=soft --with-pkgversion='crosstool-NG 1.18.0' --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --with-gmp=/home/shyuan/crosstool/.build/arm-unknown-linux-gnueabi/buildtools --with-mpfr=/home/shyuan/crosstool/.build/arm-unknown-linux-gnueabi/buildtools --enable-threads=posix --enable-target-optspace --disable-nls --disable-multilib --with-local-prefix=/home/shyuan/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.3.2 (crosstool-NG 1.18.0) 

# ../x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc hello.c -o hello
# file hello
hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.7.3, not stripped

把 hello 放到 target board, 看看是否可以正常執行.


gdb 有錯誤時, 記得安裝 expat or python
[INFO ]  =================================================================
[INFO ]  Installing cross-gdb
[EXTRA]    Configuring cross-gdb
[EXTRA]    Building cross-gdb
[ERROR]    configure: error: expat is missing or unusable
[ERROR]    make[2]: *** [configure-gdb] Error 1
[ERROR]    make[1]: *** [all] Error 2


[INFO ]  =================================================================
[INFO ]  Installing cross-gdb
[EXTRA]    Configuring cross-gdb
[EXTRA]    Building cross-gdb
[ERROR]    configure: error: python is missing or unusable
[ERROR]    make[2]: *** [configure-gdb] Error 1
[ERROR]    make[1]: *** [all] Error 2

sudo yum install expat
sudo yum install expat-devel
sudo yum install python
sudo yum install python-devel




reference: 
http://crosstool-ng.org/



附上 ct-ng build 完整的訊息

[INFO ]  Performing some trivial sanity checks
[INFO ]  Build started 20130814.151941
[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-unknown-linux-gnueabi
[EXTRA]  Dumping internal crosstool-NG configuration: done in 0.08s (at 00:01)
[INFO ]  =================================================================
[INFO ]  Retrieving needed toolchain components' tarballs
[INFO ]  Retrieving needed toolchain components' tarballs: done in 0.10s (at 00:01)
[INFO ]  =================================================================
[INFO ]  Extracting and patching toolchain components
[INFO ]  Extracting and patching toolchain components: done in 0.15s (at 00:02)
[INFO ]  =================================================================
[INFO ]  Installing GMP for host
[EXTRA]    Configuring GMP
[EXTRA]    Building GMP
[EXTRA]    Installing GMP
[INFO ]  Installing GMP for host: done in 47.82s (at 00:49)
[INFO ]  =================================================================
[INFO ]  Installing MPFR for host
[EXTRA]    Configuring MPFR
[EXTRA]    Building MPFR
[EXTRA]    Installing MPFR
[INFO ]  Installing MPFR for host: done in 13.31s (at 01:03)
[INFO ]  =================================================================
[INFO ]  Installing binutils for host
[EXTRA]    Configuring binutils
[EXTRA]    Building binutils
[EXTRA]    Installing binutils
[INFO ]  Installing binutils for host: done in 33.41s (at 01:36)
[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 58.56s (at 02:35)
[INFO ]  =================================================================
[INFO ]  Installing kernel headers
[EXTRA]    Installing kernel headers
[EXTRA]    Checking installed headers
[INFO ]  Installing kernel headers: done in 5.10s (at 02:40)
[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 32.80s (at 03:13)
[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 69.18s (at 04:22)
[INFO ]  =================================================================
[INFO ]  Installing C library
[EXTRA]    Configuring C library
[EXTRA]    Building C library
[EXTRA]    Installing C library
[09:21] - 
[INFO ]  Installing C library: done in 360.72s (at 10:23)
[INFO ]  =================================================================
[INFO ]  Installing final compiler
[EXTRA]    Configuring gcc
[EXTRA]    Building gcc
[EXTRA]    Installing gcc
[INFO ]  Installing final compiler: done in 1044.37s (at 27:47)
[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.54s (at 27:52)
[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 42.37s (at 28:34)
[INFO ]  =================================================================
[INFO ]  Installing dmalloc
[EXTRA]    Configuring dmalloc
[EXTRA]    Building dmalloc
[EXTRA]    Installing dmalloc
[INFO ]  Installing dmalloc: done in 7.10s (at 28:41)
[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.13s (at 28:43)
[INFO ]  =================================================================
[INFO ]  Installing cross-gdb
[EXTRA]    Configuring cross-gdb
[EXTRA]    Building cross-gdb
[EXTRA]    Installing cross-gdb
[INFO ]  Installing cross-gdb: done in 86.44s (at 30:10)
[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 141.24s (at 32:31)
[INFO ]  =================================================================
[INFO ]  Installing gdbserver
[EXTRA]    Configuring gdbserver
[EXTRA]    Building gdbserver
[EXTRA]    Installing gdbserver
[INFO ]  Installing gdbserver: done in 5.42s (at 32: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.85s (at 32:39)
[INFO ]  =================================================================
[INFO ]  Installing strace
[EXTRA]    Configuring strace
[EXTRA]    Building strace
[EXTRA]    Installing strace
[INFO ]  Installing strace: done in 11.68s (at 32:51)
[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.27s (at 32:52)
[INFO ]  Build completed at 20130814.155233
[INFO ]  (elapsed: 32:52.39)
[INFO ]  Finishing installation (may take a few seconds)...

留言

這個網誌中的熱門文章

NMEA標準格式 -- GPS

網路 Transformer 的用途

cut,sed,awk 字串處理