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

esp-wifi doesn't compile with "defmt" feature #2125

Closed
okhsunrog opened this issue Sep 9, 2024 · 1 comment · Fixed by #2126
Closed

esp-wifi doesn't compile with "defmt" feature #2125

okhsunrog opened this issue Sep 9, 2024 · 1 comment · Fixed by #2126
Assignees
Labels
bug Something isn't working

Comments

@okhsunrog
Copy link
Contributor

Here's my Cargo.toml for esp32-c3, I'm using defmt for logging:

[package]
name         = "esp_hal_probe"
version      = "0.1.0"
edition      = "2021"
rust-version = "1.76.0"

[dependencies]
bt-hci           = "0.1.0"
defmt            = "0.3"
defmt-rtt        = "0.4"
embassy-executor = { version = "0.6",  features = ["defmt"] }
embassy-time     = { version = "0.3",  features = ["generic-queue-8"] }
esp-alloc        = "0.4.0"
esp-backtrace    = { version = "0.14", features = ["esp32c3", "defmt", "exception-handler", "panic-handler"] }
esp-hal          = { version = "0.20", features = ["esp32c3", "defmt"] }
esp-hal-embassy  = { version = "0.3",  features = ["esp32c3", "defmt"] }
esp-wifi         = { version = "0.9",  default-features = false, features = ["defmt", "esp32c3", "ble", "async", "esp-alloc"] }
trouble-host     = { default-features = false, features = ["gatt" ], git = "https://github.com/embassy-rs/trouble", package = "trouble-host", rev = "29dabe756dc6755a0294432e63ab1da68ec0dde0"}

[profile.release]
codegen-units    = 1
debug            = 2
debug-assertions = false
incremental      = false
opt-level        = 3
lto = 'fat'
overflow-checks  = false

[patch.crates-io]
esp-hal = { git = "https://github.com/esp-rs/esp-hal", rev = "be82a6521a5859129ca4f98e54e4d4d6cedffe76" }
esp-hal-embassy = { git = "https://github.com/esp-rs/esp-hal", rev = "be82a6521a5859129ca4f98e54e4d4d6cedffe76" }
esp-backtrace = { git = "https://github.com/esp-rs/esp-hal", rev = "be82a6521a5859129ca4f98e54e4d4d6cedffe76" }
esp-wifi = { git = "https://github.com/esp-rs/esp-hal", rev = "be82a6521a5859129ca4f98e54e4d4d6cedffe76" }
esp-alloc = { git = "https://github.com/esp-rs/esp-hal", rev = "be82a6521a5859129ca4f98e54e4d4d6cedffe76" }

The project's code for now is just embassy hello world code from esp-hal's examples with esp-log's printlns replaced with defmt functions. The project build fine when I don't enable "defmt" feature for esp-wifi, but when I try to build the code with "defmt" feature enabled for esp-wifi, I get this error:

 Compiling esp-wifi v0.9.1 (https://github.com/esp-rs/esp-hal?rev=be82a6521a5859129ca4f98e54e4d4d6cedffe76#be82a652)
error[E0277]: the trait bound `FromHciBytesError: Format` is not satisfied
   --> /home/okhsunrog/.cargo/git/checkouts/esp-hal-42ec44e8c6943228/be82a65/esp-wifi/src/fmt.rs:151:13
    |
151 |             ::defmt::warn!($s $(, $x)*);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Format` is not implemented for `FromHciBytesError`
    |
   ::: /home/okhsunrog/.cargo/git/checkouts/esp-hal-42ec44e8c6943228/be82a65/esp-wifi/src/ble/controller/mod.rs:207:17
    |
207 |                 warn!("[hci] error parsing packet: {:?}", e);
    |                 -------------------------------------------- in this macro invocation
    |
    = help: the following other types implement trait `Format`:
              &T
              &mut T
              ()
              (T0, T1)
              (T0, T1, T2)
              (T0, T1, T2, T3)
              (T0, T1, T2, T3, T4)
              (T0, T1, T2, T3, T4, T5)
            and 208 others
note: required by a bound in `defmt::export::fmt`
   --> /home/okhsunrog/.cargo/registry/src/index.crates.io-6f17d22bba15001f/defmt-0.3.8/src/export/mod.rs:137:15
    |
137 | pub fn fmt<T: Format + ?Sized>(f: &T) {
    |               ^^^^^^ required by this bound in `fmt`
    = note: this error originates in the macro `::defmt::warn` which comes from the expansion of the macro `warn` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `esp-wifi` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
@okhsunrog
Copy link
Contributor Author

Here's my config.toml in case it's needed:

[env]
DEFMT_LOG="info"

[build]
target    = "riscv32imc-unknown-none-elf"
rustflags = [
  "-C", "link-arg=-Tdefmt.x",
  "-C", "link-arg=-Tlinkall.x",
  # NOTE: This is required to obtain backtraces, however it may negatively
  #       impact the performance of your application.
  "-C", "force-frame-pointers",
]

[target.riscv32imc-unknown-none-elf]
runner = "probe-rs run --chip=esp32c3"

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

I'm building with the latest nightly version of Rust

@tom-borcin tom-borcin added the chip:esp32c3 Issue related to ESP32-C3 chip label Sep 9, 2024
@bjoernQ bjoernQ added bug Something isn't working and removed chip:esp32c3 Issue related to ESP32-C3 chip labels Sep 9, 2024
@bjoernQ bjoernQ self-assigned this Sep 9, 2024
@bjoernQ bjoernQ linked a pull request Sep 9, 2024 that will close this issue
6 tasks
@bjoernQ bjoernQ added chip:esp32c3 Issue related to ESP32-C3 chip and removed chip:esp32c3 Issue related to ESP32-C3 chip labels Sep 9, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants