Template repository for Embedded Rust development
This template is configured for thumbv8m.main-none-eabihf, by default, but you can modify it for other targets (i.e. aarch64-unknown-none):
- VSCode Settings: Update the target in
.vscode/settings.json:"rust-analyzer.cargo.target": "your-target-architecture"
This configuration ensures that:
- Only the specified target architecture is analyzed, not the host platform
- Code is checked against the no_std environment
To temporarily analyze code for the host platform instead, you can remove the rust-analyzer.cargo.target setting.
-
GitHub Workflows: Modify the target in two workflow files:
.github/workflows/nostd.yml: Update the targets in the matrix:matrix: target: [your-target-architecture]
.github/workflows/check.yml: If there are any target-specific checks, update them accordingly.
-
Cargo Configuration: If needed, you can add target-specific configuration in a
.cargo/config.tomlfile.
To convert this project from a binary to a library:
-
Cargo.toml: Update your project structure:
[lib] name = "your_library_name"
-
Directory Structure:
- For a library, ensure you have a
src/lib.rsfile instead ofsrc/main.rs - Move your code from
main.rstolib.rsand adjust as needed
- For a library, ensure you have a
-
No-std Configuration: If you're creating a no-std library, ensure you have:
// In lib.rs #![cfg_attr(target_os = "none", no_std)] // Add other attributes as needed
Update the dependencies in Cargo.toml based on your target platform:
[dependencies]
# Common dependencies for all targets
[target.'cfg(target_os = "none")'.dependencies]
# Dependencies for no-std targets