An embedded-hal implementation for WebAssembly (WASM), designed to support the development of abstract WASM applications for arbitrary embedded platforms. This is intended to be extended with useful IoT interfaces to allow the construction of both drivers and full-features WASM applications.
Check out the docs for usage or the runtime file for the underlying WASM interface. WASM applications are passed a set of arguments to allow external configuration so pins etc. can be selected for your platform.
This is split from work on ESP32 WASM support on the basis that this API can be common, allowing applications to be compiled and run on arbitrary WASM supporting platforms.
WASM-HAL components:
- Core functions
- fetch arguments
- HAL functions
- delay
- spi
- i2c
- gpio
- uart / serial
- Extended functions
- Device individualisation (get serial, p/n, set hostname, etc.)
- Event publishing / subscription
- Displays / rendering
- WiFi connection / management
- MQTT connection / management
- Examples
- i2c-detect (untested)
- TODO: what else?
You'll need nightly rust (rustup default nightly
) and the wasm-unknown-unknown
rust target installed (rustup target add wasm32-unknown-unknown
), as well as wasm-opt
from binaryen to strip debug symbols, check out the example to get started.
- Build with
cargo build --release
- Optimize with:
wasm-opt -Oz -o test.wasm --strip-debug --strip-dwarf /media/tmp/wasm32-unknown-unknown/release/YOUR_BINARY.wasm
- Optional Check sizes with
twiggy top -n 21 test.wasm
andtwiggy dominators test.wasm
- You need to minimize the rustc stack size
"-C", "link-arg=-zstack-size=32768"
otherwise rustc defaults to using 1MB of stack and this won't run on devices without SPIRAM. The tradeoff here is that you may run out of stack space, so, ymmv.
Sure! Open an issue or a PR ^_^