Working with Python and Raspberry Pi Pico on Arch Linux

Many people may wish to use the Raspberry Pi Pico with Linux. To be more specific, many may wish to use it with Arch Linux and also write code in MicroPython. Many of the quick-start guides are for Microsoft Windows, so here is an equivalent guide for Arch.

Connecting the Pico

The first task is to flash the Pico with a MicroPython bootloader. Download the latest bootloader from: Now, press the white bootsel button on top of the Pico and while still holding it down, connect it to your Arch Linux system using a USB cable. I am using the Pico with a small formfactor x86 PC running Arch Linux, connected using a standard USB-A to micro USB-B cable. Once connected, release the bootsel button. This connects the Pico as a USB storage device. To check that the device is connected, use lsblk.

> lsblk
sda           8:0    1   128M  0 disk
└─sda1        8:1    1   128M  0 part
nvme0n1     259:0    0 232.9G  0 disk
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
├─nvme0n1p2 259:2    0 119.2G  0 part /
├─nvme0n1p3 259:3    0 107.6G  0 part /home
└─nvme0n1p4 259:4    0   5.6G  0 part [SWAP]

In my case, the Pico appears as /dev/sda, with the writable partition being /dev/sda1. I therefore need to mount this. For example (assuming mount point /mnt/pico already exists, if not, sudo mkdir /mnt/pico):

> sudo mount /dev/sda1 /mnt/pico

Then, simply copy the downloaded uf2 file to /mnt/pico. e.g.:

> sudo cp ~/Downloads/rp2-pico-20210205-unstable-v1.14-9-g9dedcf122.uf2 /mnt/pico/

Once copied, you can unplug the Pico from the USB cable and reconnect it without holding down the bootsel button. This reboots the Pico and loads the MicroPython bootloader. The Pico is now booted and running MicroPython firmware, ready to be programmed.

Programming the Pico using Python

Most quickstart guides for the Pico recommend using Thonny as a simple IDE with built-in support for the Raspberry Pi Pico, supported by the Raspberry Pi Foundation, in version 3.3.3 and later. Thonny can be found in the Arch Linux AUR. The version I used is the latest Git release:

Instructions on how to install and manage Arch Linux AUR packages can be found here. In summary, clone the Git repository from the AUR. Go to the downloaded directory, and execute makepkg -si to install.

Once installed, you can start Thonny, but may find when you come to execute code on the Pico, that your user does not have access to the USB serial device. You may therefore need to execute the following command to add your user to the UUCP group, thereby giving read and write access to the device. On my system, the Pico connected to /dev/ttyACM0:

> sudo usermod -a -G uucp $USER

Now, when Thonny is started, select the Raspberry Pi Pico MicroPython interpreter from the bottom-right of the screen by clicking and selecting MicroPython (Raspberry Pi Pico) from the pop-up list.

You should now be able to paste the following hello world program in to Thonny, save it to the filename of your choice, and click the green run button on the Thonny UI to run it on the Pico. You should see the Pico’s green LED flash on and off at one second intervals.

import machine
import utime
led_onboard = machine.Pin(25, machine.Pin.OUT)
while True:


Related Posts



Linux, Raspberry Pi Pico, Python