Skip to content

wasm-rtos: one .wasm file runs on an ESP32, an STM32 and in the browser

A program is an ordinary .wasm file built from C, C++ or an Arduino sketch, and wasm-rtos runs it the way a desktop operating system runs an executable. The same file runs on an ESP32, on an STM32 and in the browser, and a program stopped on one of them can go on on another.

It is written from scratch, in plain C with no platform code: an operating system, its devices and its own interpreter, small enough for chips with 128 KB of RAM; the interpreter alone fits an Arduino Uno.

Write a program · Put it on a board · Examples · Try it in the browser

How it fits together

Programs on top of the kernel; the devices and the interpreter under it; the board at the bottom

Each layer is a repository of its own and needs only the one under it: the interpreter alone is a scripting engine, the interpreter and the devices make a mini OS, all of them the whole system.

Repository What it is Inside
wasm-rtos-vm The interpreter WebAssembly 2.0, fuel, stops at any instruction, portable snapshots, MMU, code as a cache, code in flash, WASI without files
wasm-rtos The operating system Scheduler, queues and sync objects, processes, files, page stores and swap, deep sleep, the program ABI (frozen at 1.8)
wasm-rtos-hw The devices Pins, displays, input, I2C, SPI, 1-Wire, analog in and out, PWM, serial ports, pulse trains, counters: by name, one owner at a time
wasm-rtos-dylink Shared libraries dylink.0: a program and its libraries as one process, a library parsed once, libraries from a card
wasm-rtos-libraries Libraries in programs The Arduino core, Wire, SPI, OneWire, Encoder, NeoPixel; helpers for chips and buses
wasm-rtos-examples Examples Hosts and programs for every layer, a program for every topic, built and run in CI
wasm-rtos-tests Tests One test per feature, on every change, also under the sanitizers
wasm-rtos.github.io The simulator The same kernel in the browser, a dev board and a watch, a bus analyzer

Stopped at any instruction

Task A runs until its fuel is gone and stops between two instructions; task B gets a slice; later A goes on from the next instruction

Programs are not rewritten or instrumented first: any .wasm from any compiler is counted, and a plain int main with an endless loop still shares the processor. The same program takes the same fuel on every device, and a stopped program is saved by its place in the module, so it can go on on another chip.

Memory larger than RAM

A program's memory in frames, some in RAM and some in a page store, and predecoded code as a cache

The interpreter pages, the operating system decides which frames stay. A board may have several page stores, the fastest used first, and a program waiting long can leave RAM whole until it runs again.

Measured

18 programs at once on an ESP32, 10 on an STM32, the interpreter in 28.8 KB on an Uno, 27437 spec checks

  • Memory larger than RAM: on an ESP32 with 250 KB of free heap, a program with 640 KB of memory runs, paged from an SD card.
  • The same work, the same fuel: a test program takes 900013 units on an ESP32, an STM32 and a computer alike.
  • Every byte back: the board checks end with the heap as it was before the first program.

Timeline

Timeline from July to November 2026

All of it is public domain.

Pinned Loading

  1. wasm-rtos.github.io wasm-rtos.github.io Public

    JavaScript

Repositories

Showing 10 of 10 repositories

Top languages

Loading…

Most used topics

Loading…