From 3d11b70e5e64df4a583238ce37647e531930668a Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Thu, 27 Jan 2022 17:43:08 +0100 Subject: Migrate do embedded-storage-async --- Cargo.lock | 174 +++++++++++++++++++++++++++----------------- examples/Cargo.toml | 2 + examples/src/bin/flash.rs | 4 +- nrf-softdevice/Cargo.toml | 2 + nrf-softdevice/src/flash.rs | 96 +++++++++++++++--------- 5 files changed, 175 insertions(+), 103 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb46d8d..497512a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,11 +32,11 @@ dependencies = [ [[package]] name = "alloc-cortex-m" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a67ad0fe14be887ed94e5722d14861c1877b128edbda2dd372e64d5243d614ae" +checksum = "5069e21ec61f3b243a4a4c56d920d3206e6ee86022a67c23e9fe36eb60fc1efd" dependencies = [ - "cortex-m 0.6.7", + "cortex-m 0.7.4", "linked_list_allocator", ] @@ -48,7 +48,7 @@ checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" dependencies = [ "generic-array 0.12.4", "generic-array 0.13.3", - "generic-array 0.14.4", + "generic-array 0.14.5", "stable_deref_trait", ] @@ -134,19 +134,19 @@ dependencies = [ "aligned", "bare-metal 0.2.5", "bitfield", - "cortex-m 0.7.3", + "cortex-m 0.7.4", "volatile-register", ] [[package]] name = "cortex-m" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ac919ef424449ec8c08d515590ce15d9262c0ca5f0da5b0c901e971a3b783b3" +checksum = "37ff967e867ca14eba0c34ac25cd71ea98c678e741e3915d923999bb2fe7c826" dependencies = [ "bare-metal 0.2.5", "bitfield", - "embedded-hal", + "embedded-hal 0.2.6", "volatile-register", ] @@ -178,7 +178,7 @@ checksum = "01e191a5a6f6edad9b679777ef6b6c0f2bdd4a333f2ecb8f61c3e28109a03d70" dependencies = [ "bare-metal 1.0.0", "cfg-if", - "cortex-m 0.7.3", + "cortex-m 0.7.4", "riscv", ] @@ -281,29 +281,19 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d1ce010e1a51aef925c98f12ed81a4e0e96ce0185a87c33f1b3b9c8f20749c7" -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "embassy" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#79cbad501c6e6166d0e53ab33b2401a674ee9f31" +source = "git+https://github.com/embassy-rs/embassy#d76cd5ceaf5140c48ef97180beae156c0c0e07c8" dependencies = [ "atomic-polyfill", - "cortex-m 0.7.3", + "cfg-if", + "cortex-m 0.7.4", "critical-section", "defmt", "embassy-macros", "embassy-traits", - "embedded-hal", + "embedded-hal 0.2.6", "futures", "heapless", "pin-project", @@ -312,9 +302,9 @@ dependencies = [ [[package]] name = "embassy-hal-common" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#79cbad501c6e6166d0e53ab33b2401a674ee9f31" +source = "git+https://github.com/embassy-rs/embassy#d76cd5ceaf5140c48ef97180beae156c0c0e07c8" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "embassy", "num-traits", "usb-device", @@ -323,7 +313,7 @@ dependencies = [ [[package]] name = "embassy-macros" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#79cbad501c6e6166d0e53ab33b2401a674ee9f31" +source = "git+https://github.com/embassy-rs/embassy#d76cd5ceaf5140c48ef97180beae156c0c0e07c8" dependencies = [ "darling 0.13.1", "proc-macro2", @@ -334,10 +324,10 @@ dependencies = [ [[package]] name = "embassy-nrf" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#79cbad501c6e6166d0e53ab33b2401a674ee9f31" +source = "git+https://github.com/embassy-rs/embassy#d76cd5ceaf5140c48ef97180beae156c0c0e07c8" dependencies = [ "cfg-if", - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "critical-section", "defmt", @@ -345,21 +335,26 @@ dependencies = [ "embassy-hal-common", "embassy-macros", "embedded-dma", - "embedded-hal", - "embedded-storage", + "embedded-hal 0.2.6", + "embedded-storage 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "fixed", "futures", + "nrf-usbd", "nrf52840-pac", "rand_core", + "usb-device", ] [[package]] name = "embassy-traits" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy#79cbad501c6e6166d0e53ab33b2401a674ee9f31" +source = "git+https://github.com/embassy-rs/embassy#d76cd5ceaf5140c48ef97180beae156c0c0e07c8" dependencies = [ "defmt", - "embedded-hal", + "embedded-hal 0.2.6", + "embedded-hal 1.0.0-alpha.6", + "embedded-hal-async", + "nb 1.0.0", ] [[package]] @@ -381,12 +376,41 @@ dependencies = [ "void", ] +[[package]] +name = "embedded-hal" +version = "1.0.0-alpha.6" +source = "git+https://github.com/embassy-rs/embedded-hal?branch=embassy#1fa64a1d2f9cc1a1ae632dbfcc4064a9f6504a3f" +dependencies = [ + "nb 1.0.0", +] + +[[package]] +name = "embedded-hal-async" +version = "0.0.1" +source = "git+https://github.com/embassy-rs/embedded-hal?branch=embassy#1fa64a1d2f9cc1a1ae632dbfcc4064a9f6504a3f" +dependencies = [ + "embedded-hal 1.0.0-alpha.6", +] + [[package]] name = "embedded-storage" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "723dce4e9f25b6e6c5f35628e144794e5b459216ed7da97b7c4b66cdb3fa82ca" +[[package]] +name = "embedded-storage" +version = "0.2.0" +source = "git+https://github.com/embassy-rs/embedded-storage.git?branch=embassy#24309dcc22dffb1dda10fccf37b4cde92c94bd69" + +[[package]] +name = "embedded-storage-async" +version = "0.2.0" +source = "git+https://github.com/embassy-rs/embedded-storage.git?branch=embassy#24309dcc22dffb1dda10fccf37b4cde92c94bd69" +dependencies = [ + "embedded-storage 0.2.0 (git+https://github.com/embassy-rs/embedded-storage.git?branch=embassy)", +] + [[package]] name = "fixed" version = "1.11.0" @@ -486,9 +510,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" dependencies = [ "typenum", "version_check", @@ -511,9 +535,9 @@ dependencies = [ [[package]] name = "heapless" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e476c64197665c3725621f0ac3f9e5209aa5e889e02a08b1daf5f16dc5fd952" +checksum = "d076121838e03f862871315477528debffdb7462fb229216ecef91b1a3eb31eb" dependencies = [ "atomic-polyfill", "hash32", @@ -582,11 +606,13 @@ checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" name = "nrf-softdevice" version = "0.1.0" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "critical-section", "defmt", "embassy", + "embedded-storage 0.2.0 (git+https://github.com/embassy-rs/embedded-storage.git?branch=embassy)", + "embedded-storage-async", "fixed", "futures", "heapless", @@ -622,12 +648,14 @@ name = "nrf-softdevice-examples" version = "0.1.0" dependencies = [ "alloc-cortex-m", - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "defmt", "embassy", "embassy-nrf", "embassy-traits", + "embedded-storage 0.2.0 (git+https://github.com/embassy-rs/embedded-storage.git?branch=embassy)", + "embedded-storage-async", "fixed", "futures", "heapless", @@ -673,13 +701,26 @@ version = "0.1.1" name = "nrf-softdevice-s140" version = "0.1.1" +[[package]] +name = "nrf-usbd" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "640e88d4c108743c667f03320d0c9ab24a20f183a7a1b18bde7891ee13fd92c5" +dependencies = [ + "bare-metal 1.0.0", + "cortex-m 0.7.4", + "critical-section", + "usb-device", + "vcell", +] + [[package]] name = "nrf52805-pac" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4d2636b974cd6bc0b7f321e86fb51014fa9ab3e46156cb870db2335b5909713" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "vcell", ] @@ -690,7 +731,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c6dd53b0fb1b7a5bde99de9d9f61f6714e7708e9eedaad9d7ed0534c452d1b" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "vcell", ] @@ -701,7 +742,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "088b039a15924edec8a97c185e3f45b2da203c0a90696f342f1a9cba736085bf" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "vcell", ] @@ -712,7 +753,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "438e40c226811dc90f0ce34b7466ae6f4a012018f31bd4afe9c3d37cd8407951" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "vcell", ] @@ -723,7 +764,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76f5dec47cf294f40a53cc62b6d9032a5ffae998c045c517cce5acaf482350d7" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "vcell", ] @@ -734,7 +775,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd69bdb25903e18e098c040ef31dc863814437af010dea8bd55aa31f686cb461" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "vcell", ] @@ -745,7 +786,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "209c71d29ce1c0e9249b59ffff1ff5035c68b65070bf4c1315767fa4c93103ac" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "cortex-m-rt", "vcell", ] @@ -761,19 +802,18 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "085fe377a4b2805c0fbc09484415ec261174614b7f080b0e0d520456ac421a67" +checksum = "720d3ea1055e4e4574c0c0b0f8c3fd4f24c4cdaf465948206dea090b57b526ad" dependencies = [ - "derivative", "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5249369707a1e07b39f78d98c8f34e00aca7dcb053812fdbb5ad7be82c1bba38" +checksum = "0d992b768490d7fe0d8586d9b5745f6c49f557da6d81dc982b1d167ad4edbb21" dependencies = [ "proc-macro2", "quote", @@ -786,24 +826,24 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ab1f00eac22bd18f8e5cae9555f2820b3a0c166b5b556ee3e203746ea6dcf3a" dependencies = [ - "cortex-m 0.7.3", + "cortex-m 0.7.4", "defmt", ] [[package]] name = "pin-project" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576bc800220cc65dac09e99e97b08b358cfab6e17078de8dc5fee223bd2d0c08" +checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e8fe8163d14ce7f0cdac2e040116f22eac817edabff0be91e8aff7e9accf389" +checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" dependencies = [ "proc-macro2", "quote", @@ -812,9 +852,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" [[package]] name = "pin-utils" @@ -848,18 +888,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.34" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.10" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" dependencies = [ "proc-macro2", ] @@ -967,9 +1007,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote", @@ -978,9 +1018,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "unicode-xid" @@ -1008,9 +1048,9 @@ checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "void" diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 995b6f4..4d56e3c 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -26,6 +26,8 @@ nrf-softdevice-defmt-rtt = { path = "../nrf-softdevice-defmt-rtt", version = "0. panic-probe = { version = "0.3", features= ["print-defmt"] } nrf-softdevice = { version = "0.1.0", path = "../nrf-softdevice", features = ["defmt", "nrf52840", "s140", "ble-peripheral", "ble-central", "critical-section-impl"] } nrf-softdevice-s140 = { version = "0.1.1", path = "../nrf-softdevice-s140" } +embedded-storage = { git = "https://github.com/embassy-rs/embedded-storage.git", branch = "embassy" } +embedded-storage-async = { git = "https://github.com/embassy-rs/embedded-storage.git", branch = "embassy" } futures = { version = "0.3.5", default-features = false } fixed = "1.2.0" heapless = "0.7.1" diff --git a/examples/src/bin/flash.rs b/examples/src/bin/flash.rs index a5b2fac..2017e86 100644 --- a/examples/src/bin/flash.rs +++ b/examples/src/bin/flash.rs @@ -10,8 +10,8 @@ mod example_common; use cortex_m_rt::entry; use defmt::*; use embassy::executor::Executor; -use embassy::traits::flash::Flash as _; use embassy::util::Forever; +use embedded_storage_async::nor_flash::*; use futures::pin_mut; use nrf_softdevice::{Flash, Softdevice}; @@ -29,7 +29,7 @@ async fn flash_task(sd: &'static Softdevice) { pin_mut!(f); info!("starting erase"); - unwrap!(f.as_mut().erase(0x80000).await); + unwrap!(f.as_mut().erase(0x80000, 0x81000).await); info!("erased!"); info!("starting write"); diff --git a/nrf-softdevice/Cargo.toml b/nrf-softdevice/Cargo.toml index 2f17e6b..4d5cc94 100644 --- a/nrf-softdevice/Cargo.toml +++ b/nrf-softdevice/Cargo.toml @@ -41,6 +41,8 @@ cortex-m-rt = ">=0.6.15,<0.8" heapless = "0.7.1" fixed = "1.5.0" futures = { version = "0.3.17", default-features = false } +embedded-storage = { git = "https://github.com/embassy-rs/embedded-storage.git", branch = "embassy" } +embedded-storage-async = { git = "https://github.com/embassy-rs/embedded-storage.git", branch = "embassy" } nrf52805-pac = { version = "0.10.0", features = ["rt"], optional = true } nrf52810-pac = { version = "0.10.0", features = ["rt"], optional = true } diff --git a/nrf-softdevice/src/flash.rs b/nrf-softdevice/src/flash.rs index 8a4296b..ae9b935 100644 --- a/nrf-softdevice/src/flash.rs +++ b/nrf-softdevice/src/flash.rs @@ -1,12 +1,32 @@ use core::future::Future; use core::marker::PhantomData; use core::sync::atomic::{AtomicBool, Ordering}; -use embassy::traits::flash::Error as FlashError; +use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind}; +use embedded_storage_async::nor_flash::{AsyncNorFlash, AsyncReadNorFlash}; use crate::raw; use crate::util::{DropBomb, Signal}; use crate::{RawError, Softdevice}; +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +#[non_exhaustive] +pub enum FlashError { + Failed, + AddressMisaligned, + BufferMisaligned, +} + +impl NorFlashError for FlashError { + fn kind(&self) -> NorFlashErrorKind { + match self { + Self::Failed => NorFlashErrorKind::Other, + Self::AddressMisaligned => NorFlashErrorKind::NotAligned, + Self::BufferMisaligned => NorFlashErrorKind::NotAligned, + } + } +} + /// Singleton instance of the Flash softdevice functionality. pub struct Flash { // Prevent Send, Sync @@ -47,11 +67,11 @@ pub(crate) fn on_flash_error() { SIGNAL.signal(Err(FlashError::Failed)) } -impl embassy::traits::flash::Flash for Flash { - type ReadFuture<'a> = impl Future> + 'a; - type WriteFuture<'a> = impl Future> + 'a; - type ErasePageFuture<'a> = impl Future> + 'a; +impl AsyncReadNorFlash for Flash { + const READ_SIZE: usize = 1; + type Error = FlashError; + type ReadFuture<'a> = impl Future> + 'a; fn read<'a>(&'a mut self, address: usize, data: &'a mut [u8]) -> Self::ReadFuture<'a> { async move { // Reading is simple since SoC flash is memory-mapped :) @@ -65,11 +85,22 @@ impl embassy::traits::flash::Flash for Flash { } } - fn write<'a>(&'a mut self, address: usize, data: &'a [u8]) -> Self::WriteFuture<'a> { + fn capacity(&self) -> usize { + 256 * 4096 + } +} + +impl AsyncNorFlash for Flash { + const WRITE_SIZE: usize = 4; + const ERASE_SIZE: usize = 4096; + + type WriteFuture<'a> = impl Future> + 'a; + fn write<'a>(&'a mut self, offset: u32, data: &'a [u8]) -> Self::WriteFuture<'a> { async move { let data_ptr = data.as_ptr(); let data_len = data.len() as u32; + let address = offset as usize; if address % 4 != 0 { return Err(FlashError::AddressMisaligned); } @@ -96,42 +127,39 @@ impl embassy::traits::flash::Flash for Flash { } } - fn erase<'a>(&'a mut self, address: usize) -> Self::ErasePageFuture<'a> { + type EraseFuture<'a> = impl Future> + 'a; + fn erase<'a>(&'a mut self, from: u32, to: u32) -> Self::EraseFuture<'a> { async move { - if address % Self::PAGE_SIZE != 0 { + if from as usize % Self::PAGE_SIZE != 0 { + return Err(FlashError::AddressMisaligned); + } + if to as usize % Self::PAGE_SIZE != 0 { return Err(FlashError::AddressMisaligned); } - - let page_number = address / Self::PAGE_SIZE; let bomb = DropBomb::new(); - let ret = unsafe { raw::sd_flash_page_erase(page_number as u32) }; - let ret = match RawError::convert(ret) { - Ok(()) => SIGNAL.wait().await, - Err(_e) => { - warn!("sd_flash_page_erase err {:?}", _e); - Err(FlashError::Failed) + for address in (from as usize..to as usize).step_by(Self::PAGE_SIZE) { + let page_number = (address / Self::PAGE_SIZE) as u32; + let ret = unsafe { raw::sd_flash_page_erase(page_number) }; + match RawError::convert(ret) { + Ok(()) => match SIGNAL.wait().await { + Err(_e) => { + warn!("sd_flash_page_erase err {:?}", _e); + bomb.defuse(); + return Err(_e); + } + _ => {} + }, + Err(_e) => { + warn!("sd_flash_page_erase err {:?}", _e); + bomb.defuse(); + return Err(FlashError::Failed); + } } - }; + } bomb.defuse(); - ret + Ok(()) } } - - fn size(&self) -> usize { - 256 * 4096 - } - - fn read_size(&self) -> usize { - 1 - } - - fn write_size(&self) -> usize { - 4 - } - - fn erase_size(&self) -> usize { - 4096 - } } -- cgit v1.2.3