Skip to content

Commit

Permalink
Merge pull request #213 from embassy-rs/nrf-flash-multiwrite
Browse files Browse the repository at this point in the history
fix: support multiwrite for nrf flash
  • Loading branch information
lulf authored Dec 22, 2023
2 parents 18aea7d + b972331 commit fa1d591
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nrf-softdevice/src/flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use core::sync::atomic::{AtomicBool, Ordering};
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::signal::Signal;
use embedded_storage::nor_flash::{ErrorType, NorFlashError, NorFlashErrorKind, ReadNorFlash};
use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash};
use embedded_storage_async::nor_flash::{
MultiwriteNorFlash, NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash,
};

use crate::util::DropBomb;
use crate::{raw, RawError, Softdevice};
Expand Down Expand Up @@ -166,3 +168,11 @@ impl AsyncNorFlash for Flash {
Ok(())
}
}

/// According to Nordic, it is possible to perform multiple writes but only changing a bit from 1 -> 0, which
/// is what MultiwriteNorFlash is for.
///
/// "The NVMC is only able to write 0 to bits in flash memory that are erased (set to 1). It cannot rewrite a bit back to 1.
/// Only full 32-bit words can be written to flash memory using the NVMC interface. To write less than 32 bits, write the data
/// as a full 32-bit word and set all the bits that should remain unchanged in the word to 1."
impl MultiwriteNorFlash for Flash {}

0 comments on commit fa1d591

Please sign in to comment.