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

Any examples for ESP32? #5

Open
kokroo opened this issue Mar 9, 2024 · 3 comments
Open

Any examples for ESP32? #5

kokroo opened this issue Mar 9, 2024 · 3 comments

Comments

@kokroo
Copy link

kokroo commented Mar 9, 2024

Hello,

I am trying to run Embassy on an ESP32, not ESP32C3. I was able to run the examples from the esp-hal repo, but I wanted to write something from scratch. I tried using code from your repo but looks like it's not working because it targets the wrong arch for my use case.

I would really appreciate it if you could provide some ESP32 examples as well!

@apollolabsdev
Copy link
Owner

apollolabsdev commented Mar 9, 2024

Correct, the project settings in the repo are set up for the esp32c3.

To start from scratch though with any ESP device, espressif provides tools to make it a breeze. Not sure if you saw how to generate projects with cargo-generate but there are set-up instructions here. There are two templates, one for no_std and one for std development. If you want to choose the std approach, you'll need some esp-idf framework prerequisites installed. Nevertheless, when generating a project, it inquires about the device and configures the settings accordingly when spawning a project. That's the way I go every time I create a new project. For a device other than the ESP32C3 it wouldn't be any different.

Be mindful though that with the base spawned project, if you want to do embassy, you still need to modify the base cargo.toml and the main.rs. Though at least those would be similar to what you find in this repo.

@kokroo
Copy link
Author

kokroo commented Mar 10, 2024

Be mindful though that with the base spawned project, if you want to do embassy, you still need to modify the base cargo.toml and the main.rs. Though at least those would be similar to what you find in this repo.

That is my main gripe, the generator does not include embassy. The esp-hal examples import an embassy crate from within esp-hal crate. That confused me a bit. There aren't many guides or documentation to begin with for this stuff since Rust on embedded stuff is still relatively new.

@apollolabsdev
Copy link
Owner

apollolabsdev commented Mar 10, 2024

Certainly, I spent an hour myself the other day trying to fix dependencies on a new project where I used the latest crate versions. It turns out that some feature activations moved between crates. Until the project becomes a bit more stable, unfortunately, this experience will remain the same. There are still a lot of moving parts and the latest documentation is not easily accessible. In the esp-hal, embassy necessary components are incorporated as features. You'd have to activate the correct components to get started. This is in addition to adjusting the main.rs template accordingly. Below is a dependency list that should work with the latest crate versions. Give it a try. Just make sure to adjust the device name.

[dependencies]
esp32c3-hal = {version = "0.15.0", features=["async", "embassy", "embassy-time-timg0", "embassy-executor-interrupt","embassy-executor-thread"]}
esp-backtrace = { version = "0.11.0", features = ["esp32c3", "panic-handler", "exception-handler", "println"] }
esp-println = { version = "0.9.0", features = ["esp32c3"] }
embassy-executor    = { version = "0.5.0", features = ["nightly",  "integrated-timers"]}
embassy-time        = "0.3.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants