音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

登錄 免費(fèi)注冊 首頁 | 行業(yè)黑名單 | 幫助
維庫電子市場網(wǎng)
技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng)
驅(qū)動編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe

Building a GNU/Linux ARM Toolchain (from scratch)

作者:zhaojiuhua 欄目:嵌入式系統(tǒng)
Building a GNU/Linux ARM Toolchain (from scratch)


Charles M. "Chip" Coldwell

This article describes the steps necessary to build a cross-compiler toolchain for targeting ARM PROCESSors from an i386 workstation running the GNU/Linux operating SYSTEM. The procedure described can be run automatically using a shell script, or you can just download the RPMs from the table below. Those interested in what's going on under the hood should read on.
PACKAGE     Binary     Source
GNU Binutils     arm-binutils-2.16-1.i386.rpm     arm-binutils-2.16-1.src.rpm
GNU Compiler Collection     arm-gcc-3.4.4-1.i386.rpm     arm-gcc-3.4.4-1.src.rpm
GNU C Library     arm-glibc-2.3.5-1.i386.rpm     arm-glibc-2.3.5-1.src.rpm
Linux Kernel     arm-kernel-2.6.10-1.i386.rpm     arm-kernel-2.6.10-1.src.rpm

N.B., These RPMs were built on Red Hat Desktop v.3

N.B., because of the bootstrapping problem described below, building any one of the gcc, glibc or kernel RPMs from the corresponding source RPM requires INSTALLing the other two binary RPMs. The ONLY way to build the whole set from scratch is to use the shell script.

N.B., this procedure builds a little-endian toolchain. Follow the LINK to learn why big-endianness is wrong.

The files are INSTALLed in the directory /usr/arm. The build PROCESS described here assumes that all work is being done under this directory. This means that you must have read, write and execute permissions on this directory and all subdirectories and files contained therein to proceed. Probably that means you must be root.

There's a bootstrapping problem that requires some of the components to be built twice. Briefly, the problem is that building the C cross-compiler requires having the ARM GNU C Library, but of course, building the ARM GNU C Library requires a C cross-compiler. The solution to this circular dependency is to first INSTALL the GNU C library HEADERs, then build the C compiler without the C Library, use it to build the C library, then rebuild the full set of GNU compilers. Lather, rinse, repeat.

The GNU C Library cannot be built without the Linux kernel HEADERs. Most C library functions are implemented using SYSTEM calls, and the kernel HEADERs define the SYSTEM call interface. The HEADERs come with the kernel source, of course, but the source must be PATCHed and configured for the ARM architecture before they can be used to build the C library.
Setup

To start out, set up some variables and create the toplevel ARM directory and the source subdirectory. Also, make sure that the utilties we build will be on your PATH after they are INSTALLed.

  TARGET=arm-unknown-linux-gnu
  PREFIX=/usr/arm
  SYSROOT=${PREFIX}/sysroot
  export ARCH=arm
  export CROSS_COMPILE=${TARGET}-
  export PATH=$PATH:${PREFIX}/bin
  mkdir -p ${PREFIX}/src
  

Get the sources

The versions chosen are not necessarily the most recent, but they do seem to work together with a MINIMUM of PATCHing. The last two files are ONLY necessary if you are targeting the ATMEL AT91RM9200 CPU.

  cd ${PREFIX}/src
  for URL in \
  http://ftp.gnu.org/gnu/binutils/binutils-2.16.tar.gz \
  http://ftp.gnu.org/gnu/gcc/gcc-3.4.4/gcc-3.4.4.tar.bz2 \
  "http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/flow.c.diff?cvsroot=gcc&ONLY_with_tag=csl-arm-branch&r1=1.563.4.2&r2=1.563.4.3" \
  http://frank.harvard.edu/~coldwell/toolchain/t-linux.diff \
  http://ftp.gnu.org/gnu/glibc/glibc-2.3.5.tar.gz \
  http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.3.5.tar.gz \
  http://frank.harvard.edu/~coldwell/toolchain/ioperm.c.diff \
  http://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.10.tar.gz \
  http://maxim.org.za/AT91RM9200/2.6/2.6.10-at91.PATCH.gz \
  http://maxim.org.za/AT91RM9200/2.6/26_at91_serial.c.gz
  do
      FILE=${URL##*/}
      FILE=${FILE%%\?*}
      [ -f ${FILE} ] || wget -O ${FILE} ${URL}
  done
  

GNU binutils

These utilities (as, ar, ranlib, ld, etc.) are a prerequisite for building even the runt C compiler. In fact, many of the phases of compilation are accomplished by explicitly invoking some of these utilities (e.g as or ld).

Fortunately, setting up the GNU binutils for targeting the ARM architecture is very straightforward:

  cd ${PREFIX}/src
  tar xvfz binutils-2.16.tar.gz
  mkdir -p BUILD/binutils-2.16
  cd BUILD/binutils-2.16
  ../../binutils-2.16/configure --prefix=${PREFIX} --target=${TARGET} --with-sysroot=${SYSROOT} 2>&1 | tee configure.out
  make 2>&1 | tee make.out
  make INSTALL 2>&1 | tee -a make.out
  

Linux Kernel Headers

In this step, the Linux kernel HEADERs are INSTALLed in the SYSROOT directory. In the example below, the kernel is configured for the AT91RM9200 PROCESSor; default configurations for other PROCESSors are available in the linux-2.6.10/arch/arm/configs directory. Two PATCHes are applied to the kernel source in order to build for the AT91RM9200; if this isn't your target CPU these PATCHes are optional/irrelevant/harmless.

  cd ${PREFIX}/src
  tar xvfz linux-2.6.10.tar.gz
  ln -s linux-2.6.10 linux
  zcat 2.6.10-at91.PATCH.gz | PATCH -d linux -p1
  zcat 26_at91_serial.c.gz >linux/drivers/serial/at91_serial.c
  cd linux
  make at91rm9200dk_defconfig
  make include/linux/version.h
  mkdir -p ${SYSROOT}/usr/include
  cp -a ${PREFIX}/src/linux/include/linux ${SYSROOT}/usr/include/linux
  cp -a ${PREFIX}/src/linux/include/asm-arm ${SYSROOT}/usr/include/asm
  cp -a ${PREFIX}/src/linux/include/asm-generic ${SYSROOT}/usr/include/asm-generic
  

Glibc HEADERs

This step INSTALLs the HEADER files that come with glibc. Two of them are generated during the glibc build, which we don't do until later on. Fortunately, it is sufficient to substitute empty files.

  cd ${PREFIX}/src
  tar xvfz glibc-2.3.5.tar.gz
  PATCH -d glibc-2.3.5 -p1 <ioperm.c.diff
  cd glibc-2.3.5
  tar xvfz ../glibc-linuxthreads-2.3.5.tar.gz
  cd ..
  mkdir -p BUILD/glibc-2.3.5-HEADERs
  cd BUILD/glibc-2.3.5-HEADERs
  ../../glibc-2.3.5/configure --prefix=/usr --host=${TARGET} --enable-add-ons=linuxthreads --with-HEADERs=${SYSROOT}/usr/include 2>&1 | tee configure.out
  make cross-compiling=yes INSTALL_root=${SYSROOT} INSTALL-HEADERs 2>&1 | tee make.out
  touch ${SYSROOT}/usr/include/gnu/stubs.h
  touch ${SYSROOT}/usr/include/bits/stdio_lim.h
  

Stage 1 GCC

Here we apply two PATCHes to the GCC source. The first one forces the build PROCESS to generate the C Run Time files crti.o and crtn.o, which are needed later in the gcc build PROCESS. The second one fixes a bug that would otherwise cause an internal compiler error (ICE) during the glibc build PROCESS.

  cd ${PREFIX}/src
  bunzip2 -c gcc-3.4.4.tar.bz2 | tar xvf -
  PATCH -d gcc-3.4.4 -p1 < flow
參與討論
昵稱:
討論內(nèi)容:
 
 
相關(guān)帖子
請教3DES加密算法
8019初始化出現(xiàn)問題,寄存器值總為0xFF
寫S3C44B0的CPSR的疑問
求教超文本編輯器UE的高亮顯示問題!
真心期望您的指點(diǎn)(我該怎么做!)
免費(fèi)注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入


Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號