aboutsummaryrefslogtreecommitdiff
path: root/embassy-boot/boot/src/mem_flash.rs
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2023-04-05 08:28:31 +0200
committerRasmus Melchior Jacobsen <[email protected]>2023-04-05 08:28:31 +0200
commit2deb2c624c78f4ff582441d7d00a654ac3844e33 (patch)
tree159614af96d809bab75537400d91d2dda4224432 /embassy-boot/boot/src/mem_flash.rs
parent064ec9581e33fdd42f89ff75984254ccfec3f6c2 (diff)
Let Partition range be u32 instead of usize
Diffstat (limited to 'embassy-boot/boot/src/mem_flash.rs')
-rw-r--r--embassy-boot/boot/src/mem_flash.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/embassy-boot/boot/src/mem_flash.rs b/embassy-boot/boot/src/mem_flash.rs
index dd85405c8..c62379b24 100644
--- a/embassy-boot/boot/src/mem_flash.rs
+++ b/embassy-boot/boot/src/mem_flash.rs
@@ -32,6 +32,23 @@ impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> MemFla
32 pending_write_successes: None, 32 pending_write_successes: None,
33 } 33 }
34 } 34 }
35
36 pub fn program(&mut self, offset: u32, bytes: &[u8]) -> Result<(), MemFlashError> {
37 let offset = offset as usize;
38 assert!(bytes.len() % WRITE_SIZE == 0);
39 assert!(offset % WRITE_SIZE == 0);
40 assert!(offset + bytes.len() <= SIZE);
41
42 self.mem[offset..offset + bytes.len()].copy_from_slice(bytes);
43
44 Ok(())
45 }
46
47 pub fn assert_eq(&self, offset: u32, expectation: &[u8]) {
48 for i in 0..expectation.len() {
49 assert_eq!(self.mem[offset as usize + i], expectation[i], "Index {}", i);
50 }
51 }
35} 52}
36 53
37impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> Default 54impl<const SIZE: usize, const ERASE_SIZE: usize, const WRITE_SIZE: usize> Default