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
- Low-power devices: reduce idle CPU usage with async tasks
- Concurrent workloads: run sensors, comms, and UI together
- Real-time embedded systems
Montic support matrix
| W02 | W04 | |
|---|---|---|
| Chip | Expressif ESP32-C6 | WCH CH32V208 |
| Status | ✔ Support | ✔ Support |
Prerequisites
-
Install Rust
Install Rust via rustup and make sure
cargois available. -
Install common tools
Terminal window cargo install cargo-generatecargo install probe-rs-tools -
Install ESP32-C6 flashing tool (for W02)
Terminal window cargo install espflash
-
Install Rust
Terminal window curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -
Install common tools
Terminal window cargo install cargo-generatecargo install probe-rs-tools -
Install ESP32-C6 flashing tool (for W02)
Terminal window cargo install espflash
-
Install Rust
Terminal window brew install rustuprustup-init -
Install common tools
Terminal window cargo install cargo-generatecargo install probe-rs-tools -
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).
-
Add the target
Terminal window rustup target add riscv32imac-unknown-none-elf -
Get a template or example
You can generate a template with
cargo generate, or start from the Embassy examples inesp-hal:Terminal window cargo generate --git https://github.com/esp-rs/esp-hal --name montic-w02 -
Build and flash
Terminal window cargo build --releaseespflash 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.
-
Add the target
Terminal window rustup target add riscv32imac-unknown-none-elf -
Create a project and add the HAL
Create a project with
cargo new, then add the CH32-RS HAL and Embassy dependencies inCargo.toml. See the CH32-RS examples for reference. -
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; }}