Skip to content

Repository of Raspberry Pi Pico with Rust πŸ¦€ + Embassy Framework

Notifications You must be signed in to change notification settings

PicoNexus/rp2040-rust

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Raspberry Pi Pico RP2040 + Embassy Rust Template


Module


Getting Started:

Cloning the Repository

  • git clone this repository with this command:
    git clone --recurse-submodules https://github.com/tutla53/rp2040.git 
  • If you didn't use a --recursive git clone, then you need to make sure that embassy-rs is fetched now. From the top level apply one of:
    git submodule update --init --recursive   # First time
    git submodule update --recursive          # Subsequent

Installing the Module

Move to the Project Directory template:

cd rp2040-rust/template/

Adding the Build Target

Run this following command to add the build target:

rustup target add thumbv6m-none-eabi

Adding probe-rs Package

Installation
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/probe-rs/probe-rs/releases/latest/download/probe-rs-tools-installer.sh | sh
⚠️ WARNING
Make sure that you didn’t accidentally run cargo add probe-rs (which adds it as a dependency) instead of correctly installing probe-rs

Installing elf2uf2-rs Package

Dependency
sudo apt install -y pkg-config libusb-1.0-0-dev libftdi1-dev && sudo apt-get install libudev-dev
Installation
cargo install elf2uf2-rs

Build and Run the First Program

Build

cargo build --release

Run

Please select one of the runner on the .cargo/config.toml

[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "probe-rs run --chip RP2040"  # Directly Flash with Debug Probe
runner = "elf2uf2-rs -d"               # Automatic deployment to a mounted Pico
runner = "elf2uf2-rs"                  # Only create uf2 file and can be flashed to pico by pressing the bootsel button

The run the following code:

cargo run --release

The compiled elf and uf2 file will be in the target/thumbv6m-none-eabi/release/rp2040-template

Run the Example from embassy-rs

You can run the example from the embassy-rs which located at src/bin by using this following command:

cargo run --bin {project_name} --release
cargo run --bin blinky --release # Example to run blinky.rs

How to Use the Template

Project Structure

.
β”œβ”€β”€ main.rs                                                                                                                                                                  β”œβ”€β”€ 
β”œβ”€β”€ builder
β”‚Β Β  β”œβ”€β”€ mod.rs
β”‚Β Β  β”œβ”€β”€ servo_builder.rs
β”‚Β Β  └── servo_pio_builder.rs
β”œβ”€β”€ resources
β”‚Β Β  β”œβ”€β”€ gpio_list.rs
β”‚Β Β  └── mod.rs
└── tasks
    β”œβ”€β”€ fade.rs
    β”œβ”€β”€ mod.rs
    β”œβ”€β”€ servo_pio.rs
    └── servo.rs

About

Repository of Raspberry Pi Pico with Rust πŸ¦€ + Embassy Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 99.7%
  • RPC 0.3%