Raspberry PI Pico with Embassy

After I failed to do http requests in Micropython as described in a previous post, I felt like it is time to try Rust on the Raspberry PI Pico. Installing code on the Pico with Rust can be done using UF2 as with Micropython. But because there is no REPL there is no way to see the outputs of the program this way. So using a Debugprobe as described in the Embassy getting started is a good plan.

We need to prepare a second Pico as Debugprobe. The UF2 needed for this can be build as described in Appendix A of the Getting started with Raspberry Pi Pico. But this is not neccessary because there is already a version available that can be easily flashed on the Pico by dragging it on the Pico filesystem after button-press connecting it to your computer.

Now lets build an example firmware with Embassy. Important here there are two versions of blinky: blinky.rs is for the Pico and the wifi_blinky.rs Pico W. I have a Pico W connected so I did this to compile (as described in the Getting started:

# setup rust (on Archlinux)
sudo pacman -S rustup cargo-binstall
# choose stable rust
rustup default stable

git clone https://github.com/embassy-rs/embassy.git
cd embassy/examples/rp
# build pico W example
cargo build --bin wifi_blinky --release

# install probe-rs software - the binary will land in ~/.cargo/bin/probe-rs
cargo binstall probe-rs

Wire the debugprobe Pico to the Pico we want to get our code on. My version of this:


In the Appendix A of the Getting started with Raspberry Pi Pico is a lot better version than my photo!

I don't want to use sudo to use the debugprobe, so we need a udev rule. This is described in the getting started of probe-rs:

curl https://probe.rs/files/69-probe-rs.rules > 69-probe-rs.rules
sudo mv 69-probe-rs.rules /etc/udev/rules.d
sudo udevadm control --reload
sudo udevadm trigger

Check that probe-rs is finding the debugprobe Pico:

~/.cargo/bin/probe-rs list
# should return:
[0]: Debugprobe on Pico (CMSIS-DAP) (VID: 2e8a, PID: 000c, Serial: E660C06213776B27, CmsisDap

Finally run the blinky example:

cargo run --bin wifi_blinky --release