Skip to content

Commit

Permalink
Fixed triggering a debug-assertion during scan (#2612)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
bjoernQ authored Nov 27, 2024
1 parent 2512658 commit cfb83b1
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 19 deletions.
1 change: 1 addition & 0 deletions esp-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
16 changes: 7 additions & 9 deletions esp-hal/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn Error>> {
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!(
Expand Down
9 changes: 9 additions & 0 deletions esp-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
1 change: 1 addition & 0 deletions esp-metadata/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions esp-metadata/devices/esp32c6.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ symbols = [
"phy",
"bt",
"wifi",
"wifi6",
"ieee802154",
"lp_core",

Expand Down
1 change: 1 addition & 0 deletions esp-wifi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 21 additions & 8 deletions esp-wifi/src/wifi/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -173,6 +185,7 @@ pub(crate) unsafe fn handle_raw<Event: EventExt>(
core::mem::size_of::<Event>(),
"wrong size event data"
);

handle::<Event>(unsafe { &Event::from_raw_event_data(event_data) })
}

Expand Down
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion hil-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions qa-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ embassy-generic-timers = ["embassy-time/generic-queue-8"]

[profile.release]
debug = 2
debug-assertions = true
lto = "fat"
codegen-units = 1

0 comments on commit cfb83b1

Please sign in to comment.