1 个不稳定版本
0.1.0 | 2022 年 8 月 25 日 |
---|
#990 在 硬件支持 中
1,510 星 & 37 个关注者
2KB
oreboot README
oreboot 是 coreboot 的下游分支,即 oreboot 是没有 'c' 的 coreboot。
oreboot 主要使用 Rust 编写,必要时使用汇编语言。
oreboot 目前仅计划支持 LinuxBoot 负载。
演示
来自 Allwinner D1 的 oreboot 输出样本
oreboot 🦀
v 13
cpu_pll fa001000
cpu_axi 5000100
cpu_axi 5000100
peri0_ctrl was: f8216300
peri0_ctrl lock en
peri0_ctrl PLLs
peri0_ctrl set: f8216300
DDR3@792MHz
test OK
512M 🐏
NOR flash: c2/2018
load 00018000 bytes to 40000000: ➡️.
load 00fc0000 bytes to 44000000: ➡️➡️➡️➡️➡️➡️➡️➡️➡️➡️➡️➡️➡️➡️➡️➡️.
load 00010000 bytes to 41a00000: ➡️.
{ɕ serial uart0 initialized
RISC-V vendor 5b7 arch 0 imp 0
==== platform CSRs ====
MXSTATUS c0408000
MHCR 00000109
MCOR 00000002
MHINT 00004000
see C906 manual p581 ff
=======================
Set up extension CSRs
==== platform CSRs ====
MXSTATUS c0638000
MHCR 0000017f
MCOR 00000003
MHINT 0000610c
see C906 manual p581 ff
=======================
timer init
reset init
ipi init
RustSBI version 0.3.1
.______ __ __ _______.___________. _______..______ __
| _ \ | | | | / | | / || _ \ | |
| |_) | | | | | | (----`---| |----`| (----`| |_) || |
| / | | | | \ \ | | \ \ | _ < | |
| |\ \----.| `--' |.----) | | | .----) | | |_) || |
| _| `._____| \______/ |_______/ |__| |_______/ |______/ |__|
Platform Name: T-HEAD Xuantie Platform
Implementation: oreboot version 0.1.0
[rustsbi] misa: RV64ACDFIMSUVX
[rustsbi] mideleg: ssoftstimersext (0x222)
[rustsbi] medeleg: imaialmalasmasauecallipagelpagespage(0xb1f3)
[rustsbi] mie: msoft ssoft mtimer stimer mext sext (00000aaa)
PMP0 0x0 - 0x40000000 (A,R,W,X)
PMP1 0x40000000 - 0x40200000 (A,R)
PMP2 0x40200000 - 0x80000000 (A,R,W,X)
PMP3 0x80000000 - 0x80200000 (A,R)
PMP4 0x80200000 - 0xfffff800 (A,R,W,X)
PMP8 0x0 - 0x0 (A,R,W,X)
DTB looks fine, yay!
Decompress 12375521 bytes from 0x44000004 to 0x40200000, reserved 25165824 bytes
Success, decompressed 21910144 bytes :)
Payload looks like Linux Image, yay!
DTB still fine, yay!
Handing over to SBI, will continue at 0x40200000
enter supervisor at 40200000 with DTB from 41a00000
...
[ 0.000000] OF: fdt: Ignoring memory range 0x40000000 - 0x40200000
[ 0.000000] Machine model: Sipeed Lichee RV Dock
[ 0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
[ 0.000000] printk: bootconsole [sbi0] enabled
[ 0.000000] Zone ranges:
[ 0.000000] DMA32 [mem 0x0000000040200000-0x000000005fffffff]
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000040200000-0x000000005fffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000040200000-0x000000005fffffff]
[ 0.000000] riscv: SBI specification v1.0 detected
[ 0.000000] riscv: SBI implementation ID=0x4 Version=0x301
[ 0.000000] riscv: SBI TIME extension detected
[ 0.000000] riscv: SBI IPI extension detected
[ 0.000000] riscv: SBI SRST extension detected
[ 0.000000] riscv: base ISA extensions acdfim
[ 0.000000] riscv: ELF capabilities acdfim
[ 0.000000] percpu: Embedded 17 pages/cpu s31912 r8192 d29528 u69632
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 128520
[ 0.000000] Kernel command line: console=tty0 console=ttyS0,115200 loglevel=7 earlycon=sbi
Rust 嵌入式
我们基于 Rust Embedded 工作组 的模型构建,其包含 crates 和 traits,详细说明见 他们的书籍。
简单来说:
供应商支持
预期 SoC 供应商提供对其核心、外设和其他模块以及/或其 SVD 文件的文档,以便我们生成 PAC 和 HAL crates,或者最好,供应商应 提供并维护 这些。
Rust Embedded 书籍提供了 设计模式和实现指南 以及一个 术语表,以便了解结构。
引导流程和设置
要了解oreboot及其一般固件的工作原理,请参阅引导流程文档。它描述了固件如何在平台/SoC上存储和启动。
获取oreboot
克隆此存储库并进入其目录,即:
git clone git://github.com/oreboot/oreboot
cd oreboot
先决条件
通常,您需要安装以下软件包
device-tree-compiler
pkg-config
libssl
rustup
对于基于Debian的系统,有一个make目标可以安装这些软件包,它通过curl从https://sh.rustup.rs安装rustup
make debiansysprepare
否则,通过您的系统包管理器安装软件包。
设置工具链
无论您的操作系统是什么,您都需要安装oreboot的工具链。此命令只需要执行一次,但重复执行是安全的。
make firsttime
保持构建工具更新
每次您开始使用oreboot或甚至每天
cd oreboot
make update
在报告任何问题之前,您绝对应该做这件事。
开发oreboot
项目中有两件不同的事情
src/mainboards/*
实际的目标;这些依赖于并共享crates,可以是驱动程序、SoC初始化代码等。对于主板,Cargo.lock
必须跟踪。src/*
其余所有内容;这些都是上述crates,对于这些,我们不跟踪Cargo.lock
文件。
将主板的Cargo.lock
文件签入记录了其依赖项在成功构建时的状态,从而实现了可重复性。理想情况下,锁文件在硬件上成功启动后更新。
在创建新主板时,查看其他人为同一架构设置的配置是一个好的开始。请注意,oreboot针对裸机,因此没有标准库可用。
构建oreboot
要为特定平台构建oreboot,请这样做
# Go to the mainboard's directory
cd src/mainboard/sunxi/nezha
# Build the mainboard target
make mainboard
# View disassembly
make objdump
# Run from RAM without flashing
make run
# Flash to the board
make flash
根Makefile
允许您快速构建所有平台
# build all mainboards
make mainboards
# build everything in parallel
make -j mainboards
QEMU
# Install QEMU for your target platform, e.g. x86
sudo apt install qemu-system-x86
# Build release build and start with QEMU
cd src/mainboard/emulation/qemu-q35 && make run
# Quit qemu with CTRL-A X
为RISC-V从源代码构建QEMU
git clone https://github.com/qemu/qemu && cd qemu
mkdir build-riscv64 && cd build-riscv64
../configure --target-list=riscv64-softmmu
make -j$(nproc)
# QEMU binary is at riscv64-softmmu/qemu-system-riscv64
为aarch64从源代码构建QEMU
git clone https://github.com/qemu/qemu && cd qemu
mkdir build-aarch64 && cd build-aarch64
../configure --target-list=aarch64-softmmu
make -j$(nproc)
# QEMU binary is at aarch64-softmmu/qemu-system-aarch64
主板
与coreboot类似,oreboot的结构按供应商和主板划分。支持多个架构和SoC,并且它们之间的公共代码在板上共享。如果轻微的差异会导致太多的代码重复,则板可能会有变体。
仿真
qemu-riscv
硬件
RISC-V
全志D1 SoC
- 芯海Lichee RV Dock / Dock Pro
- 芒果Pi MQ-Pro
- 东山湖Nezha STU
- 全志Nezha
先前实现
作为参考,早期方法已记录。请查看有关x86和Arm平台和主板的那些。
停放以恢复
早期的仿真目标已被停放在src.broken/mainboard/emulation/
中。它们旨在提供oreboot希望支持的每个架构的一般理解
qemu-armv7
qemu-aarch64
qemu-q35
基本原则
Makefile
应该简单。使用xtask
来控制流程,例如,向二进制文件添加头文件或校验和、调整图像等。- 在相应的
src/mainboard/$VENDOR/$BOARD
(子)目录中的Cargo.toml
允许使用针对特定板卡的依赖,并可以并行构建所有阶段。 - 所有代码和标记都将使用
make format
自动格式化,没有任何例外。CI 检查将告知是否更改不符合格式化规则。 - 不会编写任何 C 语言代码。所有代码都将使用 Rust 语言编写。
- 我们不会运行自己的 Gerrit。目前我们使用 GitHub,并使用 GitHub Pull Request 审查机制。
- 我们不会运行自己的 Jenkins。我们将使用最合适的 CI;目前是 GitHub,但我们将保持灵活性。
版权和许可证
oreboot 的版权属于相当多的个人开发者和公司。请查看各个源文件以获取详细信息。
oreboot 根据 GNU 通用公共许可证 (GPL) 许可。一些文件根据 "GPL (版本 2,或任何更高版本)" 许可,一些文件根据 "GPL,版本 2" 许可。对于一些源自其他项目的部分,可能适用其他(与 GPL 兼容)的许可证。请查看各个源文件以获取详细信息。
这使得生成的 oreboot 图像根据 GPL,版本 2 许可。
依赖项
~145KB