finally: raspberry pi 2 w with micropython

Raspberry Pi Pico 2 W

I have been experimenting with a pair of Raspberry Pi 2 boards and another pair of Raspberry Pi 2 W boards. I’ll write about the non-WiFi boards later; I wanted to document what I had to do in order to get a pre-release version of MicroPython to program on one of my Pico 2 W boards.

This is the link to download the unofficial MicroPython UF2 file directly from Raspberry Pi itself: https://downloads.raspberrypi.com/micropython/mp_firmware_unofficial_latest.uf2

I don’t know how long this link will be valid. I got the unofficial firmware up and running with my test code. Here’s a typical output where the WiFi subsystem is being tested.

  MACHINE: Raspberry Pi Pico 2 W with RP2350  RELEASE: 1.25.0-preview FS TOTAL: 3,145,728 BYTES FS  FREE: 3,092,480 BYTES FS  USED: 53,248 BYTES MEM FREE: 448,160 BYTES  UID: 5C7E378630646F97 SSID: RP2-6F97 CPU FREQ: 150,000,000 Hz  I2C: SoftI2C(scl=5, sda=4, freq=500000)  I2C: DEVICES FOUND: ['0x3d']  I2C: FOUND OLEDMicroPython 1.25.0 previewGCC 10.3.12024-11-21ssid: BASIC-NET-2.4rssi: -58ssid: Dashmeister  rssi: -89ssid: ESP32S3-7814 rssi: -29ssid: SmartLife-EEFB   rssi: -74MicroPython v1.25.0-preview.49.g0625f07ad.dirty on 2024-11-21; Raspberry Pi Pico 2 W with RP2350Type "help()" for more information.

My test code shows that the WiFi subsystem is working as far as scanning for other access points in and near where I live. I’ll be working later to do something a bit more sophisticated. Be advised that this is for the ARM cores only, there is nothing out yet for the RISC-V cores like there is for the Pico 2 without WiFi.

 

building python 3.13.0 rc1 on a raspberry pi 5

This is an interesting time for Python development. Python continues it’s upward popularity increase, while the Python language developers keep pushing the Python interpreter to be more performant with each release. In particular, with the imminent release of version 3.13.0, the developers are now disabling the global interpreter lock, or GIL, for efficient concurrency. Building Python betas and release candidates has become something of a ritual for me. With the addition of the 512 GiB NVMe SSD on my Raspberry Pi 5, I decided to build Python 3.13.0 release candidate 1 on my Raspberry Pi 5 under Ubuntu 24.04.

I documented the build process flow in an earlier post (see in the link section below). I’m going to highlight one key step in that process flow, the installation of build support libraries.

sudo apt install zlib1g-dev \ libncurses5-dev \ libgdbm-dev \ libnss3-dev \ libssl-dev \ libreadline-dev \ libffi-dev \ libsqlite3-dev \ libbz2-dev \ tk \ tk-dev \ liblzma-dev \ libgdbm-compat-dev \ libmpdec-dev 

Everything succeeded except the attempt to install libmpdec-dev. You need that library to support Big Number math in Python. In every release before 3.13 that support was internal. However, starting with 3.13 and later, that support is now via libmpdec-dev. Every one of those support packages installed successfully in Linux Mint 21.3, which is based on Ubuntu 22.04. But it doesn’t work on Ubuntu 24.04 on a Raspberry Pi 5. In the end I had to locate, download and manually install the individual deb files:

sudo apt install ./libmpdec3_2.5.1-1_arm64.debsudo apt install ./libmpdec-dev_2.5.1-1_arm64.deb

Those two deb files satisfy the libmpdec-dev requirement. After that I executed the following to configure the Python 3.13 build:

../Python-3.13.0rc1/configure --enable-optimizations --disable-gil

Once built I installed according to the step documented in the linked post below.

Then I gave it a whirl. The first thing I did after installing it was to create a Python 3.13 virtual environment and then pip install luma.led-matrix. That supports silly clock. When I activated the Python 3.13 virtual environment and ran silly_clock.py, the following was emitted by Python 3.13 in the terminal window:

<frozen importlib._bootstrap>:488: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'PIL._imaging', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.

That’s going to be an interesting problem going forward, as there’s a ton of legacy Python code that will more than likely trigger that RuntimeWarning.

Note

In order to successfully install luma.led-matrix in a Python virtual environment on a Raspberry Pi 5 under Ubuntu 24.04, you will need to install yet another support library, libpng-dev.

Links

building python 3.13.0 beta 1 on linux mint 21.3