0 安装配置交叉编译器,建议到www.linaro.org下载最新的交叉编译器,本人下载命令为:
wget http://newos.org/toolchains/arm-eabi-7.3.0-Linux-x86_64.tar.xz
mkdir ~/bin
cp arm-eabi-7.3.0-Linux-x86_64.tar.xz ~/bin
cd ~/bin
tar xvJf arm-eabi-7.3.0-Linux-x86_64.tar.xz
echo ARM_LINUX_EABI=~/bin/arm-eabi-7.3.0-Linux-x86_64 >> ~/.bashrc
echo PATH=$ARM_LINUX_EABI/bin:$PATH >> ~/.bashrc
source ~/.bashrc
1 下载uboot
git clone git://git.denx.de/u-boot.git
2 配置交叉编译器,选择linaro的交叉编译器
which armv8l-linux-gnueabihf-gcc
/home/xxxx/bin/gcc-linaro-7.3.1-2018.05-x86_64_armv8l-linux-gnueabihf/bin/armv8l-linux-gnueabihf-gcc
3 编译
cd u-boot
make rpi_2_defconfig
export CROSS_COMPILE=arm-eabi-
make -j8
最后结果:
CC examples/standalone/stubs.o
LD examples/standalone/libstubs.o
CC examples/standalone/hello_world.o
LD examples/standalone/hello_world
OBJCOPY examples/standalone/hello_world.srec
OBJCOPY examples/standalone/hello_world.bin
LDS u-boot.lds
LD u-boot
OBJCOPY u-boot.srec
OBJCOPY u-boot-nodtb.bin
start=$(aarch64-linux-android-nm u-boot | grep __rel_dyn_start | cut -f 1 -d ' '); end=$(aarch64-linux-android-nm u-boot | grep __rel_dyn_end | cut -f 1 -d ' '); tools/relocate-rela u-boot-nodtb.bin 0x00000000 $start $end
COPY u-boot.bin
SYM u-boot.sym
CFG u-boot.cfg
4 编译后得到u-boot.bin,放到树莓派/boot分区,修改config.txt:
kernel=u-boot.bin
raspberrypi 3B串口打印信息如下:
U-Boot 2018.09-rc1-00018-ga839c36 (Aug 05 2018 - 13:19:03 +0800)
DRAM: 948 MiB
RPI 3 Model B (0xa02082)
MMC: mmc@7e202000: 0, sdhci@7e300000: 1
Loading Environment from FAT... *** Warning - bad CRC, using default environment
Failed (-5)
In: serial
Out: vidconsole
Err: vidconsole
Net: No ethernet found.
starting USB...
USB0: scanning bus 0 for devices... 4 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
18030 bytes read in 6 ms (2.9 MiB/s)