2 个稳定版本
1.10.0 | 2019年9月8日 |
---|---|
1.9.0 | 2019年9月3日 |
#236 in 无标准库
用于 2 crates
19MB
197K SLoC
包含 (静态库,3MB) libarm_cortexM3l_math.a,(静态库,3MB) libarm_cortexM4l_math.a,(静态库,3MB) libarm_cortexM4lf_math.a,(自动工具混淆代码,1MB) configure,(模糊 autoconf 代码,59KB) configure.ac
Rust 对 card10 CCCamp19 徽章的支持
准备你的 card10
解锁不再是必需的!
从固件 v1.9 开始,运行 ELF 可执行文件需要包含以下内容的 /card10.cfg
execute_elf=true
预构建的二进制文件
得益于 Gitlab 的 CI 系统和 NixOS,我们为您构建了 .elf
文件,可以直接放入 card10 徽章的 apps/
目录。
对于本仓库中的每个提交,我们还会构建包含所需配置和示例二进制文件的完整固件镜像。
https://git.card10.badge.events.ccc.de/astro/rust-card10/-/jobs
先决条件
您需要 Rust 夜间版本和一个可编译 card10 固件(包括匹配的 libc)的工作环境。
-
有关如何设置 rust 的说明,请参阅 https://rustup.rs。
请确保您已安装最新的 rust 夜间工具链,并添加
thumbv7em-none-eabi
目标。rustup toolchain install nightly rustup update rustup target add thumbv7em-none-eabi --toolchain nightly
-
有关如何设置 card10 固件的说明,请查看 https://firmware.card10.badge.events.ccc.de/how-to-build.html 中的依赖性章节。
-
此外,您可能还需要 llvm 和 libc i386 开发头文件的软件包。
-
使用
--recursive
克隆此仓库以获取子模块,否则之后更新它们git submodule update --init --recursive
构建和运行 Rust 可加载程序
设置
如果您想创建自己的基于 Rust 的可加载程序 crate,则需要做一些准备工作
-
设置新的 crate 仓库。
-
将
card10-l0dable = "^0.1"
添加为新crate的依赖项。 -
修改你
Cargo.toml
文件中默认的 cargo 发布配置。[profile.release] opt-level = "s" panic = "abort"
-
在
$PROJECT/.cargo/config
中创建(或更新)thumbv7em-none-eabi
目标配置,并使用以下rustflags[target.thumbv7em-none-eabi] rustflags = [ "-C", "linker=arm-none-eabi-gcc", "-C", "link-args=-Tl0dable.ld -n -pie -fPIC", "-C", "relocation-model=pic", ] [build] target = "thumbv7em-none-eabi"
-
确保你的crate被标记为
non_std
项目,并且让card10-l0dable
了解你的自定义main函数。这需要在你的main.rs
文件中进行以下更新。#![no_std] #![no_main] use card10_l0dable::main; main!(main); fn main() {}
编译
使用nightly工具链并定义正确的目标来编译项目。
cargo +nightly build --release --target thumbv7em-none-eabi
转移到card10
然后,将目标目录 target/thumbv7em-none-eabi/release/example
中的结果可执行文件复制到你的徽章的 apps
目录。
注意:需要将可执行文件重命名为添加 elf
扩展名(例如,将 example
重命名为 example.elf
)。
Crates
Crate | 文档 | 描述 |
---|---|---|
card10-sys | docs.rs | 为l0dables提供不安全的C绑定 |
card10-alloc | docs.rs | 为l0dables提供alloc::*支持 |
card10-l0dable | docs.rs | 构建l0dables的高层crate |
example | l0dable示例 | |
rkanoid | Arkanoid克隆 | |
draw-image | 将静态图像绘制到显示屏的示例 |
杂项
如何更新固件绑定
-
将
card10-sys/firmware
子模块更新到最新的固件状态。 -
按照上述方法重新构建固件。
-
从项目根目录运行以下脚本
python card10-sys/firmware/epicardium/api/genapi.py -H card10-sys/firmware/epicardium/epicardium.h -c card10-sys/vendor/client.c -s card10-sys/vendor/server.c
-
重新构建你的应用 :)
lib.rs
:
此文件与card10 EPIC API客户端C代码链接。