什么是交叉编译工具链,

http://www.crifan.com/files/doc/docbook/cross_compile/release/html/cross_compile.html#arm_crosscompile_on_x86_run_on_arm

安装依赖

1
2
3
apt-get install build-essential u-boot-tools Ddevice-tree-compile gcc-arm-linux-gnueabihf \
libusb-1.0-0-dev git wget fakeroot \
kernel-package zlib1g-dev libncurses5-dev pkg-config

下载源码

git clone git://git.denx.de/u-boot.git
它的目录是这样的

1
2
3
4
api common doc fs lib net snapshot.commit
arch config.mk drivers include Licenses post test
board configs dts Kbuild MAINTAINERS README tools
cmd disk examples Kconfig Makefile scripts

可以看到有很多分支

  • master
    u-boot-2016.09.y
    remotes/origin/HEAD -> origin/master
    remotes/origin/master
    remotes/origin/next
    remotes/origin/origin
    remotes/origin/u-boot-2009.11.y
    remotes/origin/u-boot-2013.01.y
    remotes/origin/u-boot-2016.09.y

生成配置

所有的配置文件都在configs目录
以orangepi_pc_defconfig为例子

1
2
3
4
5
6
7
8
9
10
11
make CROSS_COMPILE=arm-linux-gnueabihf- orangepi_pc_defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#

修改配置

make CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

编译

make CROSS_COMPILE=arm-linux-gnueabihf-

如果看到这样的结果,就是编译成功了

1
2
3
4
5
OBJCOPY spl/u-boot-spl-nodtb.bin
COPY spl/u-boot-spl.bin
MKSUNXI spl/sunxi-spl.bin
BINMAN u-boot-sunxi-with-spl.bin
CFGCHK u-boot.cfg

再看一下目录

1
2
3
4
5
6
7
8
9
10
11
api examples README u-boot.dtb
arch fs scripts u-boot-dtb.bin
board include snapshot.commit u-boot-dtb.img
cmd Kbuild spl u-boot.img
common Kconfig System.map u-boot.lds
config.mk lib test u-boot.map
configs Licenses tools u-boot-nodtb.bin
disk MAINTAINERS u-boot u-boot.srec
doc Makefile u-boot.bin u-boot-sunxi-with-spl.bin
drivers net u-boot.cfg u-boot.sym
dts post u-boot.cfg.configs

参考
https://linux-sunxi.org/Mainline_U-Boot#Compile_U-Boot