{"id":15011952,"url":"https://github.com/wasm3/embedded-wasm-apps","last_synced_at":"2025-03-02T17:08:28.812Z","repository":{"id":45852864,"uuid":"433879579","full_name":"wasm3/embedded-wasm-apps","owner":"wasm3","description":"Run statically-compiled WebAssembly apps on any embedded platform","archived":false,"fork":false,"pushed_at":"2024-08-27T20:43:24.000Z","size":355,"stargazers_count":159,"open_issues_count":0,"forks_count":10,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-02-23T16:07:48.058Z","etag":null,"topics":["iot","particle-io","platformio","wasm","wasm2c","webassembly"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wasm3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-01T15:22:57.000Z","updated_at":"2025-02-05T13:16:45.000Z","dependencies_parsed_at":"2024-08-27T22:13:56.335Z","dependency_job_id":null,"html_url":"https://github.com/wasm3/embedded-wasm-apps","commit_stats":{"total_commits":63,"total_committers":2,"mean_commits":31.5,"dds":"0.015873015873015928","last_synced_commit":"5b323546a1ba2b2a5d508a99ccebfa19d53bbd73"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wasm3%2Fembedded-wasm-apps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wasm3%2Fembedded-wasm-apps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wasm3%2Fembedded-wasm-apps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wasm3%2Fembedded-wasm-apps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wasm3","download_url":"https://codeload.github.com/wasm3/embedded-wasm-apps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241541445,"owners_count":19979122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iot","particle-io","platformio","wasm","wasm2c","webassembly"],"created_at":"2024-09-24T19:41:56.103Z","updated_at":"2025-03-02T17:08:28.790Z","avatar_url":"https://github.com/wasm3.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine)\n\n# embedded-wasm-apps\n\nRun **native, statically-compiled** apps on any platform, using WebAssembly.  \nExamples include [\u003cimg src=\"https://cdn.rawgit.com/simple-icons/simple-icons/develop/icons/assemblyscript.svg\" width=\"18\" height=\"18\" /\u003e AssemblyScript](apps/assemblyscript/app.ts), \n[\u003cimg src=\"https://cdn.rawgit.com/simple-icons/simple-icons/develop/icons/rust.svg\" width=\"18\" height=\"18\" /\u003e Rust](apps/rust/src/app.rs), \n[\u003cimg src=\"https://cdn.rawgit.com/simple-icons/simple-icons/develop/icons/cplusplus.svg\" width=\"18\" height=\"18\" /\u003e C/C++](apps/cpp/app.cpp), \n[\u003cimg src=\"https://cdn.rawgit.com/simple-icons/simple-icons/develop/icons/go.svg\" width=\"18\" height=\"18\" /\u003e TinyGo](apps/tinygo/app.go), \n[\u003cimg src=\"https://cdn.rawgit.com/simple-icons/simple-icons/develop/icons/zig.svg\" width=\"18\" height=\"18\" /\u003e Zig](apps/zig/main.zig), \n[Virgil](apps/virgil/app.v3), \n[WAT](apps/wat/main.wat), \netc.\n\n## How it works\n\nThis does not use [`Wasm3`](https://github.com/wasm3/wasm3) engine. The approach is similar to [`WasmBoxC`](https://kripken.github.io/blog/wasm/2020/07/27/wasmboxc.html) or [`RLBox`](https://hacks.mozilla.org/2020/02/securing-firefox-with-webassembly/):\n\n1. Compile source code to `wasm`\n2. Translate `wasm` to `C` using [`wasm2c`](https://github.com/WebAssembly/wabt/blob/main/wasm2c/README.md)\n3. Compile produced `C`, link with a thin runtime implementation using the **native platform toolchain**\n\n![How it works](docs/how-it-works.png)\n\n## Benefits\n\n- Language/toolchain decoupling\n- Resilience against attacks (RCE, Control-flow hijacking)\n- Sandboxing / SFI (Software Fault Isolation)\n- Enables wasm transformations, like instrumentation or [`gas metering`](https://github.com/wasm3/wasm3/blob/main/docs/Cookbook.md#gas-metering)\n- Software-based memory virtualization\n- Moderate runtime overhead (mostly depends on the source language/runtime)\n    - Small performance hit (~10-30% slowdown compared to native modules)\n    - Moderate binary size increase\n- Highly portable\n\n## Example\n\n```log\n$ make APP=rust\n    Finished release [optimized] target(s) in 0.00s\n$ pio run -e esp32 -t upload\n$ pio device monitor\nInitializing WebAssembly...\n🦀 Rust is running!\n\n$ make APP=assemblyscript\n    \u003e npm run asbuild:optimized\n$ pio run -e esp32 -t upload\n$ pio device monitor\nInitializing WebAssembly...\n🚀 AssemblyScript is running!\n\n$ make APP=tinygo\n$ pio run -e esp32 -t upload\n$ pio device monitor\nInitializing WebAssembly...\n🤖 TinyGo is running!\n```\n\n## Building `WASM` apps\n\nEnsure the required tools are in your `PATH`:\n- [`WABT v1.0.36`](https://github.com/WebAssembly/wabt/releases/tag/1.0.36)\n- [`Binaryen v118`](https://github.com/WebAssembly/binaryen/releases/tag/version_118)\n\n```sh\n# AssemblyScript v0.27 (needs Node.js)\nmake APP=assemblyscript\n\n# Rust 1.80.1\nrustup target add wasm32-unknown-unknown\nmake APP=rust\n\n# C/C++ (needs Clang)\nmake APP=cpp\n\n# C99 Coremark (needs Clang)\nmake APP=coremark\n\n# TinyGo v0.33.0 + Go v1.23.0\nmake APP=tinygo\n\n# Zig v0.13.0\nmake APP=zig\n\n# Virgil (Aeneas III-7.1632)\nmake APP=virgil\n\n# WAT\nmake APP=wat\n```\n\nResulting WASM file comparison:\n\n| AS       | C/C++   | Coremark | Rust    | TinyGo  | Virgil  | WAT     | Zig     |\n| -------- | ------- | -------- | ------- | ------- | ------- | ------- | ------- |\n| 3951     | 864     | 10800    | 12264   | 1227    | 315     | 223     | 1057    |\n\n\n## Building and running with `PlatformIO`\n\n```sh\n# For ESP32:\npio run -e esp32 -t upload\n\n# For ESP8266:\npio run -e esp8266 -t upload\n\n# For Raspberry Pi Pico:\npio run -e rpi-pico -t upload\n\n# Open serial monitor\npio device monitor --quiet\n```\n\n## Building and running with `Particle`\n\nRequires [`particle-cli`](https://docs.particle.io/tutorials/developer-tools/cli/).\nShould work on all Particle devices i.e. `Spark Core`, `Photon`, `Electron`, `Argon`, `Boron`, `P2 / Photon2`:\n\n```sh\nparticle flash MyDevice ./src/*\n\n# Open serial monitor\nparticle serial monitor --follow\n```\n\n### License\n\nThis project is released under The MIT License (MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwasm3%2Fembedded-wasm-apps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwasm3%2Fembedded-wasm-apps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwasm3%2Fembedded-wasm-apps/lists"}