Repository navigation
v1.0.0 — Write Once, Run on Any Microcontroller: Portable C99 WebAssembly Runtime
Write Once, Run on Any Microcontroller
ECCLES WASM is a portable, zero-heap C99 WebAssembly interpreter built specifically for resource-constrained microcontrollers. Compile your application logic to .wasm once—from C, Rust, or AssemblyScript—and execute the exact same binary across ESP32, STM32, RP2040, Zephyr, Arduino, or a desktop Host Simulator.
Why ECCLES WASM?
- True Hardware Portability: Guest modules import a unified hardware API (
enable,disable,pwm,adc,uart_*,i2c_*,spi_*,irq_*,sleep). Every call returnsSUCCESSFUL,FAILED, orUNSUPPORTED, allowing a single.wasmbinary to dynamically probe and adapt to whatever chip it lands on. - Streaming Load & Translation: Function bodies are structurally validated and translated on the fly through a tiny chunk buffer (
ECCLES_WASM_CHUNK_SIZE, default 256 bytes). The raw.wasmfile is never buffered in RAM—stream directly from SPIFFS, LittleFS, FatFs, SD cards, UART, or OTA packets. - Zero-Heap Single-Arena Memory Model: Runs cleanly in ~24 KB+ of RAM using one static array (or a single caller-supplied buffer). Linear memory caps (
ECCLES_WASM_MEM_LIMIT_BYTES) let standard 64 KiB-page.wasmbinaries execute safely on smaller MCUs. - Deterministic Safety & Watchdog Protection: Built-in instruction fuel budgets (
eccles_wasm_set_fuel) and periodic yield hooks (ECCLES_WASM_YIELD_INTERVAL) prevent runaway guest loops from locking up the CPU or starving RTOS tasks. - Drop-In Integration: Just two files (
eccles_wasm.handeccles_wasm.c) with zero external dependencies beyond a standard C99 compiler.
Built-In Platform Backends
| Backend | GPIO | ADC | PWM | Time / Sleep | Reset | RNG | IRQ | UART / I2C / SPI | Log |
|---|---|---|---|---|---|---|---|---|---|
| ESP-IDF (ESP32) | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | stdout |
| Raspberry Pi Pico | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | stdout |
| Arduino | Yes | Yes | Yes | Yes | ESP/ARM | ESP32 | — | C++ Glue | C++ Glue |
| STM32 HAL | Yes | — | — | Yes | Yes | — | — | CubeMX | — |
| Zephyr RTOS | Yes | — | — | Yes | Yes | Yes | — | — | printk |
| Host PC Simulator | Sim | Sim | Sim | Yes | Sim | Yes | Sim | Sim | stdout |
(Need custom silicon? Override any subset of operations at runtime via eccles_wasm_hal_override().)
Quick Start
Host Firmware (C99)
#include "eccles_wasm.h"
void app_main(void) {
eccles_wasm_set_fuel(500000); // Prevent infinite guest loops
eccles_wasm_load("/spiffs/blink.wasm"); // Streamed in 256-byte chunks
eccles_wasm_run("main"); // Execute exported entry point
}Portable Guest Application (clang --target=wasm32 -nostdlib)
#define ECCLES_IMPORT(n) __attribute__((import_module("env"), import_name(n)))
ECCLES_IMPORT("enable") int enable(int pin);
ECCLES_IMPORT("disable") int disable(int pin);
ECCLES_IMPORT("sleep") int sleep(int ms);
__attribute__((export_name("main")))
void main_(void) {
for (;;) {
enable(2);
sleep(500);
disable(2);
sleep(500);
}
}What's Included in v1.0.0
- Core Runtime: Streaming loader, structural validator, 16-bit bytecode translator, and interpreter supporting WebAssembly 1.0 + sign-extension ops, non-trapping float conversions, bulk memory (
memory.copy/memory.fill), and multi-value blocks. - WASI-Lite Support: Built-in
fd_write,proc_exit,clock_time_get,random_get,args_*, andsched_yieldso standardprintf()-style C and Rust guests run out of the box. - Ready-to-Build Manifests: Includes support for CMake, ESP-IDF Component Registry (
idf_component.yml), PlatformIO (library.json), and Arduino Library Manager (library.properties). - Test Suite & Differential Fuzzer: Host test harness with SDK mocks and differential fuzzing against reference WebAssembly execution.
Full Changelog: https://github.com/Igwe-Starking/eccles-wasm/commits/v1.0.0