Skip to content
ariel-osPublic

About

Tiny Rust embedded virtual machines bolted on Ariel OS

Resources

Stars

8 stars

Watchers

1 watching

Forks

Repository files navigation

Virtual Machines bolted on top of Ariel OS: treVM and SURE-VM

This repository showcases small Rust embedded virtual machines, encapsuled and bolted on Ariel OS. Open source examples of code are given which you can run on a variety of boards (see below).

WebAssembly

Currently, the only type of VM that has been tested with Ariel OS is WebAssembly. Currently, Wasmtime is the only WebAssembly runtime that is supported. See this for an overview of how other runtimes compare in terms of code size and features. Note: Support for this is experimental and the implementation is subject to change.

Setup & Requirements

Your system and toolchain should be set up for Ariel OS. To learn more about the OS check out the Ariel OS repo and follow the guide for getting started.

On top of the requirements for basic Ariel OS usage, to turn rust code into components the wasm32v1-none target should be installed for your toolchain using rustup <toolchain> target add wawm32v1-none and so should the wasm-tools CLI utility. Ariel OS works on stable and so does the rust to wasm compilation workflow but we advocate the use of a (recent) nightly compiler for two reasons:

  • Compiling the wasm payloads is a three step process. We provide a rust script that does those steps in sequence and running scripts requires nightly.
  • Wasm binaries have by default a memory page size of 65536 bytes. It is possible to go below but support for this was only added in LLVM 21 which is only used by fairly recent nightly rustc. nightly-2025-09-01 is known to work and is the nightly version that was used when developing this. Also, if you choose to use the provided script you will also need to download the rust-src target for the nightly toolchain with rustup +nightly target add rust-src to use the -Z build-std optimizations that the script uses.

Repository Structure

This repo is structured around three crates:

  • src/ariel-os-bindings/src/wasm contains bindings make OS functionality accessible to Wasm VM. They are taylored for Wasmtime and will not work with another runtime. The bindings are partially auto-generated by the use of the WebAssembly component model. The WIT interfaces that are made available to wasm components are defined in wit/deps/ariel.
  • src/trevm contains the trait and implementation needing for update capsules following the taxonomy described in this paper. It builds on ariel-os-bindings and also uses the WebAssembly component model and the WIT interface described above.
  • src/sure-vm contains an extension to treVM adding SUIT compatibility for updates and other improvements.

The same structure is reflected in the examples/ directory.

Workflow

Examples are in the examples/ directory. They can be run using the laze build system.

Changing the logic found in the VMs requires going through the following steps:

  • Compiling some code to a wasm module
  • Turning the wasm module into a wasm component
  • Precompiling this component to make it usable by wasmtime in no_std contexts. The precompile_wasm.rs script takes in a path to rust manifest (Cargo.toml) and outputs a precompiled component to make this process less time consuming. The source code for the various payloads used in the examples is located in the payloads directory. After modifying the code in for example payloads/async-bindings/src/lib.rs, the corresponding example's payload can be changed by using the script.
#  nightly is required to use -Z script
cargo +nightly -Z script precompile_wasm.rs --help

Simple CLI that takes a compiled .wasm file and turns into a precompiled-component

Usage: precompile_wasm.rs [OPTIONS] --path <PATH>

Options:
  -p, --path <PATH>                   Path to the compiled Wasm file or to a manifest for a lib that will be compiled
      --config <CONFIG>               Path to an optional `config.toml` file when `path` points to a manifest
  -t, --toolchain <TOOLCHAIN>         Toolchain for the compilation when `path` points to a manifest
  -C, --compile_options <ADDITIONAL>  Additionnal compilation options propagated to cargo
      --target <TARGET>               [default: pulley32]
  -f, --fuel                          Turn fuel instrumentation on
  -O, --opt-level <OPT_LEVEL>         Override default opt-level [default: s] [possible values: s, 3, z]
  -o, --output <OUTPUT>               Path of the output file
  -w, --wasm-tools <WASM_TOOLS>       Path to wasm-tools if isn't not in $PATH
  -m, --module                        Outputs a Module instead of a component
  -a, --conserve-artifacts            Conserve the intermediate files under `ouput.wasm` and `output.comp.wasm`
  -h, --help                          Print help
  -V, --version                       Print version

Some examples that can run with Ariel's native target, requires --target pulley64. Currently this is only practical with the ariel-os-bindings/async-bindings example.

The various parameters used for initial compilation and precompilation have been chosen to optimize the resulting code size and nothing else. See this document for a more detailled breakdown of the process. In the most recent nightly compilers, the -Zbuild-std-features option panic_immediate_abort was turned into an unstable panic strategy. The payloads/.cargo/config.toml config file reflects this change. The old version is still present but commented out.

  • Async Bindings for RNG, Timer, Log: This example shows how Ariel OS can asynchronously run wasm components that yield regularly and that call asynchronous host functions. Recommended boards for this example: nrf52840dk, rpi-pico2-w
  • UDP Bindings: This example showcases how a wasm capsule can receive and send UDP packets by using the approriate functions. Recommended boards for this example: nrf52840dk, rpi-pico2-w, espressif-esp32-c6-devkitc-1
  • GPIO through Wasm: This example showcases a simple blinky running through a wasm capsule. Recommended boards for this example: nrf52840dk, nrf9160dk
  • Sensor Access through Wasm: This examples uses the sensor facitiliies from Ariel OS and a software implementation of a dummy temperature sensor to showcase how a wasm capsule can access sensor readings. Recommended boards for this example: nrf52840dk, rpi-pico2-w, espressif-esp32-c6-devkitc-1
  • BLE Scanner: This example shows how a Wasm can receive BLE data and process it. Recommended boards for this example: nrf52840dk, rpi-pico2-w, espressif-esp32-c6-devkitc-1
  • Insecure Updates: This examples shows how to update Wasm Capsule over the air. This is done through insecure UDP and should be treated as a PoC. Recommended boards for this example: nrf52840dk, rpi-pico2-w, espressif-esp32-c6-devkitc-1
  • Updatable Async: This examples shows how to securely update Wasm capsule over the air using CoAP + OSCORE. It does this in a way that allows the capsules to be run asynchronously. Recommended boards for this example: nrf52840dk, rpi-pico2-w, espressif-esp32-c6-devkitc-1.

In its current version, sure-VM only has examples using the Persistent capsules.

  • Suit Updatable Persistent Capsules without bindings: This example shows how to extend treVM with SUIT capabilities and other features in the case of persistent capsules without bindings. Recommended boards for this example: nrf52840dk, rpi-pico2-w, espressif-esp32-c6-devkitc-1, espressif-esp32-s3-devkitc-1.
  • Suit Updatable Persistent Capsules with bindings: This example shows how to extend treVM with SUIT capabilities and other features in the case of persistent capsules with bindings. Recommended boards for this example: nrf52840dk, rpi-pico2-w, espressif-esp32-c6-devkitc-1, espressif-esp32-s3-devkitc-1.

There is also an early example of using sure-vm's idea for capsules that run background tasks continuously while monitoring for updates using a CoAP + OSCORE server à la treVM. It can be found in examples/sure-vm/suit-udpatable.

Further Reading & Reference

To cite and/or to read more about treVM, the reference article is indicated below and the pdf can be found on arXiv

A. Lavandier, B. Buil, C. Gaber and E. Baccelli, "treVM: Tiny Rust Embedded Virtual Machines with WASM on Variable Resource-Constrained Hardware,"2026 22nd International Conference on Distributed Computing in Smart Systems and the Internet of Things (DCOSS-IoT), Reykjavik, Iceland, 2026, pp. 193-200, doi: 10.1109/DCOSS-IoT69657.2026.00031.

Copyright & License

All of the code present in this repo, including treVM and sure-VM is licensed under either of

at your option.

Copyright (C) 2020-2026 Inria.

About

Tiny Rust embedded virtual machines bolted on Ariel OS

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages