Hello Embedded!

Overview

Hello Embedded! πŸ‘‹

This repository contains a sketch of an embedded API described in Wit, and a simple example Wasm application that builds with it that blinks an LED, and a Wasmtime-based simulator that can run it. This is a super early demo, and hasn't been optimized at all for code size yet. Its purpose right now is to start some discussions.

The Wits

The API is described in Wit interfaces in the wit directory, and is based off of the embedded-hal API.

The guest

The example application is in the guest directory. Building it currently requires cargo component 0.8. Build with cargo component build.

$ cd guest
$ cargo component build --release
[...]
$ cd ..

That produces a component in guest/target/wasm32-wasi/release/hello_embedded.wasm. We can examine it with wasm-tools:

$ wasm-tools component wit guest/target/wasm32-wasi/release/hello_embedded.wasm
package root:component;

world root {
  import sketch:embedded/[email protected];
  import sketch:embedded/[email protected];

  export sketch:embedded/[email protected];
}

Here we can see it's exporting the run interface, which has the run entrypoint function, and importing the digital and delay and interfaces, which it uses to set the led and control its speed, respectively.

The host simulator

Once the guest is built, it can be run in the host simulator:

$ cd host
$ cargo run
[...]
   πŸ’‘
    
   πŸ’‘
    
   πŸ’‘

...

The Linux host

⚠ The following is entirely untested at this time!!! ⚠

If you can run this on a Linux board with a GPIO pin 0 wired up to an LED, and if luck smiles on us, this should run the guest which should make that LED blink:

$ cd linux-host
$ cargo run
[...]

Bonus points

This example also demonstrates Typed Main. The run function takes two handle arguments, providing the component with exactly what it needs.

You might also like...
12600+ icons pack for embedded graphics!
12600+ icons pack for embedded graphics!

πŸ“¦ embedded-icon 12600+ πŸ–Ό icons for embedded-graphics. πŸš€ Features πŸ“¦ Support to multiple icon packs - Easy to add support to! 🎨 Multiple resolution

A lightweight, embedded key-value database for mobile clients (i.e., iOS, Android), written in Rust.

A lightweight, embedded key-value database for mobile clients (i.e., iOS, Android), written in Rust. ⚠️ Still in testing, not yet ready for production

Hello Embedded!

Hello Embedded! πŸ‘‹ This repository contains a sketch of an embedded API described in Wit, and a simple example Wasm application that builds with it th

Freebsd-embedded-hal - Like linux-embedded-hal but FreeBSD

freebsd-embedded-hal Implementation of embedded-hal traits for FreeBSD devices: gpio: using libgpio, with stateful and toggleable support, with suppor

A no_std GIF library for embedded applications(embedded-graphics)

tinygif A tiny gif decoder written in no_std Rust. This crate requires about 20kB of memory to decode a gif. basic decoding frame iterator interlace s

Super-lightweight Immediate-mode Embedded GUI framework, based on the awesome embedded-graphics library. Written in Rust.

Kolibri - A GUI framework made to be as lightweight as its namesake What is Kolibri? Kolibri is an embedded Immediate Mode GUI mini-framework very str

πŸš€Memory safe, blazing fast, configurable, minimal hello world written in rust(πŸš€) in a few lines of code with few(1092πŸš€) dependenciesπŸš€
πŸš€Memory safe, blazing fast, configurable, minimal hello world written in rust(πŸš€) in a few lines of code with few(1092πŸš€) dependenciesπŸš€

πŸš€ hello-world.rs πŸš€ πŸš€ Memory safe, blazing fast, minimal and configurable hello world project written in the rust( πŸš€ ) programming language πŸš€ πŸš€ W

Rust+Cargo lightweight hello world with the most minimum binary size possible.

Lightweight Cargo Hello World Rust+Cargo lightweight hello world with the most minimum binary size possible. requirements 1: Rustup (Rustc, Cargo) Ins

A simples rust operating system that prints hello world.

rust-os-helloworld A simples rust operating system that prints hello world. Just run: cargo install bootimage and: cargo bootimage Install QEMU and: q

A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework.

Rust on ESP-IDF "Hello, World" template A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework. This is the crate you get when ru

Cross-chain bridge message delivery network. We are hiring, [email protected]

Introduction Implementation of a https://darwinia.network node in Rust based on the Substrate framework. This repository contains runtimes for the Dar

A brief implementation of a simple hello world program in rust since they said it couldn't be done.

rust-hello-world A brief blazingly fast πŸš€ implementation of a simple hello world program in rust since they said it couldn't be done. πŸš€ fast πŸš€ Also

A Rust program/library to write a Hello World message to the standard output.

hello-world Description hello-world is a Rust program and library that prints the line Hello, world! to the console. Why was this created? This progra

Easy access of struct fields in strings using different/custom pre/postfix:
Easy access of struct fields in strings using different/custom pre/postfix: "Hello, {field}" in rust

Easy access to struct fields in strings 🐠 add strung to the dependencies in the Cargo.toml: [dependencies] strung = "0.1.3" πŸ¦€ use/import everything

hello-world geyser plugin to stream accounts and transactions from a solana node

src/lib.rs: entrypoint src/plugin.rs: main plugin code to run: cargo build && solana-test-validator -r --geyser-plugin-config config.json note: make s

A "Hello, Rust!" program for the Flipper Zero

"Hello, Rust!" for the Flipper Zero This is an example of how to build a Rust-based Flipper application that runs from the SD-card. Note: This depends

Install a package with e.g. `hdn add pkgs.hello`
Install a package with e.g. `hdn add pkgs.hello`

hdn: utility for updating home.nix Home Manager is great, but it's tedious to run home-manager edit, add your package to the file, and run home-manage

A secure embedded operating system for microcontrollers

Tock is an embedded operating system designed for running multiple concurrent, mutually distrustful applications on Cortex-M and RISC-V based embedded

A secure embedded operating system for microcontrollers

Tock is an embedded operating system designed for running multiple concurrent, mutually distrustful applications on Cortex-M and RISC-V based embedded

Comments
  • Re-introduce pwm fully-on, fully-off, and fraction?

    Re-introduce pwm fully-on, fully-off, and fraction?

    I removed set-duty-cycle-fully-on, set-duty-cycle-fully-off, and set-duty-cycle-fraction, because they seemed redundant with just calling set-duty-cycle. However, it may be the case that some chips distinguish between 0 and fully-off, and max and fully-on, or may have fractional levels that can't otherwise be represented, so we should consider re-introducing them.

    opened by sunfishcode 4
  • What about

    What about "events" / interrupts?

    It would be nice if it would be possible to figure out ways not to force polling of GPIOs but rather have some events generated from them so that you can register a WASM function to be called when IO gets high/low or changes. (As an additional interface on GPIOs).

    opened by joakimeriksson 1
Owner
Dan Gohman
I'm working on Wasmtime, WASI, and lots of things related to WebAssembly.
Dan Gohman
A Rust program/library to write a Hello World message to the standard output.

hello-world Description hello-world is a Rust program and library that prints the line Hello, world! to the console. Why was this created? This progra

null 0 May 11, 2022
Easy access of struct fields in strings using different/custom pre/postfix: "Hello, {field}" in rust

Easy access to struct fields in strings ?? add strung to the dependencies in the Cargo.toml: [dependencies] strung = "0.1.3" ?? use/import everything

Dekirisu 2 Sep 19, 2022
A "Hello, Rust!" program for the Flipper Zero

"Hello, Rust!" for the Flipper Zero This is an example of how to build a Rust-based Flipper application that runs from the SD-card. Note: This depends

David Coles 15 Dec 17, 2022
Install a package with e.g. `hdn add pkgs.hello`

hdn: utility for updating home.nix Home Manager is great, but it's tedious to run home-manager edit, add your package to the file, and run home-manage

Fisher Sun 13 Jun 16, 2023
Low-level Rust library for implementing terminal command line interface, like in embedded systems.

Terminal CLI Need to build an interactive command prompt, with commands, properties and with full autocomplete? This is for you. Example, output only

HashMismatch 47 Nov 25, 2022
Source code for our paper "Higher-order finite elements for embedded simulation"

Higher-order Finite Elements for Embedded Simulation This repository contains the source code used to produce the results for our paper: Longva, A., L

Interactive Computer Graphics 18 Sep 30, 2022
A Rust command line tool to simplify embedded development and deployment.

Bobbin-CLI bobbin-cli is a tool designed to make it easy to build, deploy, test and debug embedded devices using a unified CLI. bobbin-cli understands

Bobbin 110 Dec 25, 2022
A text renderer for Rust's embedded-graphics crate, based on U8g2

u8g2-fonts This crate is a pure Rust reimplementation of the font subsystem of U8g2. It is intended for the embedded-graphics ecosystem. Licensing Whi

null 4 Aug 29, 2022
A plugin system for the Rhai embedded scripting language.

Rhai Dylib This crate exposes a simple API to load dylib Rust crates in a Rhai engine using Rhai modules. ?? This is a work in progress, the API is su

Rhai - Embedded scripting language and engine for Rust 6 Dec 27, 2022
Simple Secure Static (HTTPS) File Server with embedded certificate

Secure Static File Server Static Files HTTPs server with self signed embedded certificate Installation Install using cargo: cargo install ssfs Or buil

0xor0ne 21 Apr 20, 2023