1、開發平臺linux
虛擬機:VMware 12c++
操做系統:Ubuntu 14.04 64bitdocker
2、準備ARM交叉編譯工具包bootstrap
編譯uboot和linux kernel都須要ARM交叉工具鏈支持,這裏使用Linaro提供的交叉編譯工具。下載地址爲:http://releases.linaro.org/bash
注意:若是主機是64bit,請選擇64位的交叉編譯器工具鏈,32bit的主機選擇32位的交叉工具鏈。app
The Linaro Toolchain Working Group is pleased to announce this quarter’s release of the Linaro Toolchain Binaries, a pre-built version of Linaro GCC and Linaro GDB that runs on generic Linux or Windows and targets the glibc Linaro Engineering Build.ide Beginning 2014.11, Linaro is changing the layout and structure of its prebuilt toolchain binary releases. 2014.11 is the first release built with ABE, adding more maintainable code base and automatic testing. For further details on ABE, please visit https://wiki.linaro.org/ABE.工具 The folder names above describe the target triplets, i.e. the system on which you want your programs/applications to run. For more details on triplets, please click here.測試 Inside each folder is also a manifest.txt file further describing the target and host systems meant for the toolchain, plus source component versions.ui Essentially, the main folder contents are as follows: aarch64-linux-gnu · gcc-linaro-*x86_64_aarch64-linux-gnu.tar.xz o Linux 64-bit binaries for the Aarch64 Linux cross-toolchain · gcc-linaro-*i686-mingw32_aarch64-linux-gnu.tar.xz o Windows 32-bit binaries for the Aarch64 Linux cross-toolchain aarch64-none-elf · gcc-linaro-*x86_64_aarch64-elf.tar.xz o Linux 64-bit binaries for the Aarch64 bare-metal cross-toolchain · gcc-linaro-*i686-mingw32_aarch64-elf.tar.xz o Windows 32-bit binaries for the Aarch64 bare-metal cross-toolchain aarch64_be-linux-gnu · gcc-linaro-*x86_64_aarch64_be-linux-gnu.tar.xz o Linux 64-bit binaries for the Aarch64 Linux Big Endian cross-toolchain · gcc-linaro-*i686-mingw32_aarch64_be-linux-gnu.tar.xz o Windows 32-bit binaries for the Aarch64 Linux Big Endian cross-toolchain aarch64_be-none-elf · gcc-linaro-*x86_64_aarch64_be-elf.tar.xz o Linux 64-bit binaries for the Aarch64 bare-metal Big Endian cross-toolchain · gcc-linaro-*i686-mingw32_aarch64_be-elf.tar.xz o Windows 32-bit binaries for the Aarch64 bare-metal Big Endian cross-toolchain arm-linux-gnueabi · gcc-linaro-*x86_64_arm-linux-gnueabi.tar.xz o Linux 64-bit binaries for the ARMv7 Linux soft float cross-toolchain · gcc-linaro-*i686-mingw32_arm-linux-gnueabi.tar.xz o Windows 32-bit binaries for the ARMv7 Linux soft float cross-toolchain arm-linux-gnueabihf · gcc-linaro-*x86_64_arm-linux-gnueabihf.tar.xz o Linux 64-bit binaries for the ARMv7 Linux hard float cross-toolchain · gcc-linaro-*i686-mingw32_arm-linux-gnueabihf.tar.xz o Windows 32-bit binaries for the ARMv7 Linux hard float cross-toolchain arm-none-eabi · gcc-linaro-*x86_64_arm-eabi.tar.xz o Linux 64-bit binaries for the ARMv7 bare-metal cross-toolchain · gcc-linaro-*i686-mingw32_arm-eabi.tar.xz o Windows 32-bit binaries for the ARMv7 bare-metal cross-toolchain armeb-linux-gnueabihf · gcc-linaro-*x86_64_armeb-linux-gnueabihf.tar.xz o Linux 64-bit binaries for the ARMv7 Linux Big Endian hard float cross-toolchain · gcc-linaro-*i686-mingw32_armeb-linux-gnueabihf.tar.xz o Windows 32-bit binaries for the ARMv7 Linux Big Endian hard float cross-toolchain armeb-none-eabi · gcc-linaro-*x86_64_armeb-eabi.tar.xz o Linux 64-bit binaries for the ARMv7 bare-metal Big Endian cross-toolchain · gcc-linaro-*i686-mingw32_armeb-eabi.tar.xz o Windows 32-bit binaries for the ARMv7 bare-metal Big Endian cross-toolchain NOTE · The binary source package is no longer distributed as the components are now archived at http://abe.tcwglab.linaro.org/snapshots and downloaded automatically based on manifest.txt when (re)building with ABE. · The source package releases for the individual components are still at http://releases.linaro.org/latest/components/toolchain. Select the component (e.g. gcc, glibc, binutils, gdb) as necessary. · The binary tarball has been splitted into 3 parts. As a result, you can install only the parts needed: o gcc-linaro-*.tar.xz – the compiler and tools o runtime-linaro-*.tar.xz – runtime libraries needed on the target o sysroot-linaro-*.tar.xz – sysroot (a set of libraries and headers to develop against) · Beginning 2014.11, sysroots will use the latest glibc release provided by Linaro engineers in order that users get the latest features and optimizations in the system libraries. · Eglibc 2.15 compatible sysroots will no longer be released. Users that require Eglibc 2.15 sysroots that need the latest Linaro GCC compiler should use the previous quarterly released sysroot. · x86 (32-bit) Linux host toolchains are no longer provided. x86_64 (64-bit) Linux host toolchains are provided instead. · Soft-float targeted toolchains are no longer supported.
|
筆者使用的ARM交叉工具鏈版本爲gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz
下載地址爲:
3、安裝步驟
3.1、Ubuntu14.04 64bit系統下安裝標準的C開發環境
sudo apt-get install gcc g++ libgcc1 libg++ make gdb
或者 sudo apt-get install build-essential
3.2、下載gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz
1> 在/usr/local/文件夾下創建名爲ARM-toolchain的文件夾
$ sudo mkdir /usr/local/ARM-toolchain |
2> 下載gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz
$ cd /usr/local/ARM-toolchain sudo wget http://releases.linaro.org/components/toolchain/binaries/6.1-2016.08/ arm-linux-gnueabi/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz |
3.3、安裝gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi
解壓gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz
$ xz –d gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar.xz $ tar xvf gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi.tar |
3.4、修改環境變量,把交叉編譯器的路徑加入到PATH
修改/etc/bash.bashrc文件(此文件只對當前用戶適用)
$sudo gedit /etc/bash.bashrc
而後在文件的末尾空白處加入一下代碼:
# Add ARM toolschain path if [ -d /usr/local/ARM-toolchain/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi ] ; then PATH= /usr/local/ARM-toolchain/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi/bin:"${PATH}" fi |
3.5、使新的環境變量生效(不用重啓電腦)
$ source /etc/bash.bashrc
3.6. 檢查是否將路徑加入到PATH:
$ echo $PATH
若顯示的內容中含有:/usr/local/ARM-toolchain/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi/bin 說明已經將交叉編譯器的路徑加入PATH。
至此,交叉編譯環境安裝完成。
3.7. 測試是否安裝成功
$ arm-linux-gnueabi-gcc -v
執行上面的命令,顯示arm-linux-gnueabi-gcc -v信息和版本:
$ arm-linux-gnueabi-gcc -v Using built-in specs. COLLECT_GCC=arm-linux-gnueabi-gcc COLLECT_LTO_WRAPPER=/usr/local/ARM-toolchain/gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi/bin/../libexec/gcc/arm-linux-gnueabi/6.1.1/lto-wrapper Target: arm-linux-gnueabi Configured with: /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/snapshots/gcc-linaro-6.1-2016.08/configure SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libstdcxx-pch --disable-libmudflap --with-cloog=no --with-ppl=no --with-isl=no --disable-nls --enable-c99 --enable-gnu-indirect-function --with-tune=cortex-a9 --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=softfp --with-mode=thumb --disable-multilib --enable-multiarch --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/sysroots/arm-linux-gnueabi --enable-lto --enable-linker-build-id --enable-long-long --enable-shared --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu/arm-linux-gnueabi/libc --enable-languages=c,c++,fortran,lto --enable-checking=release --disable-bootstrap --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=arm-linux-gnueabi --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg/target/arm-linux-gnueabi/_build/builds/destdir/x86_64-unknown-linux-gnu Thread model: posix gcc version 6.1.1 20160711 (Linaro GCC 6.1-2016.08) |