Skip to content

Using Embassy

Embassy is an async framework for embedded Rust. It provides efficient task scheduling and hardware abstractions, making it a good fit for low-power, responsive firmware.

Embassy Book

Embassy GitHub

Key features

  • Async programming model with async/await
  • Lightweight executor suitable for resource-constrained devices
  • Works with multiple HAL ecosystems for portability
  • Common peripherals supported (timers, DMA, interrupts)

Use cases

  1. Low-power devices: reduce idle CPU usage with async tasks
  2. Concurrent workloads: run sensors, comms, and UI together
  3. Real-time embedded systems

Montic support matrix

W02W04
ChipExpressif ESP32-C6WCH CH32V208
Status✔ Support✔ Support

Prerequisites

  1. Install Rust

    Install Rust via rustup and make sure cargo is available.

  2. Install common tools

    Terminal window
    cargo install cargo-generate
    cargo install probe-rs-tools
  3. Install ESP32-C6 flashing tool (for W02)

    Terminal window
    cargo install espflash

Montic W02 (ESP32-C6) quick start

Montic W02 uses ESP32-C6. We recommend using Embassy with Espressif’s Rust ecosystem (esp-hal).

  1. Add the target

    Terminal window
    rustup target add riscv32imac-unknown-none-elf
  2. Get a template or example

    You can generate a template with cargo generate, or start from the Embassy examples in esp-hal:

    Terminal window
    cargo generate --git https://github.com/esp-rs/esp-hal --name montic-w02
  3. Build and flash

    Terminal window
    cargo build --release
    espflash flash --monitor target/riscv32imac-unknown-none-elf/release/montic-w02 --chip esp32c6

Montic W04 (CH32V208) quick start

Montic W04 uses CH32V208. We recommend the community CH32-RS HAL with Embassy for async development.

  1. Add the target

    Terminal window
    rustup target add riscv32imac-unknown-none-elf
  2. Create a project and add the HAL

    Create a project with cargo new, then add the CH32-RS HAL and Embassy dependencies in Cargo.toml. See the CH32-RS examples for reference.

  3. Build and flash

    Build with cargo build --release, then flash using the WCH-Link or USB ISP tools.

Embassy app structure example

Below is a minimal Embassy app skeleton. Replace the GPIO and timer setup with the appropriate HAL for your board.

#![no_std]
#![no_main]
use embassy_executor::Spawner;
use embassy_time::{Duration, Timer};
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
// TODO: initialize your HAL peripherals (e.g., GPIO)
loop {
// TODO: toggle LED
Timer::after(Duration::from_millis(500)).await;
}
}

More resources