Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
enelson1001 opened this issue Dec 22, 2023 · 1 comment
Closed

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

enelson1001 opened this issue Dec 22, 2023 · 1 comment

Comments

@enelson1001
Copy link

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?

@enelson1001
Copy link
Author

Solved

Needed to add embassy-executor-thread to esp32s3-hal

esp32s3-hal = { version = "0.14.0", features = ["async", "embassy", "embassy-time-timg0", "embassy-executor-thread"] }

Not required but I also modified main.rs just to use embassy-time-timg0

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

    // Using 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;
    }
}

@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

1 participant