aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-10-14 00:01:49 +0200
committerDario Nieuwenhuis <[email protected]>2024-10-14 00:11:16 +0200
commitee669ee5c57851ade034beca7cfaf81825c4c21b (patch)
tree892039ef8d5b90d11bc785ee56ae15304a3127c2
parent4eb820ab6c50a0bd84f22439dab305289b3ba4a1 (diff)
Update nighlty, fix warnings.
Fixes #2599
-rw-r--r--embassy-rp/src/lib.rs6
-rw-r--r--embassy-rp/src/multicore.rs4
-rw-r--r--embassy-stm32-wpan/src/lib.rs1
-rw-r--r--embassy-stm32-wpan/src/mac/commands.rs2
-rw-r--r--embassy-stm32/src/low_power.rs3
-rw-r--r--embassy-stm32/src/rcc/mod.rs10
-rw-r--r--examples/stm32h7/src/bin/sai.rs10
-rw-r--r--examples/stm32h7/src/bin/spi_bdma.rs7
-rw-r--r--rust-toolchain-nightly.toml2
-rw-r--r--tests/nrf/src/bin/buffered_uart_spam.rs2
-rw-r--r--tests/stm32/src/bin/usart_rx_ringbuffered.rs3
11 files changed, 30 insertions, 20 deletions
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs
index 7ac18c1f8..f56cfba27 100644
--- a/embassy-rp/src/lib.rs
+++ b/embassy-rp/src/lib.rs
@@ -480,7 +480,7 @@ pub fn install_core0_stack_guard() -> Result<(), ()> {
480 480
481#[cfg(all(feature = "rp2040", not(feature = "_test")))] 481#[cfg(all(feature = "rp2040", not(feature = "_test")))]
482#[inline(always)] 482#[inline(always)]
483fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> { 483unsafe fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
484 let core = unsafe { cortex_m::Peripherals::steal() }; 484 let core = unsafe { cortex_m::Peripherals::steal() };
485 485
486 // Fail if MPU is already configured 486 // Fail if MPU is already configured
@@ -508,7 +508,7 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
508 508
509#[cfg(all(feature = "_rp235x", not(feature = "_test")))] 509#[cfg(all(feature = "_rp235x", not(feature = "_test")))]
510#[inline(always)] 510#[inline(always)]
511fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> { 511unsafe fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
512 let core = unsafe { cortex_m::Peripherals::steal() }; 512 let core = unsafe { cortex_m::Peripherals::steal() };
513 513
514 // Fail if MPU is already configured 514 // Fail if MPU is already configured
@@ -528,7 +528,7 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
528// so the compile fails when we try to use ARMv8 peripherals. 528// so the compile fails when we try to use ARMv8 peripherals.
529#[cfg(feature = "_test")] 529#[cfg(feature = "_test")]
530#[inline(always)] 530#[inline(always)]
531fn install_stack_guard(_stack_bottom: *mut usize) -> Result<(), ()> { 531unsafe fn install_stack_guard(_stack_bottom: *mut usize) -> Result<(), ()> {
532 Ok(()) 532 Ok(())
533} 533}
534 534
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs
index 81de84907..ea0a29a36 100644
--- a/embassy-rp/src/multicore.rs
+++ b/embassy-rp/src/multicore.rs
@@ -58,7 +58,7 @@ const RESUME_TOKEN: u32 = !0xDEADBEEF;
58static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false); 58static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false);
59 59
60#[inline(always)] 60#[inline(always)]
61fn core1_setup(stack_bottom: *mut usize) { 61unsafe fn core1_setup(stack_bottom: *mut usize) {
62 if install_stack_guard(stack_bottom).is_err() { 62 if install_stack_guard(stack_bottom).is_err() {
63 // currently only happens if the MPU was already set up, which 63 // currently only happens if the MPU was already set up, which
64 // would indicate that the core is already in use from outside 64 // would indicate that the core is already in use from outside
@@ -148,7 +148,7 @@ where
148 entry: *mut ManuallyDrop<F>, 148 entry: *mut ManuallyDrop<F>,
149 stack_bottom: *mut usize, 149 stack_bottom: *mut usize,
150 ) -> ! { 150 ) -> ! {
151 core1_setup(stack_bottom); 151 unsafe { core1_setup(stack_bottom) };
152 152
153 let entry = unsafe { ManuallyDrop::take(&mut *entry) }; 153 let entry = unsafe { ManuallyDrop::take(&mut *entry) };
154 154
diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs
index f9560d235..fb34d4ba0 100644
--- a/embassy-stm32-wpan/src/lib.rs
+++ b/embassy-stm32-wpan/src/lib.rs
@@ -2,6 +2,7 @@
2#![allow(async_fn_in_trait)] 2#![allow(async_fn_in_trait)]
3#![doc = include_str!("../README.md")] 3#![doc = include_str!("../README.md")]
4// #![warn(missing_docs)] 4// #![warn(missing_docs)]
5#![allow(static_mut_refs)] // TODO: Fix
5 6
6// This must go FIRST so that all the other modules see its macros. 7// This must go FIRST so that all the other modules see its macros.
7mod fmt; 8mod fmt;
diff --git a/embassy-stm32-wpan/src/mac/commands.rs b/embassy-stm32-wpan/src/mac/commands.rs
index c97c609c3..82b9d2772 100644
--- a/embassy-stm32-wpan/src/mac/commands.rs
+++ b/embassy-stm32-wpan/src/mac/commands.rs
@@ -371,7 +371,7 @@ pub struct DataRequest {
371} 371}
372 372
373impl DataRequest { 373impl DataRequest {
374 pub fn set_buffer<'a>(&'a mut self, buf: &'a [u8]) -> &mut Self { 374 pub fn set_buffer<'a>(&'a mut self, buf: &'a [u8]) -> &'a mut Self {
375 self.msdu_ptr = buf as *const _ as *const u8; 375 self.msdu_ptr = buf as *const _ as *const u8;
376 self.msdu_length = buf.len() as u8; 376 self.msdu_length = buf.len() as u8;
377 377
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs
index f3e4c6994..2be1a42b7 100644
--- a/embassy-stm32/src/low_power.rs
+++ b/embassy-stm32/src/low_power.rs
@@ -51,6 +51,9 @@
51//! } 51//! }
52//! ``` 52//! ```
53 53
54// TODO: Usage of `static mut` here is unsound. Fix then remove this `allow`.`
55#![allow(static_mut_refs)]
56
54use core::arch::asm; 57use core::arch::asm;
55use core::marker::PhantomData; 58use core::marker::PhantomData;
56use core::sync::atomic::{compiler_fence, Ordering}; 59use core::sync::atomic::{compiler_fence, Ordering};
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs
index 8022a35a4..4f43d3748 100644
--- a/embassy-stm32/src/rcc/mod.rs
+++ b/embassy-stm32/src/rcc/mod.rs
@@ -86,7 +86,7 @@ pub(crate) unsafe fn set_freqs(freqs: Clocks) {
86#[cfg(not(feature = "_dual-core"))] 86#[cfg(not(feature = "_dual-core"))]
87/// Safety: Reads a mutable global. 87/// Safety: Reads a mutable global.
88pub(crate) unsafe fn get_freqs() -> &'static Clocks { 88pub(crate) unsafe fn get_freqs() -> &'static Clocks {
89 CLOCK_FREQS.assume_init_ref() 89 (*core::ptr::addr_of_mut!(CLOCK_FREQS)).assume_init_ref()
90} 90}
91 91
92#[cfg(feature = "_dual-core")] 92#[cfg(feature = "_dual-core")]
@@ -171,7 +171,9 @@ impl RccInfo {
171 // Use .get_mut instead of []-operator so that we control how bounds checks happen. 171 // Use .get_mut instead of []-operator so that we control how bounds checks happen.
172 // Otherwise, core::fmt will be pulled in here in order to format the integer in the 172 // Otherwise, core::fmt will be pulled in here in order to format the integer in the
173 // out-of-bounds error. 173 // out-of-bounds error.
174 if let Some(refcount) = unsafe { crate::_generated::REFCOUNTS.get_mut(refcount_idx) } { 174 if let Some(refcount) =
175 unsafe { (*core::ptr::addr_of_mut!(crate::_generated::REFCOUNTS)).get_mut(refcount_idx) }
176 {
175 *refcount += 1; 177 *refcount += 1;
176 if *refcount > 1 { 178 if *refcount > 1 {
177 return; 179 return;
@@ -235,7 +237,9 @@ impl RccInfo {
235 // Use .get_mut instead of []-operator so that we control how bounds checks happen. 237 // Use .get_mut instead of []-operator so that we control how bounds checks happen.
236 // Otherwise, core::fmt will be pulled in here in order to format the integer in the 238 // Otherwise, core::fmt will be pulled in here in order to format the integer in the
237 // out-of-bounds error. 239 // out-of-bounds error.
238 if let Some(refcount) = unsafe { crate::_generated::REFCOUNTS.get_mut(refcount_idx) } { 240 if let Some(refcount) =
241 unsafe { (*core::ptr::addr_of_mut!(crate::_generated::REFCOUNTS)).get_mut(refcount_idx) }
242 {
239 *refcount -= 1; 243 *refcount -= 1;
240 if *refcount > 0 { 244 if *refcount > 0 {
241 return; 245 return;
diff --git a/examples/stm32h7/src/bin/sai.rs b/examples/stm32h7/src/bin/sai.rs
index f6735e235..04d14bd6b 100644
--- a/examples/stm32h7/src/bin/sai.rs
+++ b/examples/stm32h7/src/bin/sai.rs
@@ -81,8 +81,9 @@ async fn main(_spawner: Spawner) {
81 rx_config.sync_output = false; 81 rx_config.sync_output = false;
82 82
83 let tx_buffer: &mut [u32] = unsafe { 83 let tx_buffer: &mut [u32] = unsafe {
84 TX_BUFFER.initialize_all_copied(0); 84 let buf = &mut *core::ptr::addr_of_mut!(TX_BUFFER);
85 let (ptr, len) = TX_BUFFER.get_ptr_len(); 85 buf.initialize_all_copied(0);
86 let (ptr, len) = buf.get_ptr_len();
86 core::slice::from_raw_parts_mut(ptr, len) 87 core::slice::from_raw_parts_mut(ptr, len)
87 }; 88 };
88 89
@@ -98,8 +99,9 @@ async fn main(_spawner: Spawner) {
98 ); 99 );
99 100
100 let rx_buffer: &mut [u32] = unsafe { 101 let rx_buffer: &mut [u32] = unsafe {
101 RX_BUFFER.initialize_all_copied(0); 102 let buf = &mut *core::ptr::addr_of_mut!(RX_BUFFER);
102 let (ptr, len) = RX_BUFFER.get_ptr_len(); 103 buf.initialize_all_copied(0);
104 let (ptr, len) = buf.get_ptr_len();
103 core::slice::from_raw_parts_mut(ptr, len) 105 core::slice::from_raw_parts_mut(ptr, len)
104 }; 106 };
105 107
diff --git a/examples/stm32h7/src/bin/spi_bdma.rs b/examples/stm32h7/src/bin/spi_bdma.rs
index 43fb6b41c..9166fe9b6 100644
--- a/examples/stm32h7/src/bin/spi_bdma.rs
+++ b/examples/stm32h7/src/bin/spi_bdma.rs
@@ -22,10 +22,11 @@ static mut RAM_D3: GroundedArrayCell<u8, 256> = GroundedArrayCell::uninit();
22#[embassy_executor::task] 22#[embassy_executor::task]
23async fn main_task(mut spi: spi::Spi<'static, Async>) { 23async fn main_task(mut spi: spi::Spi<'static, Async>) {
24 let (read_buffer, write_buffer) = unsafe { 24 let (read_buffer, write_buffer) = unsafe {
25 RAM_D3.initialize_all_copied(0); 25 let ram = &mut *core::ptr::addr_of_mut!(RAM_D3);
26 ram.initialize_all_copied(0);
26 ( 27 (
27 RAM_D3.get_subslice_mut_unchecked(0, 128), 28 ram.get_subslice_mut_unchecked(0, 128),
28 RAM_D3.get_subslice_mut_unchecked(128, 128), 29 ram.get_subslice_mut_unchecked(128, 128),
29 ) 30 )
30 }; 31 };
31 32
diff --git a/rust-toolchain-nightly.toml b/rust-toolchain-nightly.toml
index 0b10d7194..acab9d615 100644
--- a/rust-toolchain-nightly.toml
+++ b/rust-toolchain-nightly.toml
@@ -1,5 +1,5 @@
1[toolchain] 1[toolchain]
2channel = "nightly-2024-09-06" 2channel = "nightly-2024-10-13"
3components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ] 3components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ]
4targets = [ 4targets = [
5 "thumbv7em-none-eabi", 5 "thumbv7em-none-eabi",
diff --git a/tests/nrf/src/bin/buffered_uart_spam.rs b/tests/nrf/src/bin/buffered_uart_spam.rs
index e8fca452e..843313537 100644
--- a/tests/nrf/src/bin/buffered_uart_spam.rs
+++ b/tests/nrf/src/bin/buffered_uart_spam.rs
@@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) {
55 let task = unsafe { Task::new_unchecked(NonNull::new_unchecked(&spam_peri.tasks_starttx as *const _ as _)) }; 55 let task = unsafe { Task::new_unchecked(NonNull::new_unchecked(&spam_peri.tasks_starttx as *const _ as _)) };
56 let mut spam_ppi = Ppi::new_one_to_one(p.PPI_CH2, event, task); 56 let mut spam_ppi = Ppi::new_one_to_one(p.PPI_CH2, event, task);
57 spam_ppi.enable(); 57 spam_ppi.enable();
58 let p = unsafe { TX_BUF.as_mut_ptr() }; 58 let p = unsafe { core::ptr::addr_of_mut!(TX_BUF) } as *mut u8;
59 spam_peri.txd.ptr.write(|w| unsafe { w.ptr().bits(p as u32) }); 59 spam_peri.txd.ptr.write(|w| unsafe { w.ptr().bits(p as u32) });
60 spam_peri.txd.maxcnt.write(|w| unsafe { w.maxcnt().bits(NSPAM as _) }); 60 spam_peri.txd.maxcnt.write(|w| unsafe { w.maxcnt().bits(NSPAM as _) });
61 spam_peri.tasks_starttx.write(|w| unsafe { w.bits(1) }); 61 spam_peri.tasks_starttx.write(|w| unsafe { w.bits(1) });
diff --git a/tests/stm32/src/bin/usart_rx_ringbuffered.rs b/tests/stm32/src/bin/usart_rx_ringbuffered.rs
index 98c7ef312..83c0887ac 100644
--- a/tests/stm32/src/bin/usart_rx_ringbuffered.rs
+++ b/tests/stm32/src/bin/usart_rx_ringbuffered.rs
@@ -43,8 +43,7 @@ async fn main(spawner: Spawner) {
43 let usart = Uart::new(usart, rx, tx, irq, tx_dma, rx_dma, config).unwrap(); 43 let usart = Uart::new(usart, rx, tx, irq, tx_dma, rx_dma, config).unwrap();
44 let (tx, rx) = usart.split(); 44 let (tx, rx) = usart.split();
45 static mut DMA_BUF: [u8; DMA_BUF_SIZE] = [0; DMA_BUF_SIZE]; 45 static mut DMA_BUF: [u8; DMA_BUF_SIZE] = [0; DMA_BUF_SIZE];
46 let dma_buf = unsafe { DMA_BUF.as_mut() }; 46 let rx = rx.into_ring_buffered(unsafe { &mut *core::ptr::addr_of_mut!(DMA_BUF) });
47 let rx = rx.into_ring_buffered(dma_buf);
48 47
49 info!("Spawning tasks"); 48 info!("Spawning tasks");
50 spawner.spawn(transmit_task(tx)).unwrap(); 49 spawner.spawn(transmit_task(tx)).unwrap();