esp-rs / std-training

Embedded Rust on Espressif training material.
https://esp-rs.github.io/std-training
Apache License 2.0
606 stars 78 forks source link

Compilation error when building hardware-check example for ESP32 #233

Closed Paumanok closed 8 months ago

Paumanok commented 8 months ago

I'm building the hardware-check example for an xtensa ESP32 and receiving the following two errors:

error[E0277]: the trait bound `heapless::string::String<32>: From<&str>` is not satisfied
  --> /home/matt/Documents/Projects/rust/esp_experiment/std-training/common/lib/wifi/src/lib.rs:54:20
   |
54 |         ssid: ssid.into(),
   |                    ^^^^ the trait `From<&str>` is not implemented for `heapless::string::String<32>`
   |
   = note: required for `&str` to implement `Into<heapless::string::String<32>>`

error[E0277]: the trait bound `heapless::string::String<64>: From<&str>` is not satisfied
  --> /home/matt/Documents/Projects/rust/esp_experiment/std-training/common/lib/wifi/src/lib.rs:55:24
   |
55 |         password: pass.into(),
   |                        ^^^^ the trait `From<&str>` is not implemented for `heapless::string::String<64>`
   |
   = note: required for `&str` to implement `Into<heapless::string::String<64>>`

I configured my environment via the instructions in the esp rust book here https://esp-rs.github.io/book/installation/riscv-and-xtensa.html

I made one change to the hardware-check Cargo.toml at the suggestion of the compiler, which was using esp-idf-svc version 0.48.0 over 0.47.3.

MabezDev commented 8 months ago

at the suggestion of the compiler,

Why did it suggest that? Could you tell me the error/warning message? As a rule of thumb, we test this crate with the versions provided, if you start changing dependencies you'll have to figure out the changes that go along with that. With that said, esp-idf-svc uses heaplesss 0.8 which no longer implements From<&str>,

From https://github.com/rust-embedded/heapless/blob/main/CHANGELOG.md

[breaking-change] From<&str> for String was replaced with TryFrom<&str> because the From trait must not fail.

Paumanok commented 8 months ago

Why did it suggest that? Could you tell me the error/warning message?

I went back through and returned the versions. I think the generated project with cargo generate defaulted to the newer svc version and I tried to bring the examples up to the generated version. Changing it back, the example compiles. I was trying to use the wifi::wifi crate in the examples for my own purposes. I'll mark this closed since it isn't a problem with the std-training.