Bare-metal Mojo on a $4 microcontroller — a pure-Mojo RP2040 firmware + SDK

Hi @SnappyWalrus34 inmojomni is updated to Mojo 1.1.0, feel free to give it a try.
I also tested IRQ->GPIO latency (on-chip), measured on the RP2040 at 125 MHz over 30,000 interrupts. Every interrupt took 176 ns with no measurable jitter, the same as C. Only the first interrupt after reset is slower (about 1–2 µs) because the cache is cold. Run it yourself with pixi run irq-latency. Details are in docs/BENCHMARKS.md.

Pointer API: Yes, Register access looks like this (you can check it in src/pico/mmio.mojo):

def write32(addr: UInt32, value: UInt32):
var p = Pointer[UInt32, MutUntrackedOrigin](unsafe_from_address=Int(addr))
p.unsafe_store[volatile=True](0, value)

For anything further, please open a GitHub issue.

2 Likes

Great result!

Is there a simple, unified example script for Mojo IRQ I/O GPIO pins that uses the Pointer API (for PWM/ADC register address)?

Could these same levels of jitter and latency for IRQ I/O, PWM, and ADC (using the Mojo Pointer API) also be achieved on ARM Cortex-M platforms (M4, M7, M33) or on isolated CPU cores running Linux-RT (PREEMPT_RT)?