This repository contains WebAssembly components, WIT interface definitions, and host implementations for the WASI-USB ecosystem. It includes a variety of demonstrations, from simple USB enumeration to real-time Computer Vision pipelines.
Original research and implementation by IDLab Discover.
wit/: Formal interface definitions (WIT) for USB operations, descriptors, transfers, and Computer Vision (CV).usb-wasm/: Host-side implementation of the WASI-USB WIT interfaces. This is the core library that bridges libusb to the Wasmtime runtime.wasmtime-usb/: A custom Wasmtime-based CLI runner that incorporates theusb-wasmhost implementation.command-components/: Guest components (WebAssembly) implementing specific USB and CV logic (e.g.,lsusb,yolo-detector).usb-wasm-bindings/: Generated Rust bindings for the guest components to use (versioned at@0.2.1).rusb-wasi/: A crate providing a wrapper around the generated bindings for a more idiomatic Rust API.
- Rust (latest stable)
- wasm-tools
- just
- wit-bindgen-cli v0.42.1 (for regenerating bindings)
We use just as the primary build system. You can see all supported commands by running just --list.
The runtime consists of the usb-wasm host library and the wasmtime-usb CLI.
just build-runtimeYou can build and run any of the guest components. For example, to run the lsusb demo:
just lsusbThis command will:
- Compile the
lsusbcomponent to WASM targetingwasm32-wasip2. - Wrap it into a WebAssembly Component.
- Run it using
wasmtime-usb.
To check or build all components in the workspace:
cargo check --workspace --target=wasm32-wasip2
cargo build --workspace --target=wasm32-wasip2Note
sudo is often required for direct USB access on Linux/macOS when running the host runtime, depending on your udev rules.
Since the game uses CLI output, it needs to write this line per line. This might cause some flickering. For best performance, use Alacritty with a font size of 30 and in fullscreen.
This work has been partially supported by the ELASTIC project, which received funding from the Smart Networks and Services Joint Undertaking (SNS JU) under the European Union’s Horizon Europe research and innovation programme under Grant Agreement No 101139067. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union. Neither the European Union nor the granting authority can be held responsible for them.