Home

Awesome

Project template for rp2040-hal

This template is intended as a starting point for developing your own firmware based on the rp2040-hal.

It includes all of the knurling-rs tooling as showcased in https://github.com/knurling-rs/app-template (defmt, defmt-rtt, panic-probe, flip-link) to make development as easy as possible.

probe-rs is configured as the default runner, so you can start your program as easy as

cargo run --release

If you aren't using a debugger (or want to use other debugging configurations), check out alternative runners for other options

<!-- TABLE OF CONTENTS --> <details open="open"> <summary><h2 style="display: inline-block">Table of Contents</h2></summary> <ol> <li><a href="#markdown-header-requirements">Requirements</a></li> <li><a href="#installation-of-development-dependencies">Installation of development dependencies</a></li> <li><a href="#running">Running</a></li> <li><a href="#alternative-runners">Alternative runners</a></li> <li><a href="#notes-on-using-rp2040_boot2">Notes on using rp2040_boot2</a></li> <li><a href="#feature-flags">Feature flags</a></li> <li><a href="#roadmap">Roadmap</a></li> <li><a href="#contributing">Contributing</a></li> <li><a href="#code-of-conduct">Code of conduct</a></li> <li><a href="#license">License</a></li> <li><a href="#contact">Contact</a></li> </ol> </details> <!-- Requirements --> <details open="open"> <summary><h2 style="display: inline-block" id="requirements">Requirements</h2></summary> </details> <!-- Installation of development dependencies --> <details open="open"> <summary><h2 style="display: inline-block" id="installation-of-development-dependencies">Installation of development dependencies</h2></summary>
rustup target install thumbv6m-none-eabi
cargo install flip-link
# Installs the probe-rs tools, including probe-rs run, our recommended default runner
cargo install --locked probe-rs-tools
# If you want to use elf2uf2-rs instead, do...
cargo install --locked elf2uf2-rs

If you get the error binary `cargo-embed` already exists during installation of probe-rs, run cargo uninstall cargo-embed to uninstall your older version of cargo-embed before trying again.

</details> <!-- Running --> <details open="open"> <summary><h2 style="display: inline-block" id="running">Running</h2></summary>

For a debug build

cargo run

For a release build

cargo run --release

If you do not specify a DEFMT_LOG level, it will be set to debug. That means println!(""), info!("") and debug!("") statements will be printed. If you wish to override this, you can change it in .cargo/config.toml

[env]
DEFMT_LOG = "off"

You can also set this inline (on Linux/MacOS)

DEFMT_LOG=trace cargo run

or set the environment variable so that it applies to every cargo run call that follows:

Linux/MacOS/unix

export DEFMT_LOG=trace

Setting the DEFMT_LOG level for the current session
for bash

export DEFMT_LOG=trace

Windows

Windows users can only override DEFMT_LOG through config.toml or by setting the environment variable as a separate step before calling cargo run

set DEFMT_LOG=trace
$Env:DEFMT_LOG = trace
cargo run
</details> <!-- ALTERNATIVE RUNNERS --> <details open="open"> <summary><h2 style="display: inline-block" id="alternative-runners">Alternative runners</h2></summary>

If you don't have a debug probe or if you want to do interactive debugging you can set up an alternative runner for cargo.

Some of the options for your runner are listed below:

</details> <!-- Notes on using rp2040_hal and rp2040_boot2 --> <details open="open"> <summary><h2 style="display: inline-block" id="notes-on-using-rp2040_boot2">Notes on using rp2040_boot2</h2></summary>

The second-stage boot loader must be written to the .boot2 section. That is usually handled by the board support package (e.g.rp-pico). If you don't use one, you should initialize the boot loader manually. This can be done by adding the following to the beginning of main.rs:

use rp2040_boot2;
#[link_section = ".boot2"]
#[used]
pub static BOOT_LOADER: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080;
</details> <!-- Feature flags --> <details open="open"> <summary><h2 style="display: inline-block" id="feature-flags">Feature flags</h2></summary>

There are several feature flags in rp2040-hal. If you want to enable some of them, uncomment the rp2040-hal dependency in Cargo.toml and add the desired feature flags there. For example, to enable ROM functions for f64 math using the feature rom-v2-intrinsics:

rp2040-hal = { version="0.10", features=["rt", "critical-section-impl", "rom-v2-intrinsics"] }
</details> <!-- ROADMAP -->

Roadmap

NOTE These packages are under active development. As such, it is likely to remain volatile until a 1.0.0 release.

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

The steps are:

  1. Fork the Project by clicking the 'Fork' button at the top of the page.
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Make some changes to the code or documentation.
  4. Commit your Changes (git commit -m 'Add some AmazingFeature')
  5. Push to the Feature Branch (git push origin feature/AmazingFeature)
  6. Create a New Pull Request
  7. An admin will review the Pull Request and discuss any changes that may be required.
  8. Once everyone is happy, the Pull Request can be merged by an admin, and your work is part of our project!

Code of Conduct

Contribution to this crate is organized under the terms of the Rust Code of Conduct, and the maintainer of this crate, the rp-rs team, promises to intervene to uphold that code of conduct.

License

The contents of this repository are dual-licensed under the MIT OR Apache 2.0 License. That means you can chose either the MIT licence or the Apache-2.0 licence when you re-use this code. See MIT or APACHE2.0 for more information on each specific licence.

Any submissions to this project (e.g. as Pull Requests) must be made available under these terms.

Contact

Raise an issue: https://github.com/rp-rs/rp2040-project-template/issues Chat to us on Matrix: #rp-rs:matrix.org