diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32h755cm4/Cargo.toml | 5 | ||||
| -rw-r--r-- | examples/stm32h755cm4/src/bin/intercore.rs | 8 | ||||
| -rw-r--r-- | examples/stm32h755cm7/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/stm32h755cm7/src/bin/intercore.rs | 18 |
4 files changed, 20 insertions, 14 deletions
diff --git a/examples/stm32h755cm4/Cargo.toml b/examples/stm32h755cm4/Cargo.toml index c6d4996f1..d2b9b1f0e 100644 --- a/examples/stm32h755cm4/Cargo.toml +++ b/examples/stm32h755cm4/Cargo.toml | |||
| @@ -49,12 +49,11 @@ overflow-checks = true # <- | |||
| 49 | 49 | ||
| 50 | # cargo build/run --release | 50 | # cargo build/run --release |
| 51 | [profile.release] | 51 | [profile.release] |
| 52 | codegen-units = 1 | 52 | codegen-units = 16 |
| 53 | debug = 2 | 53 | debug = 2 |
| 54 | debug-assertions = false # <- | 54 | debug-assertions = false # <- |
| 55 | incremental = false | 55 | incremental = false |
| 56 | #lto = 'fat' | 56 | opt-level = 3 # <- |
| 57 | #opt-level = 3 # <- | ||
| 58 | overflow-checks = false # <- | 57 | overflow-checks = false # <- |
| 59 | 58 | ||
| 60 | # cargo test --release | 59 | # cargo test --release |
diff --git a/examples/stm32h755cm4/src/bin/intercore.rs b/examples/stm32h755cm4/src/bin/intercore.rs index 8f61c3eb2..3a66a1ecd 100644 --- a/examples/stm32h755cm4/src/bin/intercore.rs +++ b/examples/stm32h755cm4/src/bin/intercore.rs | |||
| @@ -45,7 +45,7 @@ mod shared { | |||
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | self.led_states.store(new_value, Ordering::SeqCst); | 47 | self.led_states.store(new_value, Ordering::SeqCst); |
| 48 | core::sync::atomic::compiler_fence(Ordering::SeqCst); | 48 | core::sync::atomic::fence(Ordering::SeqCst); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | /// Get LED state using safe bit operations | 51 | /// Get LED state using safe bit operations |
| @@ -54,7 +54,7 @@ mod shared { | |||
| 54 | let bit = if is_green { GREEN_LED_BIT } else { YELLOW_LED_BIT }; | 54 | let bit = if is_green { GREEN_LED_BIT } else { YELLOW_LED_BIT }; |
| 55 | 55 | ||
| 56 | let value = self.led_states.load(Ordering::SeqCst); | 56 | let value = self.led_states.load(Ordering::SeqCst); |
| 57 | core::sync::atomic::compiler_fence(Ordering::SeqCst); | 57 | core::sync::atomic::fence(Ordering::SeqCst); |
| 58 | 58 | ||
| 59 | (value & (1 << bit)) != 0 | 59 | (value & (1 << bit)) != 0 |
| 60 | } | 60 | } |
| @@ -66,7 +66,7 @@ mod shared { | |||
| 66 | let current = self.counter.load(Ordering::SeqCst); | 66 | let current = self.counter.load(Ordering::SeqCst); |
| 67 | let new_value = current.wrapping_add(1); | 67 | let new_value = current.wrapping_add(1); |
| 68 | self.counter.store(new_value, Ordering::SeqCst); | 68 | self.counter.store(new_value, Ordering::SeqCst); |
| 69 | core::sync::atomic::compiler_fence(Ordering::SeqCst); | 69 | core::sync::atomic::fence(Ordering::SeqCst); |
| 70 | new_value | 70 | new_value |
| 71 | } | 71 | } |
| 72 | 72 | ||
| @@ -74,7 +74,7 @@ mod shared { | |||
| 74 | #[inline(never)] | 74 | #[inline(never)] |
| 75 | pub fn get_counter(&self) -> u32 { | 75 | pub fn get_counter(&self) -> u32 { |
| 76 | let value = self.counter.load(Ordering::SeqCst); | 76 | let value = self.counter.load(Ordering::SeqCst); |
| 77 | core::sync::atomic::compiler_fence(Ordering::SeqCst); | 77 | core::sync::atomic::fence(Ordering::SeqCst); |
| 78 | value | 78 | value |
| 79 | } | 79 | } |
| 80 | } | 80 | } |
diff --git a/examples/stm32h755cm7/Cargo.toml b/examples/stm32h755cm7/Cargo.toml index 06a3b06af..2e34f0928 100644 --- a/examples/stm32h755cm7/Cargo.toml +++ b/examples/stm32h755cm7/Cargo.toml | |||
| @@ -47,11 +47,10 @@ overflow-checks = true # <- | |||
| 47 | 47 | ||
| 48 | # cargo build/run --release | 48 | # cargo build/run --release |
| 49 | [profile.release] | 49 | [profile.release] |
| 50 | codegen-units = 1 | 50 | codegen-units = 16 |
| 51 | debug = 2 | 51 | debug = 2 |
| 52 | debug-assertions = false # <- | 52 | debug-assertions = false # <- |
| 53 | incremental = false | 53 | incremental = false |
| 54 | lto = 'fat' | ||
| 55 | opt-level = 3 # <- | 54 | opt-level = 3 # <- |
| 56 | overflow-checks = false # <- | 55 | overflow-checks = false # <- |
| 57 | 56 | ||
diff --git a/examples/stm32h755cm7/src/bin/intercore.rs b/examples/stm32h755cm7/src/bin/intercore.rs index f01d6a6b7..f1fbd29bc 100644 --- a/examples/stm32h755cm7/src/bin/intercore.rs +++ b/examples/stm32h755cm7/src/bin/intercore.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use core::mem::MaybeUninit; | 4 | use core::mem::MaybeUninit; |
| 5 | 5 | ||
| 6 | use cortex_m::asm; | 6 | use cortex_m::asm; |
| 7 | use cortex_m::peripheral::{MPU, SCB}; | 7 | use cortex_m::peripheral::MPU; |
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::{Config, SharedData}; | 10 | use embassy_stm32::{Config, SharedData}; |
| @@ -102,7 +102,7 @@ mod shared { | |||
| 102 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | 102 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); |
| 103 | 103 | ||
| 104 | // Function to configure MPU with your provided settings | 104 | // Function to configure MPU with your provided settings |
| 105 | fn configure_mpu_non_cacheable(mpu: &mut MPU, _scb: &mut SCB) { | 105 | fn configure_mpu_non_cacheable(mpu: &mut MPU) { |
| 106 | // Ensure all operations complete before reconfiguring MPU/caches | 106 | // Ensure all operations complete before reconfiguring MPU/caches |
| 107 | asm::dmb(); | 107 | asm::dmb(); |
| 108 | unsafe { | 108 | unsafe { |
| @@ -147,11 +147,19 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 147 | // Configure MPU to make SRAM4 non-cacheable | 147 | // Configure MPU to make SRAM4 non-cacheable |
| 148 | { | 148 | { |
| 149 | let mut cp = cortex_m::Peripherals::take().unwrap(); | 149 | let mut cp = cortex_m::Peripherals::take().unwrap(); |
| 150 | let mpu = &mut cp.MPU; | ||
| 151 | let scb = &mut cp.SCB; | 150 | let scb = &mut cp.SCB; |
| 152 | 151 | ||
| 153 | // Configure MPU without disabling caches | 152 | scb.disable_icache(); |
| 154 | configure_mpu_non_cacheable(mpu, scb); | 153 | scb.disable_dcache(&mut cp.CPUID); |
| 154 | |||
| 155 | // 2. MPU setup | ||
| 156 | configure_mpu_non_cacheable(&mut cp.MPU); | ||
| 157 | |||
| 158 | // 3. re-enable caches | ||
| 159 | scb.enable_icache(); | ||
| 160 | scb.enable_dcache(&mut cp.CPUID); | ||
| 161 | asm::dsb(); | ||
| 162 | asm::isb(); | ||
| 155 | } | 163 | } |
| 156 | 164 | ||
| 157 | // Configure the clocks | 165 | // Configure the clocks |
