2 个版本
使用旧的 Rust 2015
0.7.2 | 2018 年 10 月 23 日 |
---|---|
0.7.1 | 2018 年 9 月 24 日 |
在 Cargo 插件 中排名 #367
93KB
2K SLoC
cargo-fel4
概述
用于自动化的 feL4(Rust 的 seL4)开发 cargo 子命令
cargo-fel4
通过自动化构建底层的 seL4 代码库、生成可用的 Rust 绑定以及提供将代码集成到可运行的 seL4 应用程序的方法,旨在加快 seL4 环境中 Rust 开发的速度。
安装后,使用 cargo fel4 new my-project
创建一个新的 feL4 项目,这是一个具有一些额外配置装饰的常规 Rust no_std
库项目。
在该项目中,运行 cargo fel4 build
将生成一个包装来自 src/lib.rs
的库代码的 seL4 应用程序,而 cargo fel4 simulate
将运行它。
目前通过 libsel4-sys 库 访问 seL4 能力,这是一个围绕 seL4 的薄绑定层。此包装器根据您的 feL4 项目设置构建和配置,存储在您的项目的 fel4.toml
清单文件中。
feL4 项目附带一个示例 基于属性的测试套件,以演示如何在 feL4 环境中进行测试。使用 cargo fel4 test build && cargo fel4 test simulate
尝试它
cargo-fel4 的发布特别感谢并归功于 Robigalia,特别是他们的启动汇编代码和示例约定 W.R.T. 语言项,以及当然,Data61 等 seL4。
入门指南
依赖项
cargo-fel4
在运行时依赖于其他几个工具,因此您需要安装 Rust、Cargo、Xargo 和 QEMU 来构建和运行 feL4 项目。此外,feL4 还依赖于 libsel4-sys crate,它有一组自己的依赖项。以下“构建”步骤中的一些实际上是针对满足 libsel4-sys
依赖项而特定的。cargo-fel4
是在 Ubuntu Xenial 上开发的,但其他 Linux 发行版也应适用。
- rust (nightly)
- xargo (用于交叉编译)
- gcc/g++ 交叉编译器 (用于 ARM 目标)
- qemu (用于模拟)
- dfu-util (用于设备部署)
构建
以下说明涵盖了安装 libsel4-sys
和 cargo-fel4
依赖项以及构建 cargo-fel4
的步骤。
- 安装系统包依赖项
sudo apt-get install python-pip ninja-build libxml2-utils dfu-util curl sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf sudo apt-get install qemu-system-x86 qemu-system-arm
- 安装 pip 包依赖项
sudo pip install cmake sel4-deps
- 安装 Rust nightly 和其他组件
curl https://sh.rustup.rs -sSf | sh rustup install nightly rustup component add rust-src cargo install xargo
- 构建
cargo-fel4
cargo build
安装
构建完成后,可以使用 cargo install
命令安装 cargo-fel4
。
- 在 nightly 工具链下安装
cargo +nightly install cargo-fel4
用法
要获取更多详细信息,请查看 cargo fel4 --help
的输出。
cargo fel4 --help
A cargo subcommand for automating feL4 (seL4 for Rust) development
USAGE:
cargo fel4 <SUBCOMMAND>
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
SUBCOMMANDS:
build Build a feL4 project
clean Remove generated artifacts
deploy Deploy a feL4 project
help Prints this message or the help of the given subcommand(s)
new Create a new feL4 project
simulate Simulate a feL4 project with QEMU
test Build and run feL4 tests
示例
-
创建新的 feL4 项目
要使用 cargo-fel4 创建新项目
cargo fel4 new my-project Created library `my-project` project $ tree my-project/ my-project/ ├── Cargo.toml ├── fel4.toml ├── src │ ├── fel4_test.rs │ └── lib.rs ├── target_specs │ ├── armv7-sel4-fel4.json │ ├── README.md │ └── x86_64-sel4-fel4.json └── Xargo.toml
-
构建 feL4 项目
使用 cargo-fel4 构建feL4项目
cd my-project/ cargo fel4 build
-
模拟 feL4 项目
通过 cargo-fel4 使用 QEMU 模拟 feL4 项目
cd my-project/ cargo fel4 simulate
-
部署 feL4 项目
使用 cargo-fel4 在目标平台上部署 feL4 项目
cd my-project/ cargo fel4 deploy
-
运行测试
cargo-fel4 在创建新项目时会生成一组基本的属性测试。
cargo fel4 test
仅构建 feL4 测试应用程序
cargo fel4 test build
模拟先前构建的 feL4 测试应用程序
cargo fel4 test simulate
部署 feL4 测试应用程序
cargo fel4 test deploy
-
在 TX1 平台上进行 DFU 部署
要通过 DFU 部署 feL4 应用程序,请确保已设置串行连接,以便与 U-Boot 引导加载程序交互。
将 USB 线的 USB-mini 端连接到 TX1 的 USB-mini 端口。然后连接 TX1 的电源并开启电源。
TX1 开启电源后,请监视串行输出,以便在 U-boot 命令提示符处停止引导过程。
然后在 U-boot 命令提示符下,输入以下命令
setenv dfu_alt_info "kernel ram 0x83000000 0x1000000" setenv bootcmd_dfu "dfu 0 ram 0; go 0x83000000" saveenv
要使 U-boot 进入其 DFU 服务器模式,请输入
run bootcmd_dfu
U-boot 将等待上传图像。
您现在可以从主机机器部署 cargo-fel4 应用程序镜像
cargo fel4 deploy
-
配置
cargo-fel4 通过
fel4.toml
清单文件进行配置。该清单文件负责指定 cargo-fel4 基础设施的较高级别配置,以及底层
libsel4-sys
软件包的 CMake 构建系统。在
fel4.toml
中指定的布尔属性在cargo fel4 build
时作为 Rust 功能应用于 feL4 项目,因此可以进行编译时配置,以考虑可用的 seL4 选项的变体。fel4.toml
清单文件位于项目的根目录中,包含与输入/输出工件位置相关的几个属性。这些路径属性相对于项目根目录。例如,一个新创建的 feL4 项目在
fel4.toml
中包含以下内容:[fel4] artifact-path = "artifacts" target-specs-path = "target_specs" ...
在 cargo-fel4 构建过程中生成的输出工件将放置在由
artifact-path
属性指定的目录中。可用于 cargo-fel4 的目标规范文件位于由
target-specs-path
属性指定的目录中。cargo fel4 new my-project # The fel4.toml is generated at the project's root directory my-new-project/fel4.toml # Output artifacts produced by the build my-new-project/artifacts/ # Rust target specifications available to cargo-fel4 my-new-project/target_specs/
当更改 Rust 目标三元组或平台配置时,建议清理构建缓存。这可以通过 cargo-fel4 完成。
cargo fel4 clean
有关更多配置信息,请参阅 fel4-config 和 libsel4-sys 软件包。
有关 cargo-fel4 附加的规范的信息,请参阅目标规范 README。
测试
cargo-fel4
使用标准的 Rust 测试框架管理自己的测试,并使用 proptest
进行基于属性的测试。
构建
构建测试就像这样简单
cargo build --tests
运行
运行 cargo-fel4
的测试(与给定 feL4 项目中的测试相反)需要安装前面列出的标准依赖项。cargo-fel4
的内部测试可以通过运行以下命令进行测试
cargo test
许可协议
有关详细信息,请参阅 LICENSE 文件。
依赖项
~5–15MB
~165K SLoC