LiangShuang's ...

I'm not a programmer...

用crosstool-NG-1.9.3构建ARM工具链

shuang posted @ 2011年2月17日 05:02 in 嵌入式linux , 20240 阅读

    在成功重装了两次系统之后之前的移植工作终于还是被我弄丢了,无奈只好一切重头再来了。
    首先下载u-boot源码,下载地址为ftp://ftp.denx.de/pub/u-boot/,这次将要移植的版本为2010-12。
    制作交叉工具链(Cross-Tool),还是使用crosstool-NG来制作编译工具,下载地址:http://ymorin.is-a-geek.org/download/crosstool-ng 。版本为1.9.3,这个工具的使用方法可以在文档或是http://ymorin.is-a-geek.org/projects/crosstool中找到,由于之前在弄crosstool的时候遇到一些问题,所以这次也把它的安装过程和使用方法记录下来。
    Features of This Tool

  • kernel-like menuconfig configuration interface
    • widespread, well-known interface
    • easy, yet powerful configuration
  • growing number of supported architectures
  • support for alternative components in the toolchain
    • uClibc-, glibc- or eglibc-based toolchain supported right now!
    • others easy to implement
  • different target OS supported
    • Linux
    • bare metal
  • patch repository for those versions needing patching
    • patches for many versions of the toolchain components
    • support for custom (understand local) patch repository
  • different threading models
    • NPTL
    • linuxthreads
  • support for both soft- and hard-float toolchains
  • debug facilities
    • native and cross gdb, gdbserver
    • debugging libraries: dmalloc, duma
    • restart a build at any step
  • sample configurations repository usable as starting point for your own toolchain

    安装crosstool-NG
    配置安装路径./configure --prefix=/opt/programs/crosstool-ng-1.9.3,会提示缺少必要的工具,安装就行了。
    sudo yum install lzma,接下来make, make install,可以检查以下是否安装成功
        PREFIX='/opt/programs/crosstool-ng-1.9.3'
        BINDIR='/opt/programs/crosstool-ng-1.9.3/bin'
        LIBDIR='/opt/programs/crosstool-ng-1.9.3/lib/ct-ng-1.9.3'
        DOCDIR='/opt/programs/crosstool-ng-1.9.3/share/doc/ct-ng-1.9.3'
        MANDIR='/opt/programs/crosstool-ng-1.9.3/share/man'
    然后测试,将其添加到PATH环境变量中,运行ct-ng help, ct-ng menuconfig, ct-ng build。
    使用ct-ng制作工具链
    ct-ng list-samples,列出已经通过实践检验的示例配置脚本。
    这里使用arm-unknown-linux-uclibcgnueabi的配置方案预先配置一下,然后再调整。
    Options:


  • OS:linux-2.6.33.7
  • uClibc-0.9.30.2
  • linuxthread

    调整完成之后可以在工作目录下查看配置结果.config文件,然后确认无误就可以build了,哦,对了,如果不能正常下载需要的tar文件时最好自己手动下载,然后再build,build时会出现错误提示'Don't set LD_LIBRARY_PATH. It screws up the build.',按照提示unset LD_LIBRARY_PATH,这时程序自动创建了目录结构,接下来先停下来,手动下载所需要的安装文件,需要在配置时选择forbid download:

    当所有的安装文件都下载、解压、patch之后,还差一个uClibc的配置文件'[ERROR]    You did not provide a uClibc config file!',我们默认的配置文件在.config中的定义是"CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config",但是经过修改之后的CT_TARGET已经不存在了,所以直接把‘uClibc-0.9.30.2.config‘文件复制出来,放到刚才的工作目录的target下,然后再修改.config中的CT_LIBC_UCLIBC_CONFIG_FILE内容。

    虽然一切都准备好了,但是在编译器生成的最后阶段(Installing final compiler)还是出问题了,所以只好把gcc的版本换成4.3.2再试一次,不过这次没有手动下载所需的安装文件,直接通过为wget设置代理来自动通过ct-ng下载。为wget设置代理也很简单,直接编辑/etc/wgetrc文件,加上这两行:

http_proxy = http://58.248.245.225:80/

use_proxy = on

就行了,build的时候还是死掉了,原因是.../scripts/functions文件中的代码

# OK, just look if we have them...
_aria2c=$(CT_Which aria2c)
_wget=$(CT_Which wget)
#_curl=$(CT_Which curl)


# Wrapper function to call one of, in order of preference:
#   aria2
#   curl
#   wget
# Usage: CT_DoGetFile <URL>
CT_DoGetFile() {
#CT_DoLog EXTRA "1 ${_aria2c}"
#CT_DoLog EXTRA "2 ${_curl}"
#CT_DoLog EXTRA "3 ${_wget}"
    if   [ -n "${_aria2c}" -a ${CT_DOWNLOAD_MAX_CHUNKS} -gt 1 ]; then
        CT_DoGetFileAria2 "$1"
    elif [ -n "${_curl}" ]; then
        CT_DoGetFileCurl "$1"
    elif [ -n "${_wget}" ]; then
        CT_DoGetFileWget "$1"
    else
        CT_Abort "Could find neither wget nor curl"
    fi
}

 

实际上CT_DoGetFile函数调用的是CT_DoGetFileCurl而非刚才设置的wget,把上面的那个_curl=$(CT_Which curl)注释掉就行了。

程序脚本中安装文件的下载地址有时不可用,需要修改以下。

下载完成之后重新开始安装,最后成功!

.config的文件内容如下:

#
# Automatically generated make config: don't edit
# crosstool-NG version: 1.9.3
# Fri Feb 18 19:16:42 2011
#
# CT_BACKEND is not set
CT_MODULES=y

#
# Paths and misc options
#

#
# crosstool-NG behavior
#
# CT_OBSOLETE is not set
CT_EXPERIMENTAL=y
# CT_DEBUG_CT is not set

#
# Paths
#
CT_LOCAL_TARBALLS_DIR="${HOME}/src"
CT_SAVE_TARBALLS=y
CT_WORK_DIR="${CT_TOP_DIR}/targets"
CT_PREFIX_DIR="${HOME}/x-tool-2/${CT_TARGET}"
CT_INSTALL_DIR="${CT_PREFIX_DIR}"
CT_REMOVE_DOCS=y
CT_INSTALL_DIR_RO=y
CT_STRIP_ALL_TOOLCHAIN_EXECUTABLES=y

#
# Downloading
#
# CT_FORBID_DOWNLOAD is not set
# CT_FORCE_DOWNLOAD is not set
CT_USE_MIRROR=y
# CT_PREFER_MIRROR is not set
CT_MIRROR_BASE_URL="http://ymorin.is-a-geek.org/mirrors/"
CT_CONNECT_TIMEOUT=10
CT_DOWNLOAD_MAX_CHUNKS=1
# CT_ONLY_DOWNLOAD is not set

#
# Extracting
#
# CT_FORCE_EXTRACT is not set
CT_OVERIDE_CONFIG_GUESS_SUB=y
# CT_ONLY_EXTRACT is not set
CT_PATCH_BUNDLED=y
# CT_PATCH_LOCAL is not set
# CT_PATCH_BUNDLED_LOCAL is not set
# CT_PATCH_LOCAL_BUNDLED is not set
# CT_PATCH_BUNDLED_FALLBACK_LOCAL is not set
# CT_PATCH_LOCAL_FALLBACK_BUNDLED is not set
# CT_PATCH_NONE is not set
CT_PATCH_ORDER="bundled"
# CT_PATCH_SINGLE is not set
# CT_PATCH_USE_LOCAL is not set

#
# Build behavior
#
CT_PARALLEL_JOBS=1
CT_LOAD=0
CT_USE_PIPES=y
# CT_CONFIG_SHELL_SH is not set
# CT_CONFIG_SHELL_ASH is not set
CT_CONFIG_SHELL_BASH=y
# CT_CONFIG_SHELL_CUSTOM is not set
CT_CONFIG_SHELL="bash"

#
# Logging
#
# CT_LOG_ERROR is not set
# CT_LOG_WARN is not set
# CT_LOG_INFO is not set
CT_LOG_EXTRA=y
# CT_LOG_ALL is not set
# CT_LOG_DEBUG is not set
CT_LOG_LEVEL_MAX="EXTRA"
# CT_LOG_SEE_TOOLS_WARN is not set
CT_LOG_PROGRESS_BAR=y
CT_LOG_TO_FILE=y
CT_LOG_FILE_COMPRESS=y

#
# Target options
#
CT_ARCH="arm"
CT_ARCH_SUPPORTS_BOTH_MMU=y
CT_ARCH_SUPPORTS_BOTH_ENDIAN=y
CT_ARCH_SUPPORTS_32=y
# CT_ARCH_SUPPORTS_64 is not set
CT_ARCH_SUPPORT_ARCH=y
# CT_ARCH_SUPPORT_ABI is not set
CT_ARCH_SUPPORT_CPU=y
CT_ARCH_SUPPORT_TUNE=y
CT_ARCH_SUPPORT_FPU=y
CT_ARCH_DEFAULT_HAS_MMU=y
# CT_ARCH_DEFAULT_BE is not set
CT_ARCH_DEFAULT_LE=y
CT_ARCH_DEFAULT_32=y
# CT_ARCH_DEFAULT_64 is not set
CT_ARCH_ARCH="armv4t"
CT_ARCH_CPU=""
CT_ARCH_TUNE=""
CT_ARCH_FPU=""
# CT_ARCH_BE is not set
CT_ARCH_LE=y
CT_ARCH_32=y
# CT_ARCH_64 is not set
CT_ARCH_BITNESS=32
# CT_ARCH_FLOAT_HW is not set
CT_ARCH_FLOAT_SW=y
CT_TARGET_CFLAGS=""
CT_TARGET_LDFLAGS=""

#
# General target options
#
CT_ARCH_arm=y
# CT_ARCH_x86 is not set
# CT_ARCH_sh is not set
# CT_ARCH_avr32 is not set
# CT_ARCH_ia64 is not set
# CT_ARCH_mips is not set
# CT_ARCH_powerpc is not set
# CT_ARCH_s390 is not set
# CT_ARCH_m68k is not set
# CT_ARCH_alpha is not set
# CT_ARCH_blackfin is not set
CT_ARCH_arm_AVAILABLE=y
CT_ARCH_x86_AVAILABLE=y
CT_ARCH_sh_AVAILABLE=y
CT_ARCH_avr32_AVAILABLE=y
CT_ARCH_ia64_AVAILABLE=y
CT_ARCH_mips_AVAILABLE=y
CT_ARCH_powerpc_AVAILABLE=y
CT_ARCH_s390_AVAILABLE=y
CT_ARCH_m68k_AVAILABLE=y
CT_ARCH_alpha_AVAILABLE=y
CT_ARCH_blackfin_AVAILABLE=y
CT_ARCH_USE_MMU=y

#
# arm other options
#
CT_ARCH_ARM_MODE="arm"
CT_ARCH_ARM_MODE_ARM=y
# CT_ARCH_ARM_MODE_THUMB is not set
# CT_ARCH_ARM_INTERWORKING is not set
CT_ARCH_ARM_EABI=y

#
# Target optimisations
#

#
# Toolchain options
#

#
# General toolchain options
#
CT_USE_SYSROOT=y
CT_SYSROOT_DIR_PREFIX=""

#
# Tuple completion and aliasing
#
CT_TARGET_VENDOR="cool"
CT_TARGET_ALIAS_SED_EXPR=""
CT_TARGET_ALIAS="arm-cool-uClibc"

#
# Toolchain type
#
# CT_NATIVE is not set
CT_CROSS=y
# CT_CROSS_NATIVE is not set
# CT_CANADIAN is not set
CT_TOOLCHAIN_TYPE="cross"

#
# Build system
#
CT_BUILD=""
CT_BUILD_PREFIX=""
CT_BUILD_SUFFIX=""

#
# Operating System
#
# CT_BARE_METAL is not set
# CT_MINGW32 is not set
CT_KERNEL_SUPPORTS_SHARED_LIBS=y
CT_KERNEL="linux"
CT_KERNEL_VERSION="2.6.33.7"
# CT_KERNEL_mingw32 is not set
# CT_KERNEL_bare_metal is not set
CT_KERNEL_linux=y
CT_KERNEL_mingw32_AVAILABLE=y
CT_KERNEL_bare_metal_AVAILABLE=y
CT_KERNEL_linux_AVAILABLE=y
CT_KERNEL_LINUX_INSTALL=y
# CT_KERNEL_V_2_6_36 is not set
# CT_KERNEL_V_2_6_35_8 is not set
# CT_KERNEL_V_2_6_34_7 is not set
CT_KERNEL_V_2_6_33_7=y
# CT_KERNEL_V_2_6_32_25 is not set
# CT_KERNEL_V_2_6_31_14 is not set
# CT_KERNEL_V_2_6_27_55 is not set
# CT_KERNEL_LINUX_CUSTOM is not set
CT_KERNEL_LINUX_VERBOSITY_0=y
# CT_KERNEL_LINUX_VERBOSITY_1 is not set
# CT_KERNEL_LINUX_VERBOSITY_2 is not set
CT_KERNEL_LINUX_VERBOSE_LEVEL=0
CT_KERNEL_LINUX_INSTALL_CHECK=y
# CT_KERNEL_LINUX_USE_CUSTOM_HEADERS is not set

#
# Common kernel options
#
CT_SHARED_LIBS=y

#
# Binary utilities
#
CT_ARCH_BINFMT_ELF=y
# CT_ARCH_BINFMT_FLAT is not set
# CT_ARCH_BINFMT_FDPIC is not set

#
# GNU binutils
#
# CT_BINUTILS_V_2_20_1 is not set
# CT_BINUTILS_V_2_20 is not set
CT_BINUTILS_V_2_19_1=y
# CT_BINUTILS_V_2_19 is not set
# CT_BINUTILS_V_2_18 is not set
# CT_BINUTILS_V_2_17 is not set
# CT_BINUTILS_V_2_16_1 is not set
CT_BINUTILS_VERSION="2.19.1"
CT_BINUTILS_EXTRA_CONFIG=""
CT_BINUTILS_FOR_TARGET=y
CT_BINUTILS_FOR_TARGET_IBERTY=y
CT_BINUTILS_FOR_TARGET_BFD=y

#
# C compiler
#
CT_CC="gcc"
CT_CC_VERSION="4.3.2"
CT_CC_gcc=y
# CT_CC_V_4_5_1 is not set
# CT_CC_V_4_5_0 is not set
# CT_CC_V_4_4_5 is not set
# CT_CC_V_4_4_4 is not set
# CT_CC_V_4_4_3 is not set
# CT_CC_V_4_4_2 is not set
# CT_CC_V_4_4_1 is not set
# CT_CC_V_4_4_0 is not set
# CT_CC_V_4_3_5 is not set
# CT_CC_V_4_3_4 is not set
# CT_CC_V_4_3_3 is not set
CT_CC_V_4_3_2=y
# CT_CC_V_4_3_1 is not set
# CT_CC_V_4_2_4 is not set
# CT_CC_V_4_2_3 is not set
# CT_CC_V_4_2_2 is not set
# CT_CC_V_4_2_1 is not set
# CT_CC_V_4_2_0 is not set
# CT_CC_V_4_1_2 is not set
# CT_CC_V_4_0_4 is not set
# CT_CC_V_3_4_6 is not set
CT_CC_GCC_4_2_or_later=y
CT_CC_GCC_4_3_or_later=y
# CT_CC_GCC_4_4_or_later is not set
# CT_CC_GCC_4_5_or_later is not set
# CT_CC_GCC_HAS_GRAPHITE is not set
# CT_CC_GCC_HAS_LTO is not set
CT_CC_GCC_USE_GMP_MPFR=y
# CT_CC_GCC_USE_PPL_CLOOG is not set
# CT_CC_GCC_USE_MPC is not set
# CT_CC_GCC_USE_LIBELF is not set
CT_CC_PKGVERSION="crosstool-NG-${CT_VERSION}"
CT_CC_BUGURL=""
CT_CC_ENABLE_CXX_FLAGS=""
CT_CC_CORE_EXTRA_CONFIG=""
CT_CC_EXTRA_CONFIG=""
CT_CC_SUPPORT_CXX=y
CT_CC_SUPPORT_FORTRAN=y
CT_CC_SUPPORT_JAVA=y
CT_CC_SUPPORT_ADA=y
CT_CC_SUPPORT_OBJC=y
CT_CC_SUPPORT_OBJCXX=y

#
# Additional supported languages:
#
CT_CC_LANG_CXX=y
# CT_CC_LANG_FORTRAN is not set
# CT_CC_LANG_JAVA is not set
# CT_CC_LANG_ADA is not set
# CT_CC_LANG_OBJC is not set
# CT_CC_LANG_OBJCXX is not set
CT_CC_LANG_OTHERS=""

#
# gcc other options
#
CT_CC_GCC_ENABLE_TARGET_OPTSPACE=y
# CT_CC_GCC_LIBMUDFLAP is not set
# CT_CC_GCC_LIBGOMP is not set
# CT_CC_GCC_LIBSSP is not set

#
# Misc. obscure options.
#
CT_CC_CXA_ATEXIT=y
# CT_CC_GCC_DISABLE_PCH is not set
CT_CC_GCC_SJLJ_EXCEPTIONS=m
CT_CC_GCC_LDBL_128=m

#
# C-library
#
CT_LIBC="uClibc"
CT_LIBC_VERSION="0.9.30.2"
# CT_LIBC_mingw is not set
# CT_LIBC_glibc is not set
# CT_LIBC_newlib is not set
CT_LIBC_uClibc=y
# CT_LIBC_none is not set
# CT_LIBC_eglibc is not set
CT_LIBC_mingw_AVAILABLE=y
CT_LIBC_glibc_AVAILABLE=y
CT_LIBC_newlib_AVAILABLE=y
CT_LIBC_uClibc_AVAILABLE=y
# CT_LIBC_UCLIBC_V_0_9_31 is not set
# CT_LIBC_UCLIBC_V_0_9_30_3 is not set
CT_LIBC_UCLIBC_V_0_9_30_2=y
# CT_LIBC_V_0_9_30_1 is not set
# CT_LIBC_V_0_9_30 is not set
# CT_LIBC_V_0_9_29 is not set
# CT_LIBC_V_0_9_28_3 is not set
# CT_LIBC_V_snapshot is not set
# CT_LIBC_V_specific_date is not set
CT_LIBC_UCLIBC_0_9_30_or_later=y
CT_LIBC_UCLIBC_PARALLEL=y
CT_LIBC_UCLIBC_VERBOSITY_0=y
# CT_LIBC_UCLIBC_VERBOSITY_1 is not set
# CT_LIBC_UCLIBC_VERBOSITY_2 is not set
CT_LIBC_UCLIBC_VERBOSITY=""
CT_LIBC_UCLIBC_DEBUG_LEVEL_0=y
# CT_LIBC_UCLIBC_DEBUG_LEVEL_1 is not set
# CT_LIBC_UCLIBC_DEBUG_LEVEL_2 is not set
CT_LIBC_UCLIBC_DEBUG_LEVEL=0
CT_LIBC_UCLIBC_CONFIG_FILE="${HOME}/scratch/toolchain-build/${CT_LIBC}-${CT_LIBC_VERSION}.config"
CT_LIBC_none_AVAILABLE=y
CT_LIBC_eglibc_AVAILABLE=y
CT_LIBC_SUPPORT_THREADS_ANY=y
# CT_LIBC_SUPPORT_NPTL is not set
CT_LIBC_SUPPORT_LINUXTHREADS=y
# CT_LIBC_SUPPORT_WIN32THREADS is not set
CT_THREADS="linuxthreads"

#
# Common C library options
#
# CT_THREADS_NPTL is not set
CT_THREADS_LINUXTHREADS=y
# CT_THREADS_WIN32THREADS is not set
# CT_THREADS_NONE is not set
CT_LIBC_XLDD=y

#
# uClibc other options
#
CT_LIBC_UCLIBC_LNXTHRD_OLD=y
# CT_LIBC_UCLIBC_LNXTHRD_NEW is not set
CT_LIBC_UCLIBC_LNXTHRD="old"
# CT_LIBC_UCLIBC_LOCALES is not set
# CT_LIBC_UCLIBC_WCHAR is not set

#
# Debug facilities
#
CT_DEBUG_ltrace=y
CT_LTRACE_V_0_5_3=y
# CT_LTRACE_V_0_5_2 is not set
# CT_LTRACE_V_0_5 is not set
# CT_LTRACE_V_0_4 is not set
CT_LTRACE_VERSION="0.5.3"
CT_LTRACE_0_5_3_or_later=y
CT_DEBUG_gdb=y
CT_GDB_CROSS=y
# CT_GDB_CROSS_STATIC is not set
# CT_GDB_NATIVE is not set
CT_GDB_GDBSERVER=y
CT_GDB_GDBSERVER_STATIC=y
# CT_GDB_V_7_2 is not set
# CT_GDB_V_7_1 is not set
# CT_GDB_V_7_0_1 is not set
# CT_GDB_V_7_0 is not set
CT_GDB_V_6_8=y
CT_GDB_VERSION="6.8"
CT_DEBUG_duma=y
CT_DUMA_A=y
CT_DUMA_SO=y
CT_DUMA_V_2_5_15=y
# CT_DUMA_V_2_5_14 is not set
# CT_DUMA_V_2_5_12 is not set
# CT_DUMA_V_2_5_8 is not set
# CT_DUMA_V_2_5_1 is not set
CT_DUMA_VERSION="2_5_15"
CT_DEBUG_dmalloc=y
CT_DMALLOC_V_5_5_2=y
CT_DMALLOC_VERSION="5.5.2"
CT_DEBUG_strace=y
# CT_STRACE_V_4_5_20 is not set
CT_STRACE_V_4_5_19=y
# CT_STRACE_V_4_5_18 is not set
# CT_STRACE_V_4_5_17 is not set
# CT_STRACE_V_4_5_16 is not set
# CT_STRACE_V_4_5_15 is not set
CT_STRACE_VERSION="4.5.19"

#
# Companion libraries
#
CT_COMPLIBS_NEEDED=y
CT_GMP_NEEDED=y
CT_MPFR_NEEDED=y
# CT_PPL_NEEDED is not set
# CT_CLOOG_NEEDED is not set
# CT_MPC_NEEDED is not set
# CT_LIBELF_NEEDED is not set
CT_COMPLIBS=y
# CT_WRAPPER_NEEDED is not set
CT_GMP=y
CT_MPFR=y
CT_LIBELF_TARGET=y
# CT_GMP_V_5_0_1 is not set
CT_GMP_V_4_3_2=y
# CT_GMP_V_4_3_1 is not set
# CT_GMP_V_4_3_0 is not set
# CT_GMP_V_4_2_4 is not set
# CT_GMP_V_4_2_2 is not set
CT_GMP_VERSION="4.3.2"
# CT_MPFR_V_3_0_0 is not set
CT_MPFR_V_2_4_2=y
# CT_MPFR_V_2_4_1 is not set
# CT_MPFR_V_2_4_0 is not set
# CT_MPFR_V_2_3_2 is not set
# CT_MPFR_V_2_3_1 is not set
CT_MPFR_VERSION="2.4.2"

#
# libelf version needed to build for target
#
CT_LIBELF_V_0_8_13=y
# CT_LIBELF_V_0_8_12 is not set
CT_LIBELF_VERSION="0.8.13"

#
# Companion libraries common options
#
CT_COMPLIBS_BACKUP=y
# CT_COMPLIBS_CHECK is not set
# CT_COMPLIBS_SHARED is not set

#
# Companion tools
#

#
# READ HELP before you say 'Y' below !!!
#
# CT_COMP_TOOLS is not set

#
# Test suite
#
# CT_TEST_SUITE is not set
# CT_TEST_SUITE_GCC is not set

   

参考链接:

http://forum.samdroid.net/wiki/showwiki/How+to+build+cross+toolchains+for+ARM+crosstool-NG?s=3be360ee3bb8458456aadf55f3229e12&do=comments

http://ymorin.is-a-geek.org/projects/crosstool

Emma Pankhurst 说:
2018年11月28日 16:24

The post and all posture have been done for the humans. The citizenship is reported and essaytigers reviews are inquired for the formation of the better slots for the humans. The mark is identified for the opportunities for the future terms.

subway surfers 说:
2019年2月21日 15:35

Your site has a lot of useful information for myself. I visit regularly. Hope to have more quality items.

bubble shooter 说:
2019年2月21日 16:16

I like your blog post. Keep on writing this type of great stuff. I'll make sure to follow up on your blog in the future.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter