impl NorFlash for Rp2040Flash { const WRITE_SIZE: usize = 1; const ERASE_SIZE: usize = FLASH_SECTOR_SIZE as usize; fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { check_erase(self, from, to)?; cortex_m::interrupt::free(|_| unsafe { core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst); flash_range_erase(START_ADDRESS + from, to - from, true); core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst); }); Ok(()) } fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { check_write(self, offset, bytes.len())?; cortex_m::interrupt::free(|_| unsafe { core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst); flash_range_program(START_ADDRESS + offset, bytes, true); core::sync::atomic::compiler_fence(core::sync::atomic::Ordering::SeqCst); }); Ok(()) } }