Skip to content

Can't build embassy-hello-world on ESP32S3 #1050

Description

@enelson1001

I am trying to build embassy-hello-world for ESP32S3 and keep getting the following error. If I add 'use embassy_executor::raw::Executor;' I still get the same error and 'use embassy_executor::raw::Executor;' is indicated as not being used.

error[E0433]: failed to resolve: could not find `executor` in `embassy`
  --> src/main.rs:24:1
   |
24 | #[main]
   | ^^^^^^^ could not find `executor` in `embassy`
   |
   = note: this error originates in the attribute macro `main` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
   |
5  + use embassy_executor::raw::Executor;
   |

warning: unused import: `embassy_executor::raw::Executor`
 --> src/main.rs:5:5
  |
5 | use embassy_executor::raw::Executor;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `self`
  --> src/main.rs:10:15
   |
10 |     embassy::{self},
   |               ^^^^

warning: unused variable: `clocks`
  --> src/main.rs:29:9
   |
29 |     let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
   |         ^^^^^^ help: if this is intentional, prefix it with an underscore: `_clocks`
   |
   = note: `#[warn(unused_variables)]` on by default

error[E0282]: type annotations needed
  --> src/main.rs:24:1
   |
24 | #[main]
   | ^^^^^^^ cannot infer type
   |
   = note: this error originates in the attribute macro `main` (in Nightly builds, run with -Z macro-backtrace for more info)

This is my Cargo.toml

[package]
name = "hello-world"
version = "0.1.0"
authors = ["enelson1001 <ednelson5080@gmail>"]
edition = "2021"
resolver = "2"
rust-version = "1.71"

[dependencies]
esp32s3-hal = { version = "0.14.0", features = ["async", "embassy", "embassy-time-timg0"] }
esp-backtrace = { version = "0.9.0", features = [
    "esp32s3",
    "panic-handler",
    "exception-handler",
    "print-uart",
] }
esp-println = { version = "0.8.0", features = ["esp32s3"] }


# Async dependencies
#embedded-hal-async = { version = "=1.0.0-rc.2" }
#embassy-sync = { version = "0.5.0",optional = true }
#embassy-futures = { version = "0.1.0", optional = true }
embassy-executor = { version = "0.4.0", package = "embassy-executor", features = ["nightly", "integrated-timers", "executor-thread"] }
embassy-time = { version = "0.2.0" }

This is my config.toml

[target.xtensa-esp32s3-none-elf]
runner = "espflash flash --monitor"

[build]
rustflags = [
  # GNU LD
  "-C", "link-arg=-nostartfiles",
  "-C", "link-arg=-Wl,-Tlinkall.x",

  # LLD
  # "-C", "linker=rust-lld",
  # "-C", "link-arg=-Tlinkall.x",
]
target = "xtensa-esp32s3-none-elf"

[unstable]
build-std = ["core", "alloc"]

This is my main.rs

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

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

#[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();

    #[cfg(feature = "embassy-time-systick")]
    embassy::init(
        &clocks,
        esp32s3_hal::systimer::SystemTimer::new(peripherals.SYSTIMER),
    );

    #[cfg(feature = "embassy-time-timg0")]
    {
        let timer_group0 = esp32s3_hal::timer::TimerGroup::new(peripherals.TIMG0, &clocks);
        embassy::init(&clocks, timer_group0.timer0);
    }

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

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

This is my settings.json under .vscode directory

{
  "rust-analyzer.checkOnSave.allTargets": false,
}

This is how I build the project.

cargo build --release

Are the examples out of date or am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions