flash_store_refactor #49
6
memory.x
6
memory.x
@ -11,7 +11,7 @@ MEMORY
|
||||
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
|
||||
}
|
||||
|
||||
_stack_start = ORIGIN(CCMRAM) + LENGTH(CCMRAM);
|
||||
_dfu_msg = ORIGIN(DFU_MSG);
|
||||
_config_start = ORIGIN(CONFIG);
|
||||
_flash_start = ORIGIN(FLASH);
|
||||
_config_start = ORIGIN(CONFIG);
|
||||
_dfu_msg = ORIGIN(DFU_MSG);
|
||||
|
||||
_stack_start = ORIGIN(CCMRAM) + LENGTH(CCMRAM);
|
||||
|
@ -20,18 +20,18 @@ pub struct FlashBackend {
|
||||
flash: FLASH,
|
||||
}
|
||||
|
||||
unsafe fn get_offset() -> usize {
|
||||
fn get_offset() -> usize {
|
||||
sb10q
commented
I suggest moving the I suggest moving the ``unsafe`` block into this function and marking it safe.
|
||||
unsafe {
|
||||
(&_config_start as *const usize as usize) - (&_flash_start as *const usize as usize)
|
||||
}
|
||||
}
|
||||
|
||||
impl StoreBackend for FlashBackend {
|
||||
type Data = [u8];
|
||||
|
||||
fn data(&self) -> &Self::Data {
|
||||
unsafe {
|
||||
&self.flash.read()[get_offset()..(get_offset() + FLASH_SECTOR_SIZE)]
|
||||
}
|
||||
}
|
||||
|
||||
type Error = Error;
|
||||
fn erase(&mut self) -> Result<(), Self::Error> {
|
||||
@ -40,11 +40,9 @@ impl StoreBackend for FlashBackend {
|
||||
}
|
||||
|
||||
fn program(&mut self, offset: usize, payload: &[u8]) -> Result<(), Self::Error> {
|
||||
unsafe {
|
||||
self.flash.unlocked()
|
||||
.program(get_offset() + offset, payload.iter().cloned())
|
||||
}
|
||||
}
|
||||
|
||||
fn backup_space(&self) -> &'static mut [u8] {
|
||||
unsafe { &mut BACKUP_SPACE }
|
||||
|
Loading…
Reference in New Issue
Block a user
Keep the same order as the declarations above.