dazgupta.com > posts.xml 2> journal.xml

Raspberry Pico + Rust

I started working with the Raspberry Pi Pico. Managed to build code with Rust on top of rp-hal, which is an excellent library with a tonne of examples. I got the build toolchain running on WSL, but the conversion from ELF to UF2 was a the only hiccup because the way normal rp-hal configuration was using elf2uf2-rs, didn't work. elf2uf2-rs is designed to work with USB devices running on the host machine, but that's not the case on WSL. So I ended up configuring the target in .cargo/config.

[target.thumbv6m-none-eabi]
runner = "./runner.sh"

While runner.sh being

#!/bin/sh
mkdir -p ./target/publish/
elf2uf2-rs $1 ./target/publish/image.uf2

This basically, instead of trying to directly dump the UF2 binary into the Pico, it puts in a directory target/publish, which then can be copied like a file to the Raspi Pico when it's mounted as a USB mass storage device on Windows. This made the building the code very straightforward.

But given I have a normal Raspberry Pi (3) lying around, I can also use that as a host machine; which is what I might end up doing, or at least for uploading the binaries to the Pico via the probe / directly over USB.

And after all that, I did some research, I the found MicroPython API to be rather sane, so I might just end up using that. It's officially supported and has a lot of build / running tools to make coding the Pico rather easy. So that might be my go to language for programming Raspberry Pico.

04-02-2024