diff --git a/CHANGELOG.md b/CHANGELOG.md index dcd1d75..384b1af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Enable https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames with a threshold of 1024 (#241) + ### Changed ### Fixed diff --git a/template/.clippy.toml b/template/.clippy.toml new file mode 100644 index 0000000..76f6c1d --- /dev/null +++ b/template/.clippy.toml @@ -0,0 +1 @@ +stack-size-threshold = 1024 diff --git a/template/src/bin/async_main.rs b/template/src/bin/async_main.rs index 4552777..02d1354 100644 --- a/template/src/bin/async_main.rs +++ b/template/src/bin/async_main.rs @@ -7,6 +7,7 @@ reason = "mem::forget is generally not safe to do with esp_hal types, especially those \ holding buffers for the duration of a data transfer." )] +#![deny(clippy::large_stack_frames)] use esp_hal::clock::CpuClock; use esp_hal::timer::timg::TimerGroup; @@ -57,6 +58,10 @@ const L2CAP_CHANNELS_MAX: usize = 1; // For more information see: esp_bootloader_esp_idf::esp_app_desc!(); +#[allow( + clippy::large_stack_frames, + reason = "it's not unusual to allocate larger buffers etc. in main" +)] #[esp_rtos::main] async fn main(spawner: Spawner) -> ! { //REPLACE generate-version generate-version @@ -88,9 +93,10 @@ async fn main(spawner: Spawner) -> ! { //IF option("esp32") || option("esp32s2") || option("esp32s3") esp_rtos::start(timg0.timer0); //ELSE - let sw_interrupt = esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); + let sw_interrupt = + esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0); - //ENDIF + //ENDIF //IF option("defmt") || option("log") info!("Embassy initialized!"); @@ -99,17 +105,17 @@ async fn main(spawner: Spawner) -> ! { //ENDIF //IF option("ble-trouble") || option("ble-bleps") || option("wifi") - let radio_init = esp_radio::init() - .expect("Failed to initialize Wi-Fi/BLE controller"); + let radio_init = esp_radio::init().expect("Failed to initialize Wi-Fi/BLE controller"); //ENDIF //IF option("wifi") - let (mut _wifi_controller, _interfaces) = esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default()) - .expect("Failed to initialize Wi-Fi controller"); + let (mut _wifi_controller, _interfaces) = + esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default()) + .expect("Failed to initialize Wi-Fi controller"); //ENDIF //IF option("ble-trouble") // find more examples https://github.com/embassy-rs/trouble/tree/main/examples/esp32 let transport = BleConnector::new(&radio_init, peripherals.BT, Default::default()).unwrap(); - let ble_controller = ExternalController::<_, 20>::new(transport); + let ble_controller = ExternalController::<_, 1>::new(transport); let mut resources: HostResources = HostResources::new(); let _stack = trouble_host::new(ble_controller, &mut resources); diff --git a/template/src/bin/main.rs b/template/src/bin/main.rs index 126ec07..5c23cb9 100644 --- a/template/src/bin/main.rs +++ b/template/src/bin/main.rs @@ -6,6 +6,7 @@ reason = "mem::forget is generally not safe to do with esp_hal types, especially those \ holding buffers for the duration of a data transfer." )] +#![deny(clippy::large_stack_frames)] use esp_hal::{ clock::CpuClock, @@ -49,6 +50,10 @@ extern crate alloc; // For more information see: esp_bootloader_esp_idf::esp_app_desc!(); +#[allow( + clippy::large_stack_frames, + reason = "it's not unusual to allocate larger buffers etc. in main" +)] #[main] fn main() -> ! { //REPLACE generate-version generate-version @@ -85,15 +90,16 @@ fn main() -> ! { //IF option("esp32") || option("esp32s2") || option("esp32s3") esp_rtos::start(timg0.timer0); //ELSE - let sw_interrupt = esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); + let sw_interrupt = + esp_hal::interrupt::software::SoftwareInterruptControl::new(peripherals.SW_INTERRUPT); esp_rtos::start(timg0.timer0, sw_interrupt.software_interrupt0); - //ENDIF - let radio_init = esp_radio::init() - .expect("Failed to initialize Wi-Fi/BLE controller"); + //ENDIF + let radio_init = esp_radio::init().expect("Failed to initialize Wi-Fi/BLE controller"); //ENDIF //IF option("wifi") - let (mut _wifi_controller, _interfaces) = esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default()) - .expect("Failed to initialize Wi-Fi controller"); + let (mut _wifi_controller, _interfaces) = + esp_radio::wifi::new(&radio_init, peripherals.WIFI, Default::default()) + .expect("Failed to initialize Wi-Fi controller"); //ENDIF //IF option("ble-bleps") let _connector = BleConnector::new(&radio_init, peripherals.BT, Default::default());