4

给香橙派编译并写入最新的 U-Boot

 3 years ago
source link: https://ralf.ren/compile-and-write-uboot-on-orange-pi/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

本文讲述如何为香橙派编译最新版本的 U-Boot,并写入至 SD 卡。

我的硬件与软件环境

  • Ubuntu 20.04 LTS
  • Orange Pi Zero (512MB RAM)
  • 32GB MicroSD 卡

1. 编译 U-Boot

在 Linux 中,克隆香橙派的编译脚本仓库:

orangepi-xunlong/orangepi-build: Orange Pi build for H2、H3、H5、H6 and H616 (github.com)

执行 sudo ./build.sh 开始编译,选项则选择编译 U-Boot 的 DEB 包:

u-boot    U-boot package

编译完成后,会在如图所示的路径中生成一个 U-Boot 的 DEB 包:

opizero_uboot_deb-1024x643.png编译后生成的 U-Boot DEB 包

2. 获得 U-Boot 镜像和刷写命令

将 U-Boot 的 DEB 包解压到当前目录下:

dpkg -x linux-u-boot-current-orangepizero_2.1.0_armhf.deb ./

在如图所示的路径中,找到 U-Boot 的 bin 文件,以及安装脚本:

opizero_uboot_bin-2-1024x643.pngU-Boot 的 bin 文件opizero_uboot_script-1-1024x643.pngU-Boot 的安装脚本

打开安装脚本,可以看到如下的两行即是刷写 U-Boot 的命令:

opizero_uboot_install.png
标示的两行是刷写 U-Boot 的命令

对应到我的实际情况,MicroSD 卡是 /dev/sdd,因此刷写命令为:

sudo dd if=/dev/zero of=/dev/sdd bs=1k count=1023 seek=1 status=noxfer
sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdd bs=1024 seek=8 status=noxfer

再完成下一步的分区操作后,执行上述命令便可刷写 U-Boot。

3. 将 MicroSD 卡分区

Linux 下,使用 GParted 进行分区最方便便捷。

从刷写命令我们可以看出,U-Boot 存放于 MicroSD 卡地址偏移 8 * 1024 = 8KB 的位置。而 U-Boot 本身的大小,有 445KB。总计 453KB。

因此,无论何种分区方案,必须要在 MicroSD 卡开头位置留出足够的保留空间,不做分区。保留空间的大小至少要满足 U-Boot 的存放,并保有一定的空余。对于 MicroSD 卡,容量大多按 GB 计算,因此留出几 MB 的空间是较为简单的做法。以下是我的分区图(实际上,预留 4MB 足矣):

opizero_uboot_parted.png
我的 MicroSD 卡分区图

4. 启动香橙派

这里是我的运行结果:

opizero_uboot_startup-1024x666.png
U-Boot 启动输出


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK