Run statically-compiled WebAssembly apps on any embedded platform

Overview

embedded-wasm-apps

Run native, statically-compiled apps on any platform, using WebAssembly.
Examples include AssemblyScript, Rust, C/C++, TinyGo, Zig, etc.

How it works

This does not use Wasm3 engine. The approach is similar to WasmBoxC:

  1. Compile source code to wasm
  2. Translate wasm to C using wasm2c
  3. Compile produced C, link with a thin runtime implementation using the native platform toolchain

How it works

Benefits

  • Language/toolchain decoupling
  • Moderate runtime overhead (mostly depends on the source language/runtime)
  • Enables wasm transformations, like instrumentation or gas metering
  • Sandboxing / SFI (Software Fault Isolation)
  • Software-based memory virtualization

Example

$ make APP=rust
    Finished release [optimized] target(s) in 0.00s
$ pio run -e esp32 -t upload
$ pio device monitor
Initializing WebAssembly...
🦀 Rust is running!

$ make APP=assemblyscript
    > npm run asbuild:optimized
$ pio run -e esp32 -t upload
$ pio device monitor
Initializing WebAssembly...
🚀 AssemblyScript is running!

$ make APP=tinygo
$ pio run -e esp32 -t upload
$ pio device monitor
Initializing WebAssembly...
🤖 TinyGo is running!

Building WASM apps

Ensure WABT and Binaryen tools are in your PATH.

# AssemblyScript (needs Node.js)
cd apps/assemblyscript
npm install
cd ../..
make APP=assemblyscript

# Rust
rustup target add wasm32-unknown-unknown
make APP=rust

# C/C++ (needs wasienv)
make APP=cpp

# TinyGo (needs TinyGo v0.21.0 and Go v1.17.3)
make APP=tinygo

# Zig (needs Zig v0.9.0)
make APP=zig

Building and running with PlatformIO

# For ESP32:
pio run -e esp32 -t upload

# For ESP8266:
pio run -e esp8266 -t upload

# For Raspberry Pi Pico:
pio run -e rpi-pico -t upload

# Open serial monitor
pio device monitor --quiet

Building and running with Particle

Requires particle-cli. Should work on all Particle devices i.e. Spark Core, Photon, Electron, Argon, Boron:

particle flash MyDevice ./src/

# Open serial monitor
particle serial monitor --follow
Owner
Wasm3 Labs
Wasm3 Labs
Template for C++ GUI apps that can run in the browser

GGWeb Template for making a GUI app with C++ / Dear ImGui / SDL / OpenGL / Emscripten that can run both natively and in the browser. Example: https://

Georgi Gerganov 16 Jun 20, 2022
Run-time program generator embedded in C++

Run-time program generator embedded in C++

Z Guan 24 Apr 29, 2022
A place to collaborate on code for the Embedded.fm book club. Currently reading "STM32 ARM Programming for Embedded Systems".

Welcome to the Book Club Code site! This is a place for the Embedded.fm book club to collaborate and learn together. Repo Structure Guide Top-level fo

Peter Griffin 10 Jan 13, 2022
Embedded Flutter runtime targeting Embedded Linux with Wayland

ivi-homescreen IVI Homescreen for Wayland Strongly Typed (C++) Lightweight Clang 11 Release Stripped = 151k GCC 9.3 Release Stripped = 168k Source run

null 148 Jun 17, 2022
SDK for building cross-platform desktop apps in ANSI-C

NAppGUI Cross-Platform C SDK. Build portable desktop applications for Windows, macOS and Linux, using just C. Quick start in Windows Prerequisites Vis

Francisco García Collado 194 Jun 23, 2022
An embedded CAN bus sniffer which is able to monitor any of the vehicle internal CAN bus and perform some action by triggering new CAN messages.

An embedded CAN bus sniffer which is able to monitor any of the vehicle internal CAN bus and perform some action by triggering new CAN messages. In this way certain vehicle functionality can be triggered by responding to custom steering wheel button events, or use the vehicle virtual cockpit to display OBD-PIDs values instead of relying on an external display to present new information to the user

null 13 May 21, 2022
Simple, fast, JIT-compiled scripting language for game engines.

Aftel Aftel (acronym for «A Far Too Easy Language») is a programming language, primarily intended to serve as an embeddable scripting language for gam

Rosie 17 May 20, 2022
StarkScript - or the Stark programming language - is a compiled C-based programming language that aims to offer the same usability as that of JavaScript's and TypeScript's

StarkScript StarkScript - or the Stark programming language - is a compiled C-based programming language that aims to offer the same usability as that

EnderCommunity 5 May 10, 2022
Pre-compiled builds for CVE-2021-4034

CVE-2021-4034 Precompiled builds for CVE-2021-4034. Of course you shouldn't trust precompiled builds :) This release works slightly different: first a

null 11 Jun 13, 2022
Loads a signed kernel driver which allows you to map any driver to kernel mode without any traces of the signed / mapped driver.

CosMapper Loads a signed kernel driver (signed with leaked cert) which allows you to map any driver to kernel mode without any traces of the signed /

null 107 Jul 2, 2022
Automatically load dlls into any executables without replacing any files!

Automatically loaded dll using xinput9_1_0 proxy. Please put the modified xinput9_1_0.dll in the executable's directory.

null 11 Apr 17, 2022
Create a calculator of any kind in any language, create a pr.

calculators Create a calculator of any kind in any language, create a pr. Create a calculator of any type using the programming language of your choic

Akshay Gautam 2 Dec 1, 2021
WebAssembly from Scratch: From FizzBuzz to DooM.

WebAssembly from Scratch: From FizzBuzz to DooM Exploring WebAssembly from scratch from a backend-person-point-of-view. A story in four acts. Welcome

Cornelius Diekmann 1.4k Jun 23, 2022
Translates WebAssembly modules to C

w2c2 Translates WebAssembly modules to C. Inspired by wabt's wasm2c. Features Implements the WebAssembly Core Specification 1.0 Passes 99.9% of the We

Bastian Müller 197 Jun 15, 2022
Snake in C++ for WebAssembly

Snake-wasm Snake in C++ for WebAssembly This is a primitive greedy snake game demo in C++(ish) to test WebAssembly Getting Started Install emscripten

null 1 Jan 4, 2022
Minimal C# WebAssembly WebGL Example

Minimal C# WebAssembly WebGL Example a minimal example of C# wasm WebGL app based on dotnet/runtimelab/NativeAOT-LLVM WebAssembly This example is port

Zou Wei 8 Jun 13, 2022
An app that allows you to edit/create apps in Dash

AppAdder On Ubuntu, have you ever run a program or AppImage and the app not had an icon? This is a personal pet peeve. I've used AppImageLauncher to i

Camden 5 Jun 25, 2022
A set of very empty header files that can be used when building apps with Cosmopolitan

cosmo-include A set of very empty header files that can be used when building apps with Cosmopolitan Why? When you build an application with Cosmopoli

null 18 May 9, 2022