Update nighlty, fix warnings.

Fixes #2599
This commit is contained in:
Dario Nieuwenhuis 2024-10-14 00:01:49 +02:00
parent 4eb820ab6c
commit ee669ee5c5
11 changed files with 30 additions and 20 deletions

View File

@ -480,7 +480,7 @@ pub fn install_core0_stack_guard() -> Result<(), ()> {
#[cfg(all(feature = "rp2040", not(feature = "_test")))] #[cfg(all(feature = "rp2040", not(feature = "_test")))]
#[inline(always)] #[inline(always)]
fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> { unsafe fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
let core = unsafe { cortex_m::Peripherals::steal() }; let core = unsafe { cortex_m::Peripherals::steal() };
// Fail if MPU is already configured // Fail if MPU is already configured
@ -508,7 +508,7 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
#[cfg(all(feature = "_rp235x", not(feature = "_test")))] #[cfg(all(feature = "_rp235x", not(feature = "_test")))]
#[inline(always)] #[inline(always)]
fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> { unsafe fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
let core = unsafe { cortex_m::Peripherals::steal() }; let core = unsafe { cortex_m::Peripherals::steal() };
// Fail if MPU is already configured // Fail if MPU is already configured
@ -528,7 +528,7 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
// so the compile fails when we try to use ARMv8 peripherals. // so the compile fails when we try to use ARMv8 peripherals.
#[cfg(feature = "_test")] #[cfg(feature = "_test")]
#[inline(always)] #[inline(always)]
fn install_stack_guard(_stack_bottom: *mut usize) -> Result<(), ()> { unsafe fn install_stack_guard(_stack_bottom: *mut usize) -> Result<(), ()> {
Ok(()) Ok(())
} }

View File

@ -58,7 +58,7 @@ const RESUME_TOKEN: u32 = !0xDEADBEEF;
static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false); static IS_CORE1_INIT: AtomicBool = AtomicBool::new(false);
#[inline(always)] #[inline(always)]
fn core1_setup(stack_bottom: *mut usize) { unsafe fn core1_setup(stack_bottom: *mut usize) {
if install_stack_guard(stack_bottom).is_err() { if install_stack_guard(stack_bottom).is_err() {
// currently only happens if the MPU was already set up, which // currently only happens if the MPU was already set up, which
// would indicate that the core is already in use from outside // would indicate that the core is already in use from outside
@ -148,7 +148,7 @@ where
entry: *mut ManuallyDrop<F>, entry: *mut ManuallyDrop<F>,
stack_bottom: *mut usize, stack_bottom: *mut usize,
) -> ! { ) -> ! {
core1_setup(stack_bottom); unsafe { core1_setup(stack_bottom) };
let entry = unsafe { ManuallyDrop::take(&mut *entry) }; let entry = unsafe { ManuallyDrop::take(&mut *entry) };

View File

@ -2,6 +2,7 @@
#![allow(async_fn_in_trait)] #![allow(async_fn_in_trait)]
#![doc = include_str!("../README.md")] #![doc = include_str!("../README.md")]
// #![warn(missing_docs)] // #![warn(missing_docs)]
#![allow(static_mut_refs)] // TODO: Fix
// This must go FIRST so that all the other modules see its macros. // This must go FIRST so that all the other modules see its macros.
mod fmt; mod fmt;

View File

@ -371,7 +371,7 @@ pub struct DataRequest {
} }
impl DataRequest { impl DataRequest {
pub fn set_buffer<'a>(&'a mut self, buf: &'a [u8]) -> &mut Self { pub fn set_buffer<'a>(&'a mut self, buf: &'a [u8]) -> &'a mut Self {
self.msdu_ptr = buf as *const _ as *const u8; self.msdu_ptr = buf as *const _ as *const u8;
self.msdu_length = buf.len() as u8; self.msdu_length = buf.len() as u8;

View File

@ -51,6 +51,9 @@
//! } //! }
//! ``` //! ```
// TODO: Usage of `static mut` here is unsound. Fix then remove this `allow`.`
#![allow(static_mut_refs)]
use core::arch::asm; use core::arch::asm;
use core::marker::PhantomData; use core::marker::PhantomData;
use core::sync::atomic::{compiler_fence, Ordering}; use core::sync::atomic::{compiler_fence, Ordering};

View File

@ -86,7 +86,7 @@ pub(crate) unsafe fn set_freqs(freqs: Clocks) {
#[cfg(not(feature = "_dual-core"))] #[cfg(not(feature = "_dual-core"))]
/// Safety: Reads a mutable global. /// Safety: Reads a mutable global.
pub(crate) unsafe fn get_freqs() -> &'static Clocks { pub(crate) unsafe fn get_freqs() -> &'static Clocks {
CLOCK_FREQS.assume_init_ref() (*core::ptr::addr_of_mut!(CLOCK_FREQS)).assume_init_ref()
} }
#[cfg(feature = "_dual-core")] #[cfg(feature = "_dual-core")]
@ -171,7 +171,9 @@ impl RccInfo {
// Use .get_mut instead of []-operator so that we control how bounds checks happen. // Use .get_mut instead of []-operator so that we control how bounds checks happen.
// Otherwise, core::fmt will be pulled in here in order to format the integer in the // Otherwise, core::fmt will be pulled in here in order to format the integer in the
// out-of-bounds error. // out-of-bounds error.
if let Some(refcount) = unsafe { crate::_generated::REFCOUNTS.get_mut(refcount_idx) } { if let Some(refcount) =
unsafe { (*core::ptr::addr_of_mut!(crate::_generated::REFCOUNTS)).get_mut(refcount_idx) }
{
*refcount += 1; *refcount += 1;
if *refcount > 1 { if *refcount > 1 {
return; return;
@ -235,7 +237,9 @@ impl RccInfo {
// Use .get_mut instead of []-operator so that we control how bounds checks happen. // Use .get_mut instead of []-operator so that we control how bounds checks happen.
// Otherwise, core::fmt will be pulled in here in order to format the integer in the // Otherwise, core::fmt will be pulled in here in order to format the integer in the
// out-of-bounds error. // out-of-bounds error.
if let Some(refcount) = unsafe { crate::_generated::REFCOUNTS.get_mut(refcount_idx) } { if let Some(refcount) =
unsafe { (*core::ptr::addr_of_mut!(crate::_generated::REFCOUNTS)).get_mut(refcount_idx) }
{
*refcount -= 1; *refcount -= 1;
if *refcount > 0 { if *refcount > 0 {
return; return;

View File

@ -81,8 +81,9 @@ async fn main(_spawner: Spawner) {
rx_config.sync_output = false; rx_config.sync_output = false;
let tx_buffer: &mut [u32] = unsafe { let tx_buffer: &mut [u32] = unsafe {
TX_BUFFER.initialize_all_copied(0); let buf = &mut *core::ptr::addr_of_mut!(TX_BUFFER);
let (ptr, len) = TX_BUFFER.get_ptr_len(); buf.initialize_all_copied(0);
let (ptr, len) = buf.get_ptr_len();
core::slice::from_raw_parts_mut(ptr, len) core::slice::from_raw_parts_mut(ptr, len)
}; };
@ -98,8 +99,9 @@ async fn main(_spawner: Spawner) {
); );
let rx_buffer: &mut [u32] = unsafe { let rx_buffer: &mut [u32] = unsafe {
RX_BUFFER.initialize_all_copied(0); let buf = &mut *core::ptr::addr_of_mut!(RX_BUFFER);
let (ptr, len) = RX_BUFFER.get_ptr_len(); buf.initialize_all_copied(0);
let (ptr, len) = buf.get_ptr_len();
core::slice::from_raw_parts_mut(ptr, len) core::slice::from_raw_parts_mut(ptr, len)
}; };

View File

@ -22,10 +22,11 @@ static mut RAM_D3: GroundedArrayCell<u8, 256> = GroundedArrayCell::uninit();
#[embassy_executor::task] #[embassy_executor::task]
async fn main_task(mut spi: spi::Spi<'static, Async>) { async fn main_task(mut spi: spi::Spi<'static, Async>) {
let (read_buffer, write_buffer) = unsafe { let (read_buffer, write_buffer) = unsafe {
RAM_D3.initialize_all_copied(0); let ram = &mut *core::ptr::addr_of_mut!(RAM_D3);
ram.initialize_all_copied(0);
( (
RAM_D3.get_subslice_mut_unchecked(0, 128), ram.get_subslice_mut_unchecked(0, 128),
RAM_D3.get_subslice_mut_unchecked(128, 128), ram.get_subslice_mut_unchecked(128, 128),
) )
}; };

View File

@ -1,5 +1,5 @@
[toolchain] [toolchain]
channel = "nightly-2024-09-06" channel = "nightly-2024-10-13"
components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ] components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ]
targets = [ targets = [
"thumbv7em-none-eabi", "thumbv7em-none-eabi",

View File

@ -55,7 +55,7 @@ async fn main(_spawner: Spawner) {
let task = unsafe { Task::new_unchecked(NonNull::new_unchecked(&spam_peri.tasks_starttx as *const _ as _)) }; let task = unsafe { Task::new_unchecked(NonNull::new_unchecked(&spam_peri.tasks_starttx as *const _ as _)) };
let mut spam_ppi = Ppi::new_one_to_one(p.PPI_CH2, event, task); let mut spam_ppi = Ppi::new_one_to_one(p.PPI_CH2, event, task);
spam_ppi.enable(); spam_ppi.enable();
let p = unsafe { TX_BUF.as_mut_ptr() }; let p = unsafe { core::ptr::addr_of_mut!(TX_BUF) } as *mut u8;
spam_peri.txd.ptr.write(|w| unsafe { w.ptr().bits(p as u32) }); spam_peri.txd.ptr.write(|w| unsafe { w.ptr().bits(p as u32) });
spam_peri.txd.maxcnt.write(|w| unsafe { w.maxcnt().bits(NSPAM as _) }); spam_peri.txd.maxcnt.write(|w| unsafe { w.maxcnt().bits(NSPAM as _) });
spam_peri.tasks_starttx.write(|w| unsafe { w.bits(1) }); spam_peri.tasks_starttx.write(|w| unsafe { w.bits(1) });

View File

@ -43,8 +43,7 @@ async fn main(spawner: Spawner) {
let usart = Uart::new(usart, rx, tx, irq, tx_dma, rx_dma, config).unwrap(); let usart = Uart::new(usart, rx, tx, irq, tx_dma, rx_dma, config).unwrap();
let (tx, rx) = usart.split(); let (tx, rx) = usart.split();
static mut DMA_BUF: [u8; DMA_BUF_SIZE] = [0; DMA_BUF_SIZE]; static mut DMA_BUF: [u8; DMA_BUF_SIZE] = [0; DMA_BUF_SIZE];
let dma_buf = unsafe { DMA_BUF.as_mut() }; let rx = rx.into_ring_buffered(unsafe { &mut *core::ptr::addr_of_mut!(DMA_BUF) });
let rx = rx.into_ring_buffered(dma_buf);
info!("Spawning tasks"); info!("Spawning tasks");
spawner.spawn(transmit_task(tx)).unwrap(); spawner.spawn(transmit_task(tx)).unwrap();