Skip to content
This repository has been archived by the owner on Jun 27, 2021. It is now read-only.

ryankurte/rust-wasm-hal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust WASM HAL

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.

Status / Features

WASM-HAL components:

  • Core functions
    • fetch arguments
  • HAL functions
    • delay
    • print
    • 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?

Getting Started

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 and twiggy dominators test.wasm

Notes

  • 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.

I have a problem and/or can I help?

Sure! Open an issue or a PR ^_^

About

A WebAssembly (WASM) Hardware Abstraction Layer (HAL) for rust-embedded

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages