Skip to content

Creating a new binary project

Joël Bourgault edited this page Jul 27, 2025 · 1 revision

Creating a binary project

To initiate a new project for a board, that will use its Board Support Package, for instance for arduino_MKR1000:

  1. Pick one of BSP examples; for instance: blinky_rtic

  2. From the BSP Cargo.toml:

    • Check which features are required for the chosen example; here rtic and unproven.
    • 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"]
    
    (...)
  3. Start a new Rust binary project:

    cargo new --bin my-great-prj
  4. Copy the code from the chosen example of the said board, and paste it to replace src/main.rs content.

  5. Update the newly-created project Cargo.toml, so that:

    • the BSP package is imported with relevant features, here rtic and unproven
    • setting package.metadata.chip is also taken from source Cargo.toml
    • and any other dependency related to the example; in chosen example (reminder: blinky_rtic), crate cortex-m-rtic is needed as a dependency, as indicated in the example documentation.
  6. 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
  7. Flash your target and enjoy!

Clone this wiki locally