🔴 The Pi 2 Pico Toolchain

Table of Contents

Landscape

🌐 I have gone down a rabbit hole with microelectronics programming.

It all started with getting into programming the raspberry pi pico, a new and very popular microelectronic controller board made by the raspberry pi foundation. The board in popular for several reasons.

  1. It is powerful
  2. It is available
  3. It is made by a respected company.

The Standard Faire 🛒

There are tons of resources available for programming the device using MicroPython. However, information about programming the pico with lower level languages is fairly scarce.

Beyond MicroPython 🐍

This sent me on a fact finding mission regarding the process of programming the pico using popular embedded languages like C and C++, along with new kids Rust and Zig.

During this discovery process, one of my fav Youtubers Mattias Wandel made a couple of videos doing this process with C and had some very good insites from his much deeper knowledge and embedded backgroud.

YouTube Video Inspiration 📼

in one of the videos Mattias created

He is programming a pi pico with C lang to sense and sound an alart. As you can see from this image, he is using a regular pi to connect to the pico. The pico is coupled with a sensing circuit, led circuit and piezo circuit via the breadboard.

Using a Pi as a programmer 🧑‍💻

One of the ideas I really like, is using a Raspberry Pi as a computer for programming the Pico. There are many things that can go wrong in a toolchain like this and using a Pi ensures a level of compatability and portability that other systems cannot achieve.

Landscape

The Pi is compatable 💻

The Pi is a fully functional single board computer that can run Linux. Linux is my prefered environment for development because it is so explicit to setup. Furthermore, the Pi is a well known and popular piece of hardware that has sees continuous bug fixing, so linux performance is rock solid.

The pi is portable 🎒

Unline your main computer, the pi is almost small enough to fit in ones pocket and it is not full of other files and programms like your main system is. Offloading the programming toolchain to such a portable device means not lugging tons of stuff around.

Setting up the Pi 🕵️

Always starts with disk imaging. The process has been made super simple with Raspberry Pi disk imager. The program is available for most operating systems.

This is used to download our operating system ISO file and burn it to a Micro SD card.

be sure to go through the advanced settings and give it wifi and ssh credentials.

One the card is set up, just pop it in the pi and power it on.

Access Pi via SSH ☎

On Mac OS

I am a mac user, so this process is fairly straight forward. I open up a terinal and

sudo SSH user@host.local 

using a password on both ends.

On Windows

Dowload PuttY and connect

Download toolchain software on pi

Programming Via SSH in the terminal

I connect to the Pi via SSH on my local network. When I travel, I bring a portable router, so I always have a local network. This setup in very compact with the router also being pocket sized.

LSUSB

lsusb

will list out active usb connections to the pi. If a pico is connected it will be listed as pico.

C Toolchain ‘Pico Tools’

There is a build toolchain call pico tools. It uses CMAKE to build projects and send them to the pico device using the terminal

Zig toolchain

Landscape

Zig is doable, I just dont have experience with it atm. Will come back soon with an update.

Rust toolchain (Cargo target)

The rust method for compiling to a target is very elegant. In the Cargo.toml file, we just define the build target and binary type. For a larger project, rust seems to have the nicest syntax and build process. Though this is coming from a mid dev.

TinyGo

Has a simple command line argument style with a variable for the compile target. I would say that TinyGo has some really interesting features with garabage collection and rtc compensation.

Landscape