自制buildroot搭建arm9交叉编译环境

  1. ### 自动

编译脚本

郭工写的自动化编译的脚本,包含源码,可以自定义选择arm920t与arm926t平台,编译时间较长,CentOS 6 or 7 测试通过

yum update -y
yum groupinstall "Development tools" -y
yum install texinfo automake autoconf ncurses -y
wget https://git.oschina.net/sfantree/oss3/raw/master/arm_tools/buildroot/buildroot-2012.08-LingYunEmbLab-v1.3.0.bin
chmod +x ./buildroot-2012.08-LingYunEmbLab-v1.3.0.bin
./buildroot-2012.08-LingYunEmbLab-v1.3.0.bin

打包脚本

觉得编译时间太长的同学可以试试我自己写的打包脚本,提取x64上的交叉编译链,所以只支持64位的操作系统,Ubuntu 12.04, Ubuntu 16.04, CentOS 6 or 7 测试通过

wget https://coding.net/u/sfantree/p/self_use_OSS/git/raw/master/source/lin_buildroot.sh
chmod +x lin_buildroot.sh
sudo ./lin_buildroot.sh

默认的安装路径建议不要改,以后的编译路径均是这个

export CROSS=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-

手动

手动编译对宿主机的gcc版本有限制,Ubuntu 12.04, CentOS 6 or 7测试通过,过高的gcc版本可能导致编译失败

yum install texinfo automake autoconf ncurses -y
#apt install libncurses5-dev libncurses5 bison flex libgettextpo-dev libgettextpo0 gettext texinfo libmpc-dev:i386 libmpc:i386
wget http://buildroot.org/downloads/buildroot-2012.08.tar.gz
tar -zxvf buildroot-2012.08.tar.gz
cd buildroot-2012.08
wget http://git.oschina.net/sfantree/oss3/raw/master/arm_tools/buildroot/buildroot201208_arm920t.config -O .config
ls -al .config

buildroot源码顶层目录中的.config隐藏文件包含编译配置信息,即make menuconfig的配置选项

Target Architecture (ARM (little endian))  --->  
Target Architecture Variant (arm920t)  --->
Build options  --->
    ($(TOPDIR)/dl) Download dir
    ($(TOPDIR)/arm920t) Host dir
    Mirrors and Download locations  --->
        http://mirrors.ustc.edu.cn/kernel.org/ Kernel.org mirror (NEW)
        http://mirrors.ustc.edu.cn/gnu/ GNU Software mirror (NEW)
        ftp://ftp.cn.debian.org/debian/ Debian Software mirror (NEW)
Toolchain  --->
    Kernel Headers (Linux 2.6 (manually specified version))  --->
        (2.6.37) linux version
    [*] Enable MMU support
    [*] Enable large file (files > 2 GB) support
    [*] Enable IPv6 support
    [*] Enable RPC support
    [*] Enable WCHAR support
    [*] Enable C++ support
System configuration  --->
    Init system (None)  --->
Package Selection for the target  --->
    [ ] BusyBox
    Libraries  --->
        Compression and decompression  ---> 
            [*] lzo
            -*- zlib    

make过程同时还会下载依赖源码文件,建议使用命令行代理,可以参考搭建Linux命令行代理,或者先把依赖源码全部下载好

wget https://gitee.com/sfantree/oss3/raw/master/arm_tools/buildroot/buildroot-2012.08-packes.tgz
tar zxvf buildroot-2012.08-packes.tgz
mv buildroot-2012.08-packes dl
make 

测试

wget https://raw.githubusercontent.com/tmosest/The-C-Programming-Language-2nd-Edition/master/Chapter-1/helloworld.c
/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc helloworld.c -o helloworld

交叉编译的可执行文件运行平台为兼容ARMv4指令集的32位小端CPU上

$ file helloworld

helloworld: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), not stripped

发表评论

电子邮件地址不会被公开。 必填项已用*标注