———————————————————————————————————————
主机操作系统:Centos 6.7
交叉编译器环境:arm-linux-gcc-4.5.4
Linux内核版本: linux-3.0
制作工具:交叉编译器
———————————————————————————————————————
1.准备交叉编译器的源码包
1.1上传源码包到opt目录下,下载链接地址
ftp://iot-yun.zicp.net/linux_tools/
转存失败重新上传取消
1.2修改/opt目录权限
转存失败重新上传取消
leiyuxing@centos6 桌面]$ cd
[leiyuxing@centos6 ~]$ sudo chmod 777 /opt/
[leiyuxing@centos6 ~]$ cd /opt/
[leiyuxing@centos6 opt]$ ls
buildroot-2012.08-LingYunEmbLab-v1.3.0.bin rh
[leiyuxing@centos6 opt]$ chmod a+x buildroot-2012.08-LingYunEmbLab-v1.3.0.bin
[leiyuxing@centos6 opt]$ echo $PATH
/usr/lib/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/leiyuxing/bin
[leiyuxing@centos6 opt]$ ./buildroot-2012.08-LingYunEmbLab-v1.3.0.bin
+-------------------------------------------------------------------------------------------------------+
| Lingyun I.O.Y System Laboratory<www.iot-yun.com> buildroot-2012.08 packet installer for CentOS6 |
| Please report bugs or feature suggestions to <Email: guowenxue@gmail.com QQ: 281143292> |
+-------------------------------------------------------------------------------------------------------+
Current support ARCH:
1: arm920t <CPU: s3c2410,s3c2440,at91sam9200...>
2: arm926t <CPU: s3c2416,at91sam9260/9g20,at91sam9x35...>
Please select:
1
buildroot-2012.08 will be compiled for ARCH [arm920t]
Please input buildroot-2012.08 install path, or ENTER for default path [/opt]:
buildroot-2012.08 will be installed to [/opt]
Check buildroot dependency system tools installed status...
1: automake [ OK ]
2: autoconf [ OK ]
3: bison [ OK ]
4: gcc [ OK ]
5: gcc-c++ [ OK ]
6: make [ OK ]
7: ncurses [ OK ]
8: zlib [ OK ]
9: texinfo [ FAILED ]
10: flex [ OK ]
ERROR: please use yum install the miss system tools by root first!!!
[leiyuxing@centos6 opt]$ sudo yum install texinfo /*编译的过程中可能会提示缺少某些命令(譬如g++,makeinfo,ncurses),这时就使用yum或rpm命令安装缺少的相应rpm包*/
已加载插件:fastestmirror, refresh-packagekit, security
设置安装进程
Loading mirror speeds from cached hostfile
* base: mirror.nus.edu.sg
* extras: mirror.nus.edu.sg
* updates: mirror.nus.edu.sg
http://mirror.nus.edu.sg/centos/6.8/os/i386/repodata/repomd.xml: [Errno 12] Timeout on http://mirror.nus.edu.sg/centos/6.8/os/i386/repodata/repomd.xml: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
尝试其他镜像。
base | 3.7 kB 00:00
extras | 3.3 kB 00:00
updates | 3.4 kB 00:00
解决依赖关系
--> 执行事务检查
---> Package texinfo.i686 0:4.13a-8.el6 will be 安装
--> 完成依赖关系计算
依赖关系解决
================================================================================
软件包 架构 版本 仓库 大小
================================================================================
正在安装:
texinfo i686 4.13a-8.el6 base 660 k
事务概要
================================================================================
Install 1 Package(s)
总下载量:660 k
Installed size: 1.9 M
确定吗?[y/N]:y
下载软件包:
http://mirror.vastspace.net/centos/6.8/os/i386/Packages/texinfo-4.13a-8.el6.i686.rpm: [Errno 12] Timeout on http://mirror.vastspace.net/centos/6.8/os/i386/Packages/texinfo-4.13a-8.el6.i686.rpm: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')
尝试其他镜像。
texinfo-4.13a-8.el6.i686.rpm | 660 kB 00:07
运行 rpm_check_debug
执行事务测试
事务测试成功
执行事务
正在安装 : texinfo-4.13a-8.el6.i686 1/1
Verifying : texinfo-4.13a-8.el6.i686 1/1
已安装:
texinfo.i686 0:4.13a-8.el6
完毕!
[leiyuxing@centos6 opt]$ ls buildroot-2012.08
arm920t buildroot-2012.08-packes configs docs Makefile support
board CHANGES COPYING fs output target
boot Config.in dl linux package toolchain
[leiyuxing@centos6 opt]$ cd buildroot-2012.08
[leiyuxing@centos6 buildroot-2012.08]$ ls
arm920t buildroot-2012.08-packes configs docs Makefile support
board CHANGES COPYING fs output target
boot Config.in dl linux package toolchain
这样Linux服务器上的buildroot-2012.08的源码包就准备好了,之后我们就准备开始编译交叉编译器了。
2.配置交叉编译器选项
2.1 配置交叉编译器CPU类型
在开始编译交叉编译器之前,我们要先配置交叉编译器,使用那些依赖的软件包的哪些版本。输入以下命令我们开始交叉编译器的配置:
[leiyuxing@centos6 buildroot-2012.08]$ export TERM=vt100 防止make menuconfig出现乱码
[leiyuxing@centos6 buildroot-2012.08]$ make menuconfig
mkdir -p /opt/buildroot-2012.08/output/build/buildroot-config/lxdialog
make CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" obj=/opt/buildroot-2012.08/output/build/buildroot-config -C support/kconfig -f Makefile.br mconf
make[1]: Entering directory `/opt/buildroot-2012.08/support/kconfig'
/usr/bin/gcc -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -DLOCALE -I/opt/buildroot-2012.08/output/build/buildroot-config -c lxdialog/checklist.c -o /opt/buildroot-2012.08/output/build/buildroot-config/lxdialog/checklist.o
/usr/bin/gcc -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -DLOCALE -I/opt/buildroot-2012.08/output/build/buildroot-config -c lxdialog/inputbox.c -o /opt/buildroot-2012.08/output/build/buildroot-config/lxdialog/inputbox.o
/usr/bin/gcc -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -DLOCALE -I/opt/buildroot-2012.08/output/build/buildroot-config -c lxdialog/menubox.c -o /opt/buildroot-2012.08/output/build/buildroot-config/lxdialog/menubox.o
/opt/buildroot-2012.08/.config - Buildroot 2012.08 Configuration
buildroot-2012.08 make menuconfig 选项配置说明
=======================
Target Architecture (ARM (little endian)) --->
Target Architecture Variant (arm920t) ---> 根据自己的CPU来选择
Target ABI (EABI) --->
Build options --->
($(TOPDIR)/dl) Download dir
($(TOPDIR)/arm920t) Host dir
[*] prefer static libraries
其它选项都不要选,如果是要设置值的地方就使用默认值
Toolchain --->
Kernel Headers (Linux 2.6 (manually specified version)) --->
(2.6.37) linux version 选定内核版本为2.6.37
... ...
[*] Enable compiler tls support
[*] Enable MMU support
[*] Use software floating point by default
[*] Enable large file (files > 2 GB) support
[*] Enable IPv6 support
[*] Enable RPC support
[*] Enable WCHAR support
[*] Enable C++ support
其它选项都不要选,如果是要设置值的地方就使用默认值
System configuration --->
Init system (None) ---> 把Busbyox编译去掉
这里面所有的都不要选,如果是要设置值的地方就使用默认值
Package Selection for the target --->
这里面所有的选项都不要选,除了:
Libraries --->
Compression and decompression --->
[*] lzo
-*- zlib
Host utilities --->
这里面所有的选项都不要选
Filesystem images --->
这里面所有的选项都不要选
Bootloaders --->
这里面所有的选项都不要选
Kernel ---
这里面所有的选项都不要选
编译完成成功最后结果说明:
=======================
... ... ...
touch /apps/buildroot-2012.08/output/target/etc/ld.so.conf
mkdir -p /apps/buildroot-2012.08/output/target/var/cache/ldconfig
if [ -x "/apps/buildroot-2012.08/arm920t/usr/bin/arm-unknown-linux-uclibcgnueabi-ldconfig" ]; \
then \
/apps/buildroot-2012.08/arm920t/usr/bin/arm-unknown-linux-uclibcgnueabi-ldconfig -r /apps/buildroot-2012.08/output/target; \
else \
/sbin/ldconfig -r /apps/buildroot-2012.08/output/target; \
fi
/apps/buildroot-2012.08/arm920t/usr/bin/arm-unknown-linux-uclibcgnueabi-ldconfig: /usr/lib/libstdc++.so.6.0.14-gdb.py is not a shared library, skipping
/apps/buildroot-2012.08/arm920t/usr/bin/arm-unknown-linux-uclibcgnueabi-ldconfig: can't resolve /usr/X11R6/lib in chroot .: No such file or directory
/apps/buildroot-2012.08/arm920t/usr/bin/arm-unknown-linux-uclibcgnueabi-ldconfig: skipping /usr/X11R6/lib: No such file or directory
( \
echo "NAME=Buildroot"; \
echo "VERSION=2012.08"; \
echo "ID=buildroot"; \
echo "VERSION_ID=2012.08"; \
echo "PRETTY_NAME=\"Buildroot 2012.08\"" \
) > /apps/buildroot-2012.08/output/target/etc/os-release
这时应该可以看到编译出来的交叉编译器工具链
[leiyuxing@centos6 buildroot-2012.08]$ ls arm920t/usr/bin/
aclocal
aclocal-1.11
arm-linux-addr2line
arm-linux-ar
arm-linux-as
arm-linux-c++
arm-linux-cc
arm-linux-c++filt
arm-linux-cpp
arm-linux-elfedit
arm-linux-g++
arm-linux-gcc
arm-linux-gcc-4.5.4
arm-linux-gccbug
arm-linux-gcov
arm-linux-gprof
arm-linux-ld
arm-linux-ld.bfd
arm-linux-ldconfig
arm-linux-ldd
arm-linux-nm
arm-linux-objcopy
arm-linux-objdump
arm-linux-ranlib
arm-linux-readelf
arm-linux-size
arm-linux-strings
arm-linux-strip
arm-unknown-linux-uclibcgnueabi-addr2line
arm-unknown-linux-uclibcgnueabi-ar
arm-unknown-linux-uclibcgnueabi-as
arm-unknown-linux-uclibcgnueabi-c++
arm-unknown-linux-uclibcgnueabi-cc
arm-unknown-linux-uclibcgnueabi-c++filt
arm-unknown-linux-uclibcgnueabi-cpp
arm-unknown-linux-uclibcgnueabi-elfedit
arm-unknown-linux-uclibcgnueabi-g++
arm-unknown-linux-uclibcgnueabi-gcc
arm-unknown-linux-uclibcgnueabi-gcc-4.5.4
arm-unknown-linux-uclibcgnueabi-gccbug
arm-unknown-linux-uclibcgnueabi-gcov
arm-unknown-linux-uclibcgnueabi-gprof
arm-unknown-linux-uclibcgnueabi-ld
arm-unknown-linux-uclibcgnueabi-ld.bfd
arm-unknown-linux-uclibcgnueabi-ldconfig
arm-unknown-linux-uclibcgnueabi-ldd
arm-unknown-linux-uclibcgnueabi-nm
arm-unknown-linux-uclibcgnueabi-objcopy
arm-unknown-linux-uclibcgnueabi-objdump
arm-unknown-linux-uclibcgnueabi-ranlib
arm-unknown-linux-uclibcgnueabi-readelf
arm-unknown-linux-uclibcgnueabi-size
arm-unknown-linux-uclibcgnueabi-strings
arm-unknown-linux-uclibcgnueabi-strip
autoconf
autoheader
autom4te
automake
automake-1.11
autoreconf
autoscan
autoupdate
bison
captoinfo
clear
ifnames
infocmp
infotocap
ldconfig
ldd
libtool
libtoolize
m4
ncurses5-config
pkg-config
reset
tabs
tic
toe
tput
tset
yacc
[leiyuxing@centos6 buildroot-2012.08]$ ls arm920t/usr/lib/
gcc libiberty.a libmpc.so libncurses++.a
ldscripts libltdl.la libmpc.so.2 libncurses_g.a
libform.a libltdl.so libmpc.so.2.0.0 libpanel.a
libform_g.a libltdl.so.7 libmpfr.la libpanel_g.a
libgmp.la libltdl.so.7.2.2 libmpfr.so liby.a
libgmp.so libmenu.a libmpfr.so.4 terminfo
libgmp.so.10 libmenu_g.a libmpfr.so.4.1.1
libgmp.so.10.0.5 libmpc.la libncurses.a
3.测试交叉编译器
首先,我们写一个Hello.c的程序,如下:
然后我们使用交叉编译器来编译这个C文件生成hello可执行文件,然后使用file命令查看文件属性,可以看到这个文件是ARM下运行的,具体如下:
当我们把这个hello文件下载到开发板上时,应该能运行了。
转存失败重新上传取消
转存失败重新上传取消
转存失败重新上传取消