From cfb83b153dfeb7ca44b622a50be3131bbd213676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Quentin?= Date: Wed, 27 Nov 2024 15:14:04 +0100 Subject: [PATCH] Fixed triggering a debug-assertion during scan (#2612) * Fixed triggering a debug-assertion during scan * CHANGELOGs * Change `debug_assert` into warning level log * Enable debug-asserts in hil-test, qa-test and examples * Change the way we detect and warn about debug-builds * Warn if opt-level is `0` or `1` --- esp-hal/Cargo.toml | 1 + esp-hal/build.rs | 16 +++++++--------- esp-hal/src/lib.rs | 9 +++++++++ esp-metadata/CHANGELOG.md | 1 + esp-metadata/devices/esp32c6.toml | 1 + esp-wifi/CHANGELOG.md | 1 + esp-wifi/src/wifi/event.rs | 29 +++++++++++++++++++++-------- examples/Cargo.toml | 2 +- hil-test/Cargo.toml | 2 +- qa-test/Cargo.toml | 1 + 10 files changed, 44 insertions(+), 19 deletions(-) diff --git a/esp-hal/Cargo.toml b/esp-hal/Cargo.toml index e1b3770fc2d..68ab0ade890 100644 --- a/esp-hal/Cargo.toml +++ b/esp-hal/Cargo.toml @@ -37,6 +37,7 @@ embedded-hal-nb = "1.0.0" embedded-io = "0.6.1" embedded-io-async = "0.6.1" enumset = "1.1.5" +esp-build = { version = "0.1.0", path = "../esp-build" } esp-synopsys-usb-otg = { version = "0.4.2", optional = true, features = ["fs", "esp32sx"] } fugit = "0.3.7" log = { version = "0.4.22", optional = true } diff --git a/esp-hal/build.rs b/esp-hal/build.rs index 9e0f49684c0..8e283f1c474 100644 --- a/esp-hal/build.rs +++ b/esp-hal/build.rs @@ -11,16 +11,14 @@ use esp_build::assert_unique_used_features; use esp_config::{generate_config, Value}; use esp_metadata::{Chip, Config}; -#[cfg(debug_assertions)] -esp_build::warning! {" -WARNING: use --release - We *strongly* recommend using release profile when building esp-hal. - The dev profile can potentially be one or more orders of magnitude - slower than release, and may cause issues with timing-senstive - peripherals and/or devices. -"} - fn main() -> Result<(), Box> { + println!("cargo:rustc-check-cfg=cfg(is_debug_build)"); + if let Ok(level) = std::env::var("OPT_LEVEL") { + if level == "0" || level == "1" { + println!("cargo:rustc-cfg=is_debug_build"); + } + } + // NOTE: update when adding new device support! // Ensure that exactly one chip has been specified: assert_unique_used_features!( diff --git a/esp-hal/src/lib.rs b/esp-hal/src/lib.rs index 8dfb652c50d..aafe8b21ea8 100644 --- a/esp-hal/src/lib.rs +++ b/esp-hal/src/lib.rs @@ -261,6 +261,15 @@ pub mod trapframe { // be directly exposed. mod soc; +#[cfg(is_debug_build)] +esp_build::warning! {" +WARNING: use --release + We *strongly* recommend using release profile when building esp-hal. + The dev profile can potentially be one or more orders of magnitude + slower than release, and may cause issues with timing-senstive + peripherals and/or devices. +"} + /// A marker trait for initializing drivers in a specific mode. pub trait Mode: crate::private::Sealed {} diff --git a/esp-metadata/CHANGELOG.md b/esp-metadata/CHANGELOG.md index ea6930f68c0..d362ae1a250 100644 --- a/esp-metadata/CHANGELOG.md +++ b/esp-metadata/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Introduced the `wifi6` symbol (#2612) ### Fixed diff --git a/esp-metadata/devices/esp32c6.toml b/esp-metadata/devices/esp32c6.toml index 128e8a06c24..6b59d5e02ea 100644 --- a/esp-metadata/devices/esp32c6.toml +++ b/esp-metadata/devices/esp32c6.toml @@ -80,6 +80,7 @@ symbols = [ "phy", "bt", "wifi", + "wifi6", "ieee802154", "lp_core", diff --git a/esp-wifi/CHANGELOG.md b/esp-wifi/CHANGELOG.md index 0ffc9b157b0..5f9b7ef3457 100644 --- a/esp-wifi/CHANGELOG.md +++ b/esp-wifi/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed ### Fixed +- Fixed triggering a debug-assertion during scan (#2612) ### Removed diff --git a/esp-wifi/src/wifi/event.rs b/esp-wifi/src/wifi/event.rs index e4925d921b4..ac99767460c 100644 --- a/esp-wifi/src/wifi/event.rs +++ b/esp-wifi/src/wifi/event.rs @@ -104,7 +104,7 @@ macro_rules! impl_wifi_event { } impl_wifi_event!(WifiReady); -impl_wifi_event!(ScanDone); +impl_wifi_event!(ScanDone, wifi_event_sta_scan_done_t); impl_wifi_event!(StaStart); impl_wifi_event!(StaStop); impl_wifi_event!(StaConnected, wifi_event_sta_connected_t); @@ -131,13 +131,25 @@ impl_wifi_event!(ApWpsRgFailed, wifi_event_ap_wps_rg_fail_reason_t); impl_wifi_event!(ApWpsRgTimeout); impl_wifi_event!(ApWpsRgPin, wifi_event_ap_wps_rg_pin_t); impl_wifi_event!(ApWpsRgPbcOverlap); -impl_wifi_event!(ItwtSetup); -impl_wifi_event!(ItwtTeardown); -impl_wifi_event!(ItwtProbe); -impl_wifi_event!(ItwtSuspend); -impl_wifi_event!(TwtWakeup); -impl_wifi_event!(BtwtSetup); -impl_wifi_event!(BtwtTeardown); +cfg_if::cfg_if! { + if #[cfg(wifi6)] { + impl_wifi_event!(ItwtSetup, wifi_event_sta_itwt_setup_t); + impl_wifi_event!(ItwtTeardown, wifi_event_sta_itwt_teardown_t); + impl_wifi_event!(ItwtProbe, wifi_event_sta_itwt_probe_t); + impl_wifi_event!(ItwtSuspend, wifi_event_sta_itwt_suspend_t); + impl_wifi_event!(TwtWakeup); + impl_wifi_event!(BtwtSetup, wifi_event_sta_btwt_setup_t); + impl_wifi_event!(BtwtTeardown, wifi_event_sta_btwt_teardown_t); + } else { + impl_wifi_event!(ItwtSetup); + impl_wifi_event!(ItwtTeardown); + impl_wifi_event!(ItwtProbe); + impl_wifi_event!(ItwtSuspend); + impl_wifi_event!(TwtWakeup); + impl_wifi_event!(BtwtSetup); + impl_wifi_event!(BtwtTeardown); + } +} impl_wifi_event!(NanStarted); impl_wifi_event!(NanStopped); impl_wifi_event!(NanSvcMatch, wifi_event_nan_svc_match_t); @@ -173,6 +185,7 @@ pub(crate) unsafe fn handle_raw( core::mem::size_of::(), "wrong size event data" ); + handle::(unsafe { &Event::from_raw_event_data(event_data) }) } diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 5972c6a3b8b..50faa946801 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -65,7 +65,7 @@ embassy-generic-timers = ["embassy-time/generic-queue-8"] [profile.release] codegen-units = 1 debug = 2 -debug-assertions = false +debug-assertions = true incremental = false opt-level = 3 lto = 'fat' diff --git a/hil-test/Cargo.toml b/hil-test/Cargo.toml index e033ac3f353..cc273714e98 100644 --- a/hil-test/Cargo.toml +++ b/hil-test/Cargo.toml @@ -311,7 +311,7 @@ overflow-checks = true [profile.release] codegen-units = 1 debug = 2 -debug-assertions = false +debug-assertions = true incremental = false opt-level = 3 lto = false # LTO (thin or fat) miscompiles some tests on RISC-V diff --git a/qa-test/Cargo.toml b/qa-test/Cargo.toml index ea0f64d239c..d7760ce52e9 100644 --- a/qa-test/Cargo.toml +++ b/qa-test/Cargo.toml @@ -32,5 +32,6 @@ embassy-generic-timers = ["embassy-time/generic-queue-8"] [profile.release] debug = 2 +debug-assertions = true lto = "fat" codegen-units = 1