Rust for Embedded Targets
A few notes on compiling embedded targets with Rust.
The rustup installer supports adding targets:
-
https://rust-lang.github.io/rustup/
e.g.
RUN rustup target add riscv32imac-unknown-none-elf
There are many embedded targets:
-
https://doc.rust-lang.org/nightly/rustc/platform-support.html
e.g.
riscv32imac-unknown-none-elf
andthumbv6m-none-eabi
are Tier 2
A bare-metal no_std
“crate attribute” is defined:
- https://docs.rust-embedded.org/book/intro/no-std.html
- https://stackoverflow.com/questions/27454761/what-is-a-crate-attribute-and-where-do-i-add-it
With no_std
:
- A
panic_handler
is needed https://doc.rust-lang.org/nomicon/panic-handler.html - https://os.phil-opp.com/freestanding-rust-binary/
Using inline Assembler:
- https://doc.rust-lang.org/beta/unstable-book/library-features/asm.html
- https://github.com/rust-lang/rust/issues/72016
- https://docs.rust-embedded.org/embedonomicon/asm.html
Linker for bare-metal:
Raw Pointers
- https://docs.rust-embedded.org/embedonomicon/main.html
- https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html
Cargo Build System:
Subscribe via RSS