本教程给出了使用 RustSBI 和 U-Boot 在 VisionFive2 中启动的基本流程。
本教程使用软件版本如下:
软件 | 版本 |
---|---|
gcc | 10.5.0 |
RustSBI Prototyper | 0.0.0 |
你可以通过 这个链接 下载预编译的
visionfive2_fw_payload.img
。如果你希望自行编译相关内容,请先跳过此节。
VisionFive2 支持从 1-bit QSPI Nor Flash、SDIO3.0、eMMC 中启动,对于不同启动模式,烧录方式有所不同。
你可以参照 昉·星光 2启动模式设置 来修改启动模式。
参照 更新Flash中的SPL和U-Boot 或 恢复Bootloader 来更新 Flash 中的 U-Boot 部分。
非 Flash 的启动方式并不被 VisionFive2 官方文档建议。
首先,你需要确保你的对应磁盘(如 SD 卡)按照 启动地址分配 - 昉·惊鸿-7110启动手册 进行分区。
如果你不清楚如何对磁盘进行分区,你可以选择先完成烧录 Debian 镜像一节,这样你对应磁盘的分区表就应已满足上述要求。
之后,将上文得到的 visionfive2_fw_payload.img
写入表中所指向的 2 号分区即可。
本命令仅为参考,请根据自己的磁盘路径修改
$ cd workshop
$ dd if=./visionfive2_fw_payload.img of=/dev/sda2 status=progress
创建工作目录
$ mkdir workshop
这里仅使用 Debian 镜像提供分区表。如果需要启动其他操作系统,可以在进入 U-Boot 后自行启动。
前往 https://debian.starfivetech.com/ 下载最新 Debian 镜像。
假设下载下来的文件名为 debian_image.img.bz2
。
$ bzip2 -dk debian_image.img.bz2
移动 debian_image.img
到 workshop
目录下。
$ cd workshop
$ git clone [email protected]:starfive-tech/VisionFive2.git
$ cd VisionFive2
$ git checkout JH7110_VisionFive2_devel
$ git submodule update --init --recursive
$ cd workshop/VisionFive2
$ git clone https://github.com/rustsbi/rustsbi
编译 SDK,编译产物应在 work
目录下。
$ cd workshop/VisionFive2
$ make -j$(nproc)
编译 RustSBI Prototyper,以 U-Boot 作为 Payload。
$ cd workshop/VisionFive2/rustsbi
$ cargo prototyper --payload ../work/u-boot/u-boot.bin --fdt ../work/u-boot/arch/riscv/dts/starfive_visionfive2.dtb
创建 workshop/VisionFive2/payload_image.its
:
/dts-v1/;
/ {
description = "U-boot-spl FIT image for JH7110 VisionFive2";
#address-cells = <2>;
images {
firmware {
description = "u-boot";
data = /incbin/("./rustsbi/target/riscv64imac-unknown-none-elf/release/rustsbi-prototyper-payload.bin");
type = "firmware";
arch = "riscv";
os = "u-boot";
load = <0x0 0x40000000>;
entry = <0x0 0x40000000>;
compression = "none";
};
};
configurations {
default = "config-1";
config-1 {
description = "U-boot-spl FIT config for JH7110 VisionFive2";
firmware = "firmware";
};
};
};
生成 visionfive2_fw_payload.img
:
$ cd workshop/VisionFive2
$ mkimage -f payload_image.its -A riscv -O u-boot -T firmware visionfive2_fw_payload.img
假设你的对应磁盘路径为 /dev/sda
,按如下命令使用 dd
工具进行烧写即可:
$ cd workshop
$ dd if=./debian_image.img of=/dev/sda