Pi Pico First Steps/References

The Raspberry Pi Pico is a 133MHz dual-core ARM chip that is widely available for under $10, upsetting the usual use cases that I have for Arduinos. It has plenty of IO available (see pinout) and neat features like programmable IO

I went down a couple different paths for initially tinkering with it, so here’s my notes so that I can close all my tabs:

Connectivity

Upon pressing the bootsel button while being connected, the pi exposes a filesystem via USB that can have special uf2 formatted binaries dropped into it. It will then reboot and run the binary.

Python

  • MicroPython (pi pico python sdk reference) is a small embedded version of Python that you can flash onto it
  • Start with getting started
  • Flashing it gives a repl that you can immediately start typing things into, accessing via minicom or otherwise (minicom -b 115200 -o -D /dev/ttyACM0)
  • rshell (pip install rshell) will discover Pi Picos and lets you do things like type repl to access the console
  • You can copy a file (main.py) to by using rshell (cp main.py /pyboard/) and it will be run when the Pi boots up
    • This special file survives reflashing uf2 files

Rust

Tutorials of various utility:

  • getting started: a guide on using a pi pico to program a pi pico as something resembling an in-system programmer (it appears to be using jtag to program)
  • embedded programming in rust: a quick guide using elf2uf2 to deploy directly to a pi pico board in bootsel mode; requires dependency not on my Fedora box

Useful resources:

  • rp-hal: library over the Pi Pico’s microcontroller and various boards that use it
  • rp2040 template: a template for making rust projects with rp-hal
  • uf2conv: converts a .bin file (see readme for producing)
  • cargo-binutils: makes the .bin object for the above uf2conf

Build a hello with uf2conf (work in progress)

  • clone rp2040-project-template
  • draw the owl of dependencies (I already did this so I forget exactly what I did)
  • cargo objcopy --release -- -O binary flash.bin
  • uf2conv flash.bin -b 0x10000000 -o flash.uf2
  • Connect pi in bootsel mode, mine mounts to /run/media/$(whoami)/RPI-RP2
  • cp flash.uf2 /run/media/$(whoami)/RPI-RP2/

Build a hello with Docker and elf2uf2

This Dockerfile is sufficient to make a build image for docker, but is pretty clunky otherwise.

  • clone rp2040-project-template
  • drop the dockerfile
  • docker build . -t build-image
  • docker exec --name build-env -it build-image bash
  • cargo build; elf2uf2-rs target/thumbv6m-none-eabi/debug/rp2040-project-template flash.uf2
  • docker cp build-env:/rust/flash.uf2 /run/media/$(whoami)/RPI-RP2/
Written on July 8, 2022