aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-boot/rp/src/lib.rs8
-rw-r--r--embassy-rp/src/flash.rs100
-rw-r--r--examples/boot/application/rp/src/bin/a.rs4
-rw-r--r--examples/rp/src/bin/flash.rs34
-rw-r--r--tests/rp/src/bin/flash.rs14
5 files changed, 82 insertions, 78 deletions
diff --git a/embassy-boot/rp/src/lib.rs b/embassy-boot/rp/src/lib.rs
index 96bcf3bf7..989e7521b 100644
--- a/embassy-boot/rp/src/lib.rs
+++ b/embassy-boot/rp/src/lib.rs
@@ -54,7 +54,7 @@ pub struct WatchdogFlash<'d, const SIZE: usize> {
54impl<'d, const SIZE: usize> WatchdogFlash<'d, SIZE> { 54impl<'d, const SIZE: usize> WatchdogFlash<'d, SIZE> {
55 /// Start a new watchdog with a given flash and watchdog peripheral and a timeout 55 /// Start a new watchdog with a given flash and watchdog peripheral and a timeout
56 pub fn start(flash: FLASH, watchdog: WATCHDOG, timeout: Duration) -> Self { 56 pub fn start(flash: FLASH, watchdog: WATCHDOG, timeout: Duration) -> Self {
57 let flash = Flash::<_, Blocking, SIZE>::new(flash); 57 let flash = Flash::<_, Blocking, SIZE>::new_blocking(flash);
58 let mut watchdog = Watchdog::new(watchdog); 58 let mut watchdog = Watchdog::new(watchdog);
59 watchdog.start(timeout); 59 watchdog.start(timeout);
60 Self { flash, watchdog } 60 Self { flash, watchdog }
@@ -71,11 +71,11 @@ impl<'d, const SIZE: usize> NorFlash for WatchdogFlash<'d, SIZE> {
71 71
72 fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { 72 fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
73 self.watchdog.feed(); 73 self.watchdog.feed();
74 self.flash.erase(from, to) 74 self.flash.blocking_erase(from, to)
75 } 75 }
76 fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> { 76 fn write(&mut self, offset: u32, data: &[u8]) -> Result<(), Self::Error> {
77 self.watchdog.feed(); 77 self.watchdog.feed();
78 self.flash.write(offset, data) 78 self.flash.blocking_write(offset, data)
79 } 79 }
80} 80}
81 81
@@ -83,7 +83,7 @@ impl<'d, const SIZE: usize> ReadNorFlash for WatchdogFlash<'d, SIZE> {
83 const READ_SIZE: usize = <Flash<'d, FLASH, Blocking, SIZE> as ReadNorFlash>::READ_SIZE; 83 const READ_SIZE: usize = <Flash<'d, FLASH, Blocking, SIZE> as ReadNorFlash>::READ_SIZE;
84 fn read(&mut self, offset: u32, data: &mut [u8]) -> Result<(), Self::Error> { 84 fn read(&mut self, offset: u32, data: &mut [u8]) -> Result<(), Self::Error> {
85 self.watchdog.feed(); 85 self.watchdog.feed();
86 self.flash.read(offset, data) 86 self.flash.blocking_read(offset, data)
87 } 87 }
88 fn capacity(&self) -> usize { 88 fn capacity(&self) -> usize {
89 self.flash.capacity() 89 self.flash.capacity()
diff --git a/embassy-rp/src/flash.rs b/embassy-rp/src/flash.rs
index 70d867319..1c1c2449e 100644
--- a/embassy-rp/src/flash.rs
+++ b/embassy-rp/src/flash.rs
@@ -102,7 +102,7 @@ pub struct Flash<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> {
102} 102}
103 103
104impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> Flash<'d, T, M, FLASH_SIZE> { 104impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> Flash<'d, T, M, FLASH_SIZE> {
105 pub fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { 105 pub fn blocking_read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
106 trace!( 106 trace!(
107 "Reading from 0x{:x} to 0x{:x}", 107 "Reading from 0x{:x} to 0x{:x}",
108 FLASH_BASE as u32 + offset, 108 FLASH_BASE as u32 + offset,
@@ -120,7 +120,7 @@ impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> Flash<'d, T, M, FLASH_SI
120 FLASH_SIZE 120 FLASH_SIZE
121 } 121 }
122 122
123 pub fn erase(&mut self, from: u32, to: u32) -> Result<(), Error> { 123 pub fn blocking_erase(&mut self, from: u32, to: u32) -> Result<(), Error> {
124 check_erase(self, from, to)?; 124 check_erase(self, from, to)?;
125 125
126 trace!( 126 trace!(
@@ -136,7 +136,7 @@ impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> Flash<'d, T, M, FLASH_SI
136 Ok(()) 136 Ok(())
137 } 137 }
138 138
139 pub fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { 139 pub fn blocking_write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> {
140 check_write(self, offset, bytes.len())?; 140 check_write(self, offset, bytes.len())?;
141 141
142 trace!("Writing {:?} bytes to 0x{:x}", bytes.len(), FLASH_BASE as u32 + offset); 142 trace!("Writing {:?} bytes to 0x{:x}", bytes.len(), FLASH_BASE as u32 + offset);
@@ -233,13 +233,13 @@ impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> Flash<'d, T, M, FLASH_SI
233 } 233 }
234 234
235 /// Read SPI flash unique ID 235 /// Read SPI flash unique ID
236 pub fn unique_id(&mut self, uid: &mut [u8]) -> Result<(), Error> { 236 pub fn blocking_unique_id(&mut self, uid: &mut [u8]) -> Result<(), Error> {
237 unsafe { self.in_ram(|| ram_helpers::flash_unique_id(uid))? }; 237 unsafe { self.in_ram(|| ram_helpers::flash_unique_id(uid))? };
238 Ok(()) 238 Ok(())
239 } 239 }
240 240
241 /// Read SPI flash JEDEC ID 241 /// Read SPI flash JEDEC ID
242 pub fn jedec_id(&mut self) -> Result<u32, Error> { 242 pub fn blocking_jedec_id(&mut self) -> Result<u32, Error> {
243 let mut jedec = None; 243 let mut jedec = None;
244 unsafe { 244 unsafe {
245 self.in_ram(|| { 245 self.in_ram(|| {
@@ -251,7 +251,7 @@ impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> Flash<'d, T, M, FLASH_SI
251} 251}
252 252
253impl<'d, T: Instance, const FLASH_SIZE: usize> Flash<'d, T, Blocking, FLASH_SIZE> { 253impl<'d, T: Instance, const FLASH_SIZE: usize> Flash<'d, T, Blocking, FLASH_SIZE> {
254 pub fn new(_flash: impl Peripheral<P = T> + 'd) -> Self { 254 pub fn new_blocking(_flash: impl Peripheral<P = T> + 'd) -> Self {
255 Self { 255 Self {
256 dma: None, 256 dma: None,
257 phantom: PhantomData, 257 phantom: PhantomData,
@@ -310,47 +310,8 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> Flash<'d, T, Async, FLASH_SIZE> {
310 transfer, 310 transfer,
311 }) 311 })
312 } 312 }
313}
314
315impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> ErrorType for Flash<'d, T, M, FLASH_SIZE> {
316 type Error = Error;
317}
318
319impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> ReadNorFlash for Flash<'d, T, M, FLASH_SIZE> {
320 const READ_SIZE: usize = READ_SIZE;
321
322 fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
323 self.read(offset, bytes)
324 }
325
326 fn capacity(&self) -> usize {
327 self.capacity()
328 }
329}
330
331impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> MultiwriteNorFlash for Flash<'d, T, M, FLASH_SIZE> {}
332
333impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> NorFlash for Flash<'d, T, M, FLASH_SIZE> {
334 const WRITE_SIZE: usize = WRITE_SIZE;
335
336 const ERASE_SIZE: usize = ERASE_SIZE;
337
338 fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
339 self.erase(from, to)
340 }
341 313
342 fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { 314 pub async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> {
343 self.write(offset, bytes)
344 }
345}
346
347#[cfg(feature = "nightly")]
348impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash::ReadNorFlash
349 for Flash<'d, T, Async, FLASH_SIZE>
350{
351 const READ_SIZE: usize = ASYNC_READ_SIZE;
352
353 async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
354 use core::mem::MaybeUninit; 315 use core::mem::MaybeUninit;
355 316
356 // Checked early to simplify address validity checks 317 // Checked early to simplify address validity checks
@@ -389,6 +350,49 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash
389 350
390 Ok(()) 351 Ok(())
391 } 352 }
353}
354
355impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> ErrorType for Flash<'d, T, M, FLASH_SIZE> {
356 type Error = Error;
357}
358
359impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> ReadNorFlash for Flash<'d, T, M, FLASH_SIZE> {
360 const READ_SIZE: usize = READ_SIZE;
361
362 fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
363 self.blocking_read(offset, bytes)
364 }
365
366 fn capacity(&self) -> usize {
367 self.capacity()
368 }
369}
370
371impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> MultiwriteNorFlash for Flash<'d, T, M, FLASH_SIZE> {}
372
373impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> NorFlash for Flash<'d, T, M, FLASH_SIZE> {
374 const WRITE_SIZE: usize = WRITE_SIZE;
375
376 const ERASE_SIZE: usize = ERASE_SIZE;
377
378 fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
379 self.blocking_erase(from, to)
380 }
381
382 fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
383 self.blocking_write(offset, bytes)
384 }
385}
386
387#[cfg(feature = "nightly")]
388impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash::ReadNorFlash
389 for Flash<'d, T, Async, FLASH_SIZE>
390{
391 const READ_SIZE: usize = ASYNC_READ_SIZE;
392
393 async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> {
394 self.read(offset, bytes).await
395 }
392 396
393 fn capacity(&self) -> usize { 397 fn capacity(&self) -> usize {
394 self.capacity() 398 self.capacity()
@@ -404,11 +408,11 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash
404 const ERASE_SIZE: usize = ERASE_SIZE; 408 const ERASE_SIZE: usize = ERASE_SIZE;
405 409
406 async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> { 410 async fn erase(&mut self, from: u32, to: u32) -> Result<(), Self::Error> {
407 self.erase(from, to) 411 self.blocking_erase(from, to)
408 } 412 }
409 413
410 async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> { 414 async fn write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Self::Error> {
411 self.write(offset, bytes) 415 self.blocking_write(offset, bytes)
412 } 416 }
413} 417}
414 418
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs
index f0dda39d0..15fdaca82 100644
--- a/examples/boot/application/rp/src/bin/a.rs
+++ b/examples/boot/application/rp/src/bin/a.rs
@@ -7,7 +7,7 @@ use core::cell::RefCell;
7use defmt_rtt as _; 7use defmt_rtt as _;
8use embassy_boot_rp::*; 8use embassy_boot_rp::*;
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_rp::flash::{self, Flash}; 10use embassy_rp::flash::Flash;
11use embassy_rp::gpio::{Level, Output}; 11use embassy_rp::gpio::{Level, Output};
12use embassy_rp::watchdog::Watchdog; 12use embassy_rp::watchdog::Watchdog;
13use embassy_sync::blocking_mutex::Mutex; 13use embassy_sync::blocking_mutex::Mutex;
@@ -34,7 +34,7 @@ async fn main(_s: Spawner) {
34 let mut watchdog = Watchdog::new(p.WATCHDOG); 34 let mut watchdog = Watchdog::new(p.WATCHDOG);
35 watchdog.start(Duration::from_secs(8)); 35 watchdog.start(Duration::from_secs(8));
36 36
37 let flash = Flash::<_, flash::Blocking, FLASH_SIZE>::new(p.FLASH); 37 let flash = Flash::<_, _, FLASH_SIZE>::new_blocking(p.FLASH);
38 let flash = Mutex::new(RefCell::new(flash)); 38 let flash = Mutex::new(RefCell::new(flash));
39 39
40 let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); 40 let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash);
diff --git a/examples/rp/src/bin/flash.rs b/examples/rp/src/bin/flash.rs
index 88bb931d2..911a657eb 100644
--- a/examples/rp/src/bin/flash.rs
+++ b/examples/rp/src/bin/flash.rs
@@ -28,12 +28,12 @@ async fn main(_spawner: Spawner) {
28 let mut flash = embassy_rp::flash::Flash::<_, Async, FLASH_SIZE>::new(p.FLASH, p.DMA_CH0); 28 let mut flash = embassy_rp::flash::Flash::<_, Async, FLASH_SIZE>::new(p.FLASH, p.DMA_CH0);
29 29
30 // Get JEDEC id 30 // Get JEDEC id
31 let jedec = flash.jedec_id().unwrap(); 31 let jedec = flash.blocking_jedec_id().unwrap();
32 info!("jedec id: 0x{:x}", jedec); 32 info!("jedec id: 0x{:x}", jedec);
33 33
34 // Get unique id 34 // Get unique id
35 let mut uid = [0; 8]; 35 let mut uid = [0; 8];
36 flash.unique_id(&mut uid).unwrap(); 36 flash.blocking_unique_id(&mut uid).unwrap();
37 info!("unique id: {:?}", uid); 37 info!("unique id: {:?}", uid);
38 38
39 erase_write_sector(&mut flash, 0x00); 39 erase_write_sector(&mut flash, 0x00);
@@ -48,25 +48,25 @@ async fn main(_spawner: Spawner) {
48fn multiwrite_bytes(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) { 48fn multiwrite_bytes(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) {
49 info!(">>>> [multiwrite_bytes]"); 49 info!(">>>> [multiwrite_bytes]");
50 let mut read_buf = [0u8; ERASE_SIZE]; 50 let mut read_buf = [0u8; ERASE_SIZE];
51 defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut read_buf)); 51 defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut read_buf));
52 52
53 info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32); 53 info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32);
54 info!("Contents start with {=[u8]}", read_buf[0..4]); 54 info!("Contents start with {=[u8]}", read_buf[0..4]);
55 55
56 defmt::unwrap!(flash.erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32)); 56 defmt::unwrap!(flash.blocking_erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32));
57 57
58 defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut read_buf)); 58 defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut read_buf));
59 info!("Contents after erase starts with {=[u8]}", read_buf[0..4]); 59 info!("Contents after erase starts with {=[u8]}", read_buf[0..4]);
60 if read_buf.iter().any(|x| *x != 0xFF) { 60 if read_buf.iter().any(|x| *x != 0xFF) {
61 defmt::panic!("unexpected"); 61 defmt::panic!("unexpected");
62 } 62 }
63 63
64 defmt::unwrap!(flash.write(ADDR_OFFSET + offset, &[0x01])); 64 defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset, &[0x01]));
65 defmt::unwrap!(flash.write(ADDR_OFFSET + offset + 1, &[0x02])); 65 defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset + 1, &[0x02]));
66 defmt::unwrap!(flash.write(ADDR_OFFSET + offset + 2, &[0x03])); 66 defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset + 2, &[0x03]));
67 defmt::unwrap!(flash.write(ADDR_OFFSET + offset + 3, &[0x04])); 67 defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset + 3, &[0x04]));
68 68
69 defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut read_buf)); 69 defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut read_buf));
70 info!("Contents after write starts with {=[u8]}", read_buf[0..4]); 70 info!("Contents after write starts with {=[u8]}", read_buf[0..4]);
71 if &read_buf[0..4] != &[0x01, 0x02, 0x03, 0x04] { 71 if &read_buf[0..4] != &[0x01, 0x02, 0x03, 0x04] {
72 defmt::panic!("unexpected"); 72 defmt::panic!("unexpected");
@@ -76,14 +76,14 @@ fn multiwrite_bytes(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH
76fn erase_write_sector(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) { 76fn erase_write_sector(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLASH_SIZE>, offset: u32) {
77 info!(">>>> [erase_write_sector]"); 77 info!(">>>> [erase_write_sector]");
78 let mut buf = [0u8; ERASE_SIZE]; 78 let mut buf = [0u8; ERASE_SIZE];
79 defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut buf)); 79 defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut buf));
80 80
81 info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32); 81 info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32);
82 info!("Contents start with {=[u8]}", buf[0..4]); 82 info!("Contents start with {=[u8]}", buf[0..4]);
83 83
84 defmt::unwrap!(flash.erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32)); 84 defmt::unwrap!(flash.blocking_erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32));
85 85
86 defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut buf)); 86 defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut buf));
87 info!("Contents after erase starts with {=[u8]}", buf[0..4]); 87 info!("Contents after erase starts with {=[u8]}", buf[0..4]);
88 if buf.iter().any(|x| *x != 0xFF) { 88 if buf.iter().any(|x| *x != 0xFF) {
89 defmt::panic!("unexpected"); 89 defmt::panic!("unexpected");
@@ -93,9 +93,9 @@ fn erase_write_sector(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async, FLA
93 *b = 0xDA; 93 *b = 0xDA;
94 } 94 }
95 95
96 defmt::unwrap!(flash.write(ADDR_OFFSET + offset, &buf)); 96 defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset, &buf));
97 97
98 defmt::unwrap!(flash.read(ADDR_OFFSET + offset, &mut buf)); 98 defmt::unwrap!(flash.blocking_read(ADDR_OFFSET + offset, &mut buf));
99 info!("Contents after write starts with {=[u8]}", buf[0..4]); 99 info!("Contents after write starts with {=[u8]}", buf[0..4]);
100 if buf.iter().any(|x| *x != 0xDA) { 100 if buf.iter().any(|x| *x != 0xDA) {
101 defmt::panic!("unexpected"); 101 defmt::panic!("unexpected");
@@ -111,7 +111,7 @@ async fn background_read(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async,
111 info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32); 111 info!("Addr of flash block is {:x}", ADDR_OFFSET + offset + FLASH_BASE as u32);
112 info!("Contents start with {=u32:x}", buf[0]); 112 info!("Contents start with {=u32:x}", buf[0]);
113 113
114 defmt::unwrap!(flash.erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32)); 114 defmt::unwrap!(flash.blocking_erase(ADDR_OFFSET + offset, ADDR_OFFSET + offset + ERASE_SIZE as u32));
115 115
116 defmt::unwrap!(flash.background_read(ADDR_OFFSET + offset, &mut buf)).await; 116 defmt::unwrap!(flash.background_read(ADDR_OFFSET + offset, &mut buf)).await;
117 info!("Contents after erase starts with {=u32:x}", buf[0]); 117 info!("Contents after erase starts with {=u32:x}", buf[0]);
@@ -123,7 +123,7 @@ async fn background_read(flash: &mut embassy_rp::flash::Flash<'_, FLASH, Async,
123 *b = 0xDABA1234; 123 *b = 0xDABA1234;
124 } 124 }
125 125
126 defmt::unwrap!(flash.write(ADDR_OFFSET + offset, unsafe { 126 defmt::unwrap!(flash.blocking_write(ADDR_OFFSET + offset, unsafe {
127 core::slice::from_raw_parts(buf.as_ptr() as *const u8, buf.len() * 4) 127 core::slice::from_raw_parts(buf.as_ptr() as *const u8, buf.len() * 4)
128 })); 128 }));
129 129
diff --git a/tests/rp/src/bin/flash.rs b/tests/rp/src/bin/flash.rs
index 6e65fbdc0..75be2bf06 100644
--- a/tests/rp/src/bin/flash.rs
+++ b/tests/rp/src/bin/flash.rs
@@ -25,23 +25,23 @@ async fn main(_spawner: Spawner) {
25 let mut flash = embassy_rp::flash::Flash::<_, Async, { 2 * 1024 * 1024 }>::new(p.FLASH, p.DMA_CH0); 25 let mut flash = embassy_rp::flash::Flash::<_, Async, { 2 * 1024 * 1024 }>::new(p.FLASH, p.DMA_CH0);
26 26
27 // Get JEDEC id 27 // Get JEDEC id
28 let jedec = defmt::unwrap!(flash.jedec_id()); 28 let jedec = defmt::unwrap!(flash.blocking_jedec_id());
29 info!("jedec id: 0x{:x}", jedec); 29 info!("jedec id: 0x{:x}", jedec);
30 30
31 // Get unique id 31 // Get unique id
32 let mut uid = [0; 8]; 32 let mut uid = [0; 8];
33 defmt::unwrap!(flash.unique_id(&mut uid)); 33 defmt::unwrap!(flash.blocking_unique_id(&mut uid));
34 info!("unique id: {:?}", uid); 34 info!("unique id: {:?}", uid);
35 35
36 let mut buf = [0u8; ERASE_SIZE]; 36 let mut buf = [0u8; ERASE_SIZE];
37 defmt::unwrap!(flash.read(ADDR_OFFSET, &mut buf)); 37 defmt::unwrap!(flash.blocking_read(ADDR_OFFSET, &mut buf));
38 38
39 info!("Addr of flash block is {:x}", ADDR_OFFSET + FLASH_BASE as u32); 39 info!("Addr of flash block is {:x}", ADDR_OFFSET + FLASH_BASE as u32);
40 info!("Contents start with {=[u8]}", buf[0..4]); 40 info!("Contents start with {=[u8]}", buf[0..4]);
41 41
42 defmt::unwrap!(flash.erase(ADDR_OFFSET, ADDR_OFFSET + ERASE_SIZE as u32)); 42 defmt::unwrap!(flash.blocking_erase(ADDR_OFFSET, ADDR_OFFSET + ERASE_SIZE as u32));
43 43
44 defmt::unwrap!(flash.read(ADDR_OFFSET, &mut buf)); 44 defmt::unwrap!(flash.blocking_read(ADDR_OFFSET, &mut buf));
45 info!("Contents after erase starts with {=[u8]}", buf[0..4]); 45 info!("Contents after erase starts with {=[u8]}", buf[0..4]);
46 if buf.iter().any(|x| *x != 0xFF) { 46 if buf.iter().any(|x| *x != 0xFF) {
47 defmt::panic!("unexpected"); 47 defmt::panic!("unexpected");
@@ -51,9 +51,9 @@ async fn main(_spawner: Spawner) {
51 *b = 0xDA; 51 *b = 0xDA;
52 } 52 }
53 53
54 defmt::unwrap!(flash.write(ADDR_OFFSET, &mut buf)); 54 defmt::unwrap!(flash.blocking_write(ADDR_OFFSET, &mut buf));
55 55
56 defmt::unwrap!(flash.read(ADDR_OFFSET, &mut buf)); 56 defmt::unwrap!(flash.blocking_read(ADDR_OFFSET, &mut buf));
57 info!("Contents after write starts with {=[u8]}", buf[0..4]); 57 info!("Contents after write starts with {=[u8]}", buf[0..4]);
58 if buf.iter().any(|x| *x != 0xDA) { 58 if buf.iter().any(|x| *x != 0xDA) {
59 defmt::panic!("unexpected"); 59 defmt::panic!("unexpected");