Measuring the CO2 levels at a local club (with permission)
Find a file
2022-09-21 19:02:58 +08:00
.cargo Add flip-link for zero-cost stack overflow protection 2022-09-09 21:40:32 +08:00
.vscode Initial skeleton commit 2022-09-08 09:22:35 +08:00
src Initial skeleton commit 2022-09-08 09:22:35 +08:00
.gitignore Initial skeleton commit 2022-09-08 09:22:35 +08:00
Cargo.lock Allow flashing using DapperMime RP2040 probe 2022-09-09 14:26:11 +08:00
Cargo.toml Allow flashing using DapperMime RP2040 probe 2022-09-09 14:26:11 +08:00
memory.x Allow flashing using DapperMime RP2040 probe 2022-09-09 14:26:11 +08:00
README.md Update README.md 2022-09-21 19:02:58 +08:00
rust-toolchain.toml Initial skeleton commit 2022-09-08 09:22:35 +08:00

Embassy RP Skeleton

The Embassy RP Skeleton repository is a project template intended as a starting point for developing your own firmware for the rp2040 based on the embassy asynchronous embedded development framework for Rust.

It includes all of the knurling-rs tooling (defmt, defmt-rtt, panic-probe, flip-link, probe-run) to enhance the embedded development process.

The default cargo runner is configured as probe-run, so you can build, flash and run your firmware with output from the device via a CMSIS-DAP compatible debug probe with the command:

$ cargo run

If you want to use a different runner with your debugger (e.g., cargo-embed, probe-rs-debugger, etc.) or if you aren't using a debugger and want the runner to flash the firmware via USB (e.g., elf2uf2-rs, picotool, etc.) then see: Alternative Runners

Table of Contents

  1. Requirements
  2. Setup
    1. System Setup
    2. Probe Setup
    3. Hardware Setup
  3. Usage
  4. Appendix

Requirements

  • Ubuntu
  • Raspberry Pi Pico
  • CMSIS-DAP Debugger Probe (or another Raspberry Pi Pico)
  • Rust Toolchain (cargo, rustup)

Setup

System Setup

  1. Install Rust and cargo using rustup
# Install `rustup` for Rust Toolchain
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  1. Install Cortex-M Target Toolchain Support for Rust
# Install `thumbv6m-none-eabi` Target for `rp2040`
$ rustup target add thumbv6m-none-eabi
  1. Install probe-run
# Install Linux Dependencies
$ sudo apt install -y libusb-1.0-0-dev libudev-dev

# Install `probe-run`
$ cargo install probe-run

# (Optional) Install `udev` Rules and Reload
$ sudo curl https://probe.rs/files/69-probe-rs.rules -o /etc/udev/rules.d/69-probe-rs.rules
$ sudo udevadm control --reload
$ sudo udevadm trigger

# (Optional) Add User to `plugdev` Group
$ sudo usermod -aG plugdev $USER
  1. Install flip-link
# Install `flip-link`
$ $ cargo install flip-link

Probe Setup

You can use a Raspberry Pi Pico as a CMSIS-DAP compatible debug probe.

  1. Download CMSIS-DAP debugger firmware DapperMime for the Raspberry Pi Pico
  2. Boot the Raspberry Pi Pico in "Bootloader Mode" by holding the BOOTSEL button while plugging it in
  3. Open the mounted Raspberry Pi Pico storage device
  4. Copy the raspberry_pi_pico-DapperMime.uf2 onto the Raspberry Pi Pico
  5. Firmware will be flashed to the Raspberry Pi Pico and it will disconnect

Any CMSIS-DAP compatible debugger probe can be used with probe-run. A short list of compatible debug probes is available here: Alternative Debug Probes.

Hardware Setup

TODO

  • Connecting the debugger (image, link to pdf)
  • Raspberry Pi Pico development board

Usage

To run the firmware in debug mode:

$ cargo run

To run the firmware in release mode:

$ cargo run --release

To change the default defmt log level, see .cargo/config.toml:

[env]
DEFMT_LOG = "trace"

You can also set the log level inline:

$ DEFMT_LOG=debug cargo run
$ DEFMT_LOG=error cargo run --release

Appendix

TODO

  • Links, resources, references and guides