embassy-rs / embassy

Modern embedded framework, using Rust and async.
https://embassy.dev
Apache License 2.0
5.51k stars 767 forks source link

could not find `executor` in `embassy` #2674

Closed 0xkelvin closed 7 months ago

0xkelvin commented 8 months ago

hello,

I am trying to do basic "hello world" with embassy on esp32c6, but i got error "could not find executor in embassy"

my cargo.toml :

[package]
name = "c6-hello"
version = "0.1.0"
authors = ["Kelvin <quocvm1@gmail.com>"]
edition = "2021"
resolver = "2"
rust-version = "1.71"

[profile.release]
opt-level = "s"

[profile.dev]
debug = true    # Symbols are nice and they don't increase the size on Flash
opt-level = "z"

[features]
default = ["std", "embassy", "esp-idf-svc/native"]

pio = ["esp-idf-svc/pio"]
std = ["alloc", "esp-idf-svc/binstart", "esp-idf-svc/std"]
alloc = ["esp-idf-svc/alloc"]
nightly = ["esp-idf-svc/nightly"]
experimental = ["esp-idf-svc/experimental"]
embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/embassy-time-driver"]

[dependencies]
log = { version = "0.4", default-features = false }
esp-idf-svc = { version = "0.48", default-features = false }
esp-backtrace       = { version = "0.11.0", features = ["esp32c6", "exception-handler", "panic-handler", "println"] }
embassy-executor    = { version = "0.5.0", features = ["nightly", "integrated-timers", "arch-riscv32", "executor-thread"] }
embassy-sync        = "0.5.0"
embassy-time        = "0.3.0"
embassy-time-driver = { version = "0.1.0", optional = true }
embedded-graphics   = "0.8.1"
embedded-hal        = "1.0.0"
embedded-hal-02     = { version = "0.2.7", package = "embedded-hal" }
embedded-hal-async  = "1.0.0"
embedded-hal-bus    = "0.1.0"
embedded-io-async   = "0.6.1"
esp32c6-hal = { version = "0.8.0", features = ["async", "embassy", "embassy-time-timg0"] }
esp-println = { version = "0.9.0", features = ["esp32c6"] }

[build-dependencies]
embuild = "0.31.3"

and the main.rs :

//! embassy hello world
//!
//! This is an example of running the embassy executor with multiple tasks
//! concurrently.

//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: embassy embassy-time-timg0 embassy-executor-thread embassy-generic-timers

#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]

use embassy_executor::Spawner;
use embassy_time::{Duration, Timer};
use esp_backtrace as _;
use esp32c6_hal::{
    clock::ClockControl,
    embassy::{self},
    peripherals::Peripherals,
    prelude::*,
    timer::TimerGroup,
};

#[embassy_executor::task]
async fn run() {
    loop {
        esp_println::println!("Hello world from embassy using esp-hal-async!");
        Timer::after(Duration::from_millis(1_000)).await;
    }
}

#[main]
async fn main(spawner: Spawner) {
    esp_println::println!("Init!");
    let peripherals = Peripherals::take();
    let system = peripherals.SYSTEM.split();
    let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

    let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks);
    embassy::init(&clocks, timg0);

    spawner.spawn(run()).ok();

    loop {
        esp_println::println!("Bing!");
        Timer::after(Duration::from_millis(5_000)).await;
    }
}

great thanks for any comments

DeppLearning commented 7 months ago

Not an expert, but I guess you might be missing a feature flag, see

manuelbaez commented 7 months ago

Hey, not sure if this helps but you could also use the esp-hal crate for no_std then need to enable these features and should work: features = [ "esp32c6", "embassy", "embassy-time-timg0", "embassy-executor-thread", "embassy-executor-interrupt" ] I think you could also remove the esp32c6-hal crate since it's deprecated for esp-hal.

0xkelvin commented 7 months ago

thanks, that's works