KoaOS Architecture: WASM on Microcontrollers with Web Serial Flashing

October 2026 - min read


Try it in your browser (Chrome/Edge, USB cable, Heltec WiFi LoRa 32 V4)

What It Is

KoaOS is a tiny Unix-style operating system for the Heltec WiFi LoRa 32 V4 (ESP32-S3, 16 MB flash, 8 MB PSRAM, SX1262 LoRa, GPS, 0.96” OLED). It boots from a browser-based flasher using the Web Serial API, then runs a persistent shell with a WASM sandbox for user applications.

Key Features

Feature Details
Flash from browser Web Serial API - no drivers, no esptool install, works on Chrome/Edge
Persistent shell & FS Login, background jobs, nano-style editor, files survive reflashes
WASM sandbox (wasm3) Apps are .esp packages (max 256 KB); crash won’t kill the OS
Hardware mediation OS arbitrates Wi-Fi, GPS, LoRa, GPIO so apps don’t conflict
Built-ins GPS manager, HTTP(S), Open-Meteo weather, LoRa APRS (aprs, aprsd), edit, neofetch, pins
Experimental 0.14 VGA/desktop (vga, gui), RCA composite (rca), BLE keyboard (ble), I2C/OLED support for apps
SDK C -> WASM with 48-56 function ABI (console, files, Wi-Fi, GPS, LoRa, UART, I2C, SPI, RNG, crypto, IPC)

Architecture Overview

Boot Flow

Browser (Web Serial) -> ESP32-S3 ROM bootloader -> KoaOS bootloader -> KoaOS kernel -> init -> shell

The browser flasher sends the bootloader + kernel + rootfs in one stream. On first boot, KoaOS formats the data partition, creates the default user, and drops to a login prompt. Subsequent boots are ~2 seconds to shell.

Memory Map (16 MB Flash + 8 MB PSRAM)

Region Size Purpose
Bootloader 64 KB Web Serial receive, verify, jump to kernel
Kernel ~512 KB Scheduler, VFS, drivers, hardware mediation
Rootfs (read-only) ~2 MB Built-in apps, libraries, config
Data partition ~13 MB User files, installed .esp apps, logs
PSRAM 8 MB WASM heap, framebuffers (VGA/composite), network buffers

Hardware Mediation Layer

Instead of giving apps raw peripheral access, KoaOS exposes capability-based syscalls:

Apps request capabilities at install; user grants/denies. A buggy app can’t brick the radio stack.

WASM Sandbox (wasm3)

Building an App (C -> .esp)

// hello.c
#include <koaos.h>

int main() {
    console_puts("Hello from WASM!");
    wifi_connect("SSID", "pass");
    http_get("https://api.example.com/data", buf, sizeof(buf));
    console_puts(buf);
    return 0;
}

// Compile:
clang --target=wasm32 -O2 -nostdlib -Wl,--export=main -Wl,--no-entry -o hello.wasm hello.c

// Package:
koaos-pack hello.wasm hello.esp  --name "Hello" --cap wifi,http

Drag hello.esp onto the browser flasher -> installs to data partition -> appears in shell as hello command.

Experimental: VGA + Composite + BLE

Version 0.14 adds:

Known issues: VGA + Wi-Fi + LoRa simultaneous = PSRAM pressure. MeshCore direct messages crash the system (WIP).

Why This Matters for Embedded Work

KoaOS demonstrates the full stack I bring to client projects:


KoaOS is experimental. Wi-Fi and Bluetooth share one radio - concurrent use degrades both. Flash at your own risk; recovery requires the browser flasher or esptool. Default login: root / 1234.