|
1 hete | |
---|---|---|
.. | ||
bench-kernel | 2 hete | |
docs | 1 hete | |
prototyper | 1 hete | |
test-kernel | 1 hónapja | |
.gitignore | 1 hónapja | |
.pre-commit-config.yaml | 1 hónapja | |
CHANGELOG.md | 1 hónapja | |
README.md | 3 hete | |
_typos.toml | 1 hónapja | |
cliff.toml | 1 hónapja |
RustSBI Prototyper is a developing RISC-V Secure Bootloader solution. It can be integrated with the Rust or C language ecosystem to form a complete RISC-V bootloader ecosystem.
Before compiling, ensure the following packages are installed:
cargo install cargo-binutils
sudo apt install u-boot-tools
These are necessary for building the firmware and handling RISC-V binary outputs.
The following command compiles the RustSBI Prototyper bootloader with optional settings:
cargo prototyper [OPTIONS]
This builds the firmware based on the provided options (or defaults if none are specified). The resulting files—such as .elf
executables and .bin
binaries—are generated in the target/riscv64imac-unknown-none-elf/release/
directory under your project root. See the "Firmware Compilation" section for specific outputs and modes.
These are necessary for building the firmware and handling RISC-V binary outputs.
-f, --features <FEATURES>
--features "feat1,feat2"
).--fdt <PATH>
PROTOTYPER_FDT_PATH
]--payload <PATH>
PROTOTYPER_PAYLOAD_PATH
]--jump
-c, --config-file <PATH>
-v, --verbose
-q, --quiet
-h, --help
Note on FDT Files
Regardless of the mode (Dynamic Firmware, Payload Firmware, or Jump Firmware), specifying an FDT file with
--fdt
ensures it is used to initialize the hardware platform configuration. The FDT file provides essential hardware setup details and overrides the bootloader’s default settings.
Compilation Command:
Use this command to compile firmware that dynamically loads payloads:
cargo prototyper
Output:
Once compiled, the firmware files will be located in the target/riscv64imac-unknown-none-elf/release/
directory under your project root:
rustsbi-prototyper-dynamic.elf
(ELF executable)rustsbi-prototyper-dynamic.bin
(Binary file)Compilation Command:
Build firmware with an embedded payload:
cargo prototyper --payload <PAYLOAD_PATH>
Output:
After compilation, the resulting firmware files are generated in the target/riscv64imac-unknown-none-elf/release/
directory:
rustsbi-prototyper-payload.elf
rustsbi-prototyper-payload.bin
Compilation Command:
Build firmware for jump mode:
cargo prototyper --jump
Output:
After compilation, the resulting firmware files are generated in the target/riscv64imac-unknown-none-elf/release/
directory:
rustsbi-prototyper-jump.elf
rustsbi-prototyper-jump.bin
Customize bootloader parameters by editing default.toml
located at prototyper/config/default.toml
. Example:
num_hart_max = 8
stack_size_per_hart = 16384 # 16 KiB (16 * 1024)
heap_size = 32768 # 32 KiB (32 * 1024)
page_size = 4096 # 4 KiB
log_level = "INFO"
jump_address = 0x80200000
tlb_flush_limit = 16384 # 16 KiB (page_size * 4)
num_hart_max
: Maximum number of supported harts (hardware threads).stack_size_per_hart
: Stack size per hart, in bytes.heap_size
: Heap size, in bytes.page_size
: Page size, in bytes.log_level
: Logging level (TRACE
, DEBUG
, INFO
, WARN
, ERROR
).jump_address
: Target address for jump mode.tlb_flush_limit
: TLB flush limit, in bytes.To use a custom configuration file, specify it with:
cargo prototyper -c /path/to/custom_config.toml
Run the generated firmware in QEMU:
qemu-system-riscv64 \
-machine virt \
-bios target/riscv64imac-unknown-none-elf/release/rustsbi-prototyper-dynamic.elf \
-display none \
-serial stdio
For additional examples, see the docs directory.
See the Required Dependencies under Usage above for the packages needed to compile the RustSBI Prototyper.
These tools are optional but recommended to enhance your development workflow:
A tool to run code checks before committing:
pipx install pre-commit
pre-commit install # Set up pre-commit for the project
A Cargo plugin to audit dependency security:
cargo install --locked cargo-deny
A spell-checking tool for code and documentation:
cargo install typos-cli
A changelog generation tool:
cargo install git-cliff
This project is dual-licensed under MIT or Mulan-PSL v2. See LICENSE-MIT and LICENSE-MULAN for details.