香蕉派 BPI-M5折腾记录(2)—— 编译u-boot

21 篇文章 2 订阅
3 篇文章 0 订阅

折腾开发板的过程一般是先烧录官方release 的镜像,然后在想着自己编译kernal制作镜像,在这之前需要编译u-boot,u-boot 是一个主要用于引导加载内核,u-boot 编译过程如下记录。

1 安装toolchain

先查看kernal 和u-boot 支持的toolchain 版本:

zhy@zhy-ThinkPad-E480:~/code/BPI5/BSP/BPI-M5-bsp$ find . -name "compiler-gcc*"
./linux-aml/include/linux/compiler-gcc.h
./linux-aml/tools/include/linux/compiler-gcc.h
./u-boot-aml/include/linux/compiler-gcc4.h
./u-boot-aml/include/linux/compiler-gcc3.h
./u-boot-aml/include/linux/compiler-gcc.h
zhy@zhy-ThinkPad-E480:~/code/BPI5/BSP/BPI-M5-bsp$ 

可以看到支持的版本有3、4,因此选择的toolchain的版本是4.8,下载链接:

https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
https://releases.linaro.org/archive/14.04/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2014.04_linux.tar.xz

创建toolchain路径并解压:

sudo mkdir -p /opt/toolchains
sudo tar xvf gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz -C /opt/toolchains/
sudo tar xvf gcc-linaro-arm-none-eabi-4.8-2014.04_linux.tar.xz -C /opt/toolchains/

将toolchain路径添加到环境变量:

sudo vim ~/.bashrc

在文件最末尾添加以下内容:

export ARCH=arm64
export CROSS_COMPILE=aarch64-none-elf-
export PATH=/opt/toolchains/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:/opt/toolchains/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/bin:$PATH

执行命令,使环境变量改变立即生效:

source ~/.bashrc

执行以下命令,测试是否安装成功:

aarch64-none-elf-gcc -v

如果有以下类似输出则代表安装成功:

Using built-in specs.
COLLECT_GCC=aarch64-none-elf-gcc
COLLECT_LTO_WRAPPER=/opt/toolchains/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin/../libexec/gcc/aarch64-none-elf/4.8.3/lto-wrapper
Target: aarch64-none-elf
......
Thread model: single
gcc version 4.8.3 20131111 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2013.11 - Linaro GCC 2013.10) 

2 u-boot

下载souce code:

git clone https://github.com/BPI-SINOVOIP/BPI-M5-bsp
cd BPI-M5-bsp
git submodule update --init --recursive

这个过程需要下载挺长时间,,code里包含了kernal 和u-boot,本次只编译uboot,执行编译脚本:

./build.sh

结果如下:

zhy@zhy-ThinkPad-E480:~/code/BPI5/BSP/BPI-M5-bsp$ ./build.sh 
This tool support following building mode(s):
--------------------------------------------------------------------------------
	1. Build all, uboot and kernel and pack to download images.
	2. Build uboot only.
	3. Build kernel only.
	4. kernel configure.
	5. Pack the builds to target download image, this step must execute after u-boot,
	   kernel and rootfs build out
	6. Update local build to SD with BPI Image flashed
	7. Clean all build.
--------------------------------------------------------------------------------
Please choose a mode(1-7): 

可以看到有7个编译选项,编译u-boot输入2即可,或者直接执行以下命令编译u-boot:

./build.sh 2

编译后会在BPI-M5-bsp/u-boot-aml/sd_fuse目录生成u-boot.bin,准备一张SD卡,执行以下命令将u-boot 烧写到SD卡:

sudo dd if=u-boot.bin of=/dev/mmcblk0 conv=fsync,notrunc bs=512 seek=1
sync

接上串口,SD卡插到开发板,给开发板上电,可以看到串口有启动信息印出:
在这里插入图片描述
一上电立刻连续按回车键可以进入uboot命令模式,可以输出help命令查看支持的命令:
在这里插入图片描述
至此u-boot编译烧写完毕,过程还是挺简单的。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值