重新以arm用户登陆,让新设置得环境变量起作用
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ tree -L 1
.
|-- BUILD
|-- binutils-2.16
|-- binutils-2.16.tar.gz
|-- flow.c.diff
|-- gcc-3.4.4
|-- gcc-3.4.4.tar.bz2
|-- gdb-6.4.tar.gz
|-- glibc-2.3.5
|-- glibc-2.3.5.tar.gz
|-- glibc-linuxthreads-2.3.5.tar.gz
|-- ioperm.c.diff
|-- linux-2.6.14.1.tar.bz2
`-- t-linux.diff
arm@ubuntu:~$ su arm
arm@ubuntu:~$ cd ${SRC}
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ tar zxvf binutils-2.16.tar.gz
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ mkdir -p BUILD/binutils-2.16
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd BUILD/binutils-2.16
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/binutils-2.16$ ../../binutils-2.16/configure --prefix=${PREFIX} --target=${TARGET} --with-sysroot=${SYSROOT}
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/binutils-2.16$ make
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/binutils-2.16$ su root
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/binutils-2.16#make install
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/binutils-2.16# exit
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/binutils-2.16$
2.5 准备内核头文件
2.5.1 使用当前平台的gcc编译内核头文件
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/binutils-2.16$ cd ${KERNEL}
arm@ubuntu:~/dev_home/kernel$
arm@ubuntu:~/dev_home/kernel$ tar jxvf ../btools/tchain3.4.4/linux-2.6.14.1.tar.bz2
arm@ubuntu:~/dev_home/kernel$ cd linux-2.6.14.1/
arm@ubuntu:~/dev_home/kernel/linux-2.6.14.1$ cp arch/arm/configs/smdk2410_defconfig .config
本人是用的CPU是S3C2410,选择了一个配置文件smdk2410_defconfig,你可以根据你的需要选择
arm@ubuntu:~/dev_home/kernel/linux-2.6.14.1$ make ARCH=arm menuconfig
System Type --->
ARM system type (Samsung S3C2410) --->
S3C24XX Implementations --->
[ ] Simtec Electronics ANUBIS
[ ] Simtec Electronics BAST (EB2410ITX)
[ ] IPAQ H1940
[ ] Acer N30
SMDK2410/A9M2410
[ ] SMDK2440
[ ] Thorcom VR1000
[ ] HP iPAQ rx3715
[ ] NexVision OTOM Board
[ ] NexVision NEXCODER 2440 Light Board
--- S3C2410 Boot
--- S3C2410 Setup
[ ] S3C2410 DMA support
(0) S3C2410 UART to use for low-level messages
--- Processor Type
--- Processor Features
Support Thumb user binaries
[ ] Disable I-Cache
[ ] Disable D-Cache
[ ] Force write through D-cache
退出时
Do you wish to save your new kernel configuration?
No >
选择Yes
arm@ubuntu:~/dev_home/kernel/linux-2.6.14.1$ make
2.5.2 复制内核头文件
arm@ubuntu:~/dev_home/kernel/linux-2.6.14.1$ su root
root@ubuntu:/home/arm/dev_home/kernel/linux-2.6.14.1# mkdir -p ${SYSROOT}/usr/include
root@ubuntu:/home/arm/dev_home/kernel/linux-2.6.14.1# cp -a include/linux ${SYSROOT}/usr/include/linux
root@ubuntu:/home/arm/dev_home/kernel/linux-2.6.14.1# cp -a include/asm-arm ${SYSROOT}/usr/include/asm
root@ubuntu:/home/arm/dev_home/kernel/linux-2.6.14.1# cp -a include/asm-generic ${SYSROOT}/usr/include/asm-generic
root@ubuntu:/home/arm/dev_home/kernel/linux-2.6.14.1# exit
arm@ubuntu:~/dev_home/kernel/linux-2.6.14.1$
2.6 编译glibc头文件
arm@ubuntu:~/dev_home/kernel/linux-2.6.14.1$ cd ${SRC}
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ tar zxvf glibc-2.3.5.tar.gz
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ patch -d glibc-2.3.5 -p1
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd glibc-2.3.5
arm@ubuntu:~/dev_home/btools/tchain3.4.4/glibc-2.3.5$ tar zxvf ../glibc-linuxthreads-2.3.5.tar.gz
arm@ubuntu:~/dev_home/btools/tchain3.4.4/glibc-2.3.5$ cd ..
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ mkdir -p BUILD/glibc-2.3.5-headers
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd BUILD/glibc-2.3.5-headers/
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5-headers$ ../../glibc-2.3.5/configure --prefix=/usr --host=${TARGET} --enable-add-ons=linuxthreads --with-headers=${SYSROOT}/usr/include
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5-headers$ su root
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5-headers# make cross-compiling=yes install_root=${SYSROOT} install-headers
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5-headers# touch ${SYSROOT}/usr/include/gnu/stubs.h
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5-headers#
touch ${SYSROOT}/usr/include/bits/stdio_lim.h
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5-headers# exit
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5-headers$
2.7 编译gcc 第一阶段
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5-headers$ cd ${SRC}
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ tar jxvf gcc-3.4.4.tar.bz2
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ patch -d gcc-3.4.4 -p1
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ patch -d gcc-3.4.4 -p1
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ mkdir -p BUILD/gcc-3.4.4-stage1
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd BUILD/gcc-3.4.4-stage1/
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$ ../../gcc-3.4.4/configure --prefix=${PREFIX} --target=${TARGET} --enable-languages=c --with-sysroot=${SYSROOT}
注意: 不能加上--disable-shared
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$ make all-gcc
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$ su root
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1# make install-gcc
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1# exit
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$