I/ve tried one of your examples for esp32c3. Sadly, the following does it produce:
warning: Git tree '/home/ulysses/projects/rust/espc3-firmware' is dirty
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: cleaning up downloads & tmp directories
info: self-update is disabled for this build of rustup
info: any updates to rustup will need to be fetched with your system package manager
Checking espc3-firmware v0.1.0 (/home/ulysses/projects/rust/espc3-firmware)
error[E0308]: mismatched types
--> src/hello_rtic.rs:15:5
|
15 | esp32c3_systimer_monotonic!(Mono);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected `SYSTIMER`, found `Periph<RegisterBlock, 1610756096>`
| arguments to this function are incorrect
|
= note: expected struct `esp32c3::SYSTIMER`
found struct `Periph<esp32c3::systimer::RegisterBlock, 1610756096>`
note: associated function defined here
--> /home/ulysses/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rtic-monotonics-2.1.0/src/esp32c3.rs:50:12
|
50 | pub fn _start(timer: SYSTIMER) {
| ^^^^^^
= note: this error originates in the macro `esp32c3_systimer_monotonic` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unused variable: `timer`
--> src/hello_rtic.rs:28:13
|
28 | let timer = cx.device.SYSTIMER;
| ^^^^^ help: if this is intentional, prefix it with an underscore: `_timer`
|
= note: `#[warn(unused_variables)]` on by default
For more information about this error, try `rustc --explain E0308`.
warning: `espc3-firmware` (bin "hello_rtic") generated 1 warning
error: could not compile `espc3-firmware` (bin "hello_rtic") due to 1 previous error; 1 warning emitted
That's the program code:
#![deny(
clippy::mem_forget,
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
holding buffers for the duration of a data transfer."
)]
#![no_main]
#![no_std]
use esp_backtrace as _;
esp_bootloader_esp_idf::esp_app_desc!();
#[rtic::app(device = esp32c3, dispatchers = [])]
mod app {
use rtic_monotonics::esp32c3::prelude::*;
esp32c3_systimer_monotonic!(Mono);
use esp_hal as _;
use esp_println::println;
#[shared]
struct Shared {}
#[local]
struct Local {}
#[init]
fn init(cx: init::Context) -> (Shared, Local) {
println!("init");
let timer = cx.device.SYSTIMER;
foo::spawn().unwrap();
bar::spawn().unwrap();
baz::spawn().unwrap();
(Shared {}, Local {})
}
#[task]
async fn foo(_cx: foo::Context) {
println!("hello from foo");
Mono::delay(2_u64.secs()).await;
println!("bye from foo");
}
#[task]
async fn bar(_cx: bar::Context) {
println!("hello from bar");
Mono::delay(3_u64.secs()).await;
println!("bye from bar");
}
#[task]
async fn baz(_cx: baz::Context) {
println!("hello from baz");
Mono::delay(4_u64.secs()).await;
println!("bye from baz");
}
}
That's the cargo.toml code:
[package]
name = "espc3-firmware"
version = "0.1.0"
edition = "2024"
rust-version = "1.88"
[[bin]]
name = "hello"
path = "src/hello.rs"
[[bin]]
name = "hello_rtic"
path = "src/hello_rtic.rs"
[dependencies]
esp-hal = { version = "1.0", features = [
"esp32c3",
"unstable",
"rt",
] }
esp-rtos = { version = "0.2.0", features = [
"esp-radio",
"esp-alloc",
"embassy",
"esp32c3",
]}
esp-bootloader-esp-idf = { version = "0.4.0", features = [
"esp32c3",
] }
esp-println = { version = "0.16.1", features = [
"esp32c3",
] }
esp-backtrace = { version = "0.18.1", features = [
"esp32c3",
"panic-handler",
"println",
] }
esp-alloc = "0.9.0"
embedded-io = "0.7.1"
embedded-io-async = "0.7.0"
embassy-net = { version = "0.7.1", features = [
"tcp",
"udp",
"dhcpv4",
"medium-ethernet",
] }
# for more networking protocol support see https://crates.io/crates/edge-net
smoltcp = { version = "0.12.0", default-features = false, features = [
"medium-ethernet",
"multicast",
"proto-dhcpv4",
"proto-dns",
"proto-ipv4",
"socket-dns",
"socket-raw",
"socket-tcp",
"socket-udp",
"socket-icmp",
] }
esp-radio = { version = "0.17.0", features = [
"esp32c3",
"wifi",
"smoltcp",
"esp-alloc",
"unstable",
] }
embassy-executor = { version = "0.9.1", features = [
] }
embassy-time = "0.5.0"
static_cell = "2.1.1"
critical-section = "1.2.0"
rtic = {version="2.2.0",features=["riscv-esp32c3-backend"]}
rtic-monotonics = { version = "2.1.0", features = ["esp32c3-systimer"] }
esp32c3 = { version = "0.30.0", features = ["critical-section"] }
[profile.dev]
# Rust debug is too slow.
# For debug builds always builds with some optimization
opt-level = "s"
[profile.release]
codegen-units = 1 # LLVM can perform better optimizations using a single thread
debug = 2
debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 's'
overflow-checks = false
Do you know, why it doesn't work?
I/ve tried one of your examples for esp32c3. Sadly, the following does it produce:
That's the program code:
That's the cargo.toml code:
Do you know, why it doesn't work?