-
Notifications
You must be signed in to change notification settings - Fork 216
Creating a new binary project
Joël Bourgault edited this page Jul 27, 2025
·
1 revision
To initiate a new project for a board, that will use its Board Support Package, for instance for arduino_MKR1000
:
-
Pick one of BSP examples; for instance:
blinky_rtic
-
From the BSP
Cargo.toml
:- Check which features are required for the chosen example; here
rtic
andunproven
. - Check content of
package.metadata.chip
; here"ATSAMD21G18A"
.
# in boards/arduino_mkr1000/Cargo.toml (...) [package.metadata] chip = "ATSAMD21G18A" (...) [[example]] name = "blinky_rtic" required-features = ["rtic", "unproven"] (...)
- Check which features are required for the chosen example; here
-
Start a new Rust binary project:
cargo new --bin my-great-prj
-
Copy the code from the chosen example of the said board, and paste it to replace
src/main.rs
content. -
Update the newly-created project
Cargo.toml
, so that:- the BSP package is imported with relevant features, here
rtic
andunproven
- setting
package.metadata.chip
is also taken from sourceCargo.toml
- and any other dependency related to the example; in chosen example (reminder:
blinky_rtic
), cratecortex-m-rtic
is needed as a dependency, as indicated in the example documentation.
- the BSP package is imported with relevant features, here
-
Copy the
boards/{target board}/.cargo/config.toml
file as.cargo/config.toml
in the newly created project.Failure to do so may result in following compilation error:
$ cargo build Compiling my-great-prj v0.1.0 (/home/joel/dev/électronique/my-great-prj) error: unwinding panics are not supported without std | = help: using nightly cargo, use -Zbuild-std with panic="abort" to avoid unwinding = note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem
-
Flash your target and enjoy!