PikaScript Crams Python Onto Microcontrollers with Just 4kB of RAM and 32kB of Storage

Designed for devices too compact to accept MicroPython or CircuitPython, PikaScript is an extremely compact Python environment.

Those who like to program in Python have a new option on the table for resource-constrained environments: PikaScript, which can run on devices with as little as 4kB of RAM and 32kB of flash storage.

"PikaScript is an ultra-lightweight Python engine with zero dependencies and zero-configuration, that can run with 4kB of RAM and 32kB of flash (such as STM32G030C8 and STM32F103C8)," the project's maintainers explain. "[We] support run[ning] in MCU without OS or file system. Zero dependencies, zero configuration, out-of-the-box, easy to integrate into previous C projects."

The obvious comparison to PikaScript, which was brought to our attention by CNX Software, is MicroPython and its fork CircuitPython. While there are undeniably similarities, PikaScript is considerably more resource-friendly β€” running on devices with one-eighth the storage and one-quarter the RAM compared to the competition.

As a considerably newer project, though, hardware support is relatively limited. The PikaScript project has its own reference development board, the PikaPi-Zero β€” entirely unrelated to the Raspberry Pi Zero β€” which features an STMicro STM32G030C8T6 with 8kB of RAM and 64kB of flash alongside four user-addressable RGB LEDs and push-button switches.

Outside the PikaPi-Zero and other STM32-based devices, though, you're more limited: full compatibility is offered on the WinnerMicro W806, while the WCH CH582 offers partial compatibility missing only pulse-width modulation (PWM) support. Other devices β€” including the popular Raspberry Pi Pico and its RP2040 microcontroller β€” have board support packages ready, but no access as yet to the general-purpose input/output (GPIO) pins.

Despite this, there are some interesting features that may make PikaScript worthy of investigation beyond its minimal resource requirements: The software can run bare-metal on compatible microcontrollers, or beneath the RT-Thread or Versalooon Software Framework (VSF) real-time operating systems, and It offers an easy way to bind C libraries through a Python API and comes with an online project generation tool.

Those interested in trying PikaScript out can download the full source code from the project's GitHub repository, where it's made available under the permissive MIT license.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles