aboutsummaryrefslogtreecommitdiff
path: root/embassy-boot
diff options
context:
space:
mode:
authorRasmus Melchior Jacobsen <[email protected]>2023-04-04 12:50:53 +0200
committerRasmus Melchior Jacobsen <[email protected]>2023-04-04 12:50:53 +0200
commit803c09c300a9aeb412e08c37723cd9de3caf89e9 (patch)
tree837ac8c8c2cb4c2255c01a84fbbb6c8515f97c4a /embassy-boot
parent36ad82a52b540eec5e94052b08de8e8e6308f2ce (diff)
Expose read/write/erase on partition
Diffstat (limited to 'embassy-boot')
-rw-r--r--embassy-boot/boot/src/partition.rs22
1 files changed, 6 insertions, 16 deletions
diff --git a/embassy-boot/boot/src/partition.rs b/embassy-boot/boot/src/partition.rs
index 3ccd4dd76..217c457fc 100644
--- a/embassy-boot/boot/src/partition.rs
+++ b/embassy-boot/boot/src/partition.rs
@@ -24,7 +24,7 @@ impl Partition {
24 } 24 }
25 25
26 /// Read from the partition on the provided flash 26 /// Read from the partition on the provided flash
27 pub(crate) async fn read<F: AsyncReadNorFlash>( 27 pub async fn read<F: AsyncReadNorFlash>(
28 &self, 28 &self,
29 flash: &mut F, 29 flash: &mut F,
30 offset: u32, 30 offset: u32,
@@ -35,12 +35,7 @@ impl Partition {
35 } 35 }
36 36
37 /// Write to the partition on the provided flash 37 /// Write to the partition on the provided flash
38 pub(crate) async fn write<F: AsyncNorFlash>( 38 pub async fn write<F: AsyncNorFlash>(&self, flash: &mut F, offset: u32, bytes: &[u8]) -> Result<(), F::Error> {
39 &self,
40 flash: &mut F,
41 offset: u32,
42 bytes: &[u8],
43 ) -> Result<(), F::Error> {
44 let offset = self.from as u32 + offset; 39 let offset = self.from as u32 + offset;
45 flash.write(offset, bytes).await?; 40 flash.write(offset, bytes).await?;
46 trace!("Wrote from 0x{:x} len {}", offset, bytes.len()); 41 trace!("Wrote from 0x{:x} len {}", offset, bytes.len());
@@ -48,7 +43,7 @@ impl Partition {
48 } 43 }
49 44
50 /// Erase part of the partition on the provided flash 45 /// Erase part of the partition on the provided flash
51 pub(crate) async fn erase<F: AsyncNorFlash>(&self, flash: &mut F, from: u32, to: u32) -> Result<(), F::Error> { 46 pub async fn erase<F: AsyncNorFlash>(&self, flash: &mut F, from: u32, to: u32) -> Result<(), F::Error> {
52 let from = self.from as u32 + from; 47 let from = self.from as u32 + from;
53 let to = self.from as u32 + to; 48 let to = self.from as u32 + to;
54 flash.erase(from, to).await?; 49 flash.erase(from, to).await?;
@@ -66,18 +61,13 @@ impl Partition {
66 } 61 }
67 62
68 /// Read from the partition on the provided flash 63 /// Read from the partition on the provided flash
69 pub(crate) fn read_blocking<F: ReadNorFlash>( 64 pub fn read_blocking<F: ReadNorFlash>(&self, flash: &mut F, offset: u32, bytes: &mut [u8]) -> Result<(), F::Error> {
70 &self,
71 flash: &mut F,
72 offset: u32,
73 bytes: &mut [u8],
74 ) -> Result<(), F::Error> {
75 let offset = self.from as u32 + offset; 65 let offset = self.from as u32 + offset;
76 flash.read(offset, bytes) 66 flash.read(offset, bytes)
77 } 67 }
78 68
79 /// Write to the partition on the provided flash 69 /// Write to the partition on the provided flash
80 pub(crate) fn write_blocking<F: NorFlash>(&self, flash: &mut F, offset: u32, bytes: &[u8]) -> Result<(), F::Error> { 70 pub fn write_blocking<F: NorFlash>(&self, flash: &mut F, offset: u32, bytes: &[u8]) -> Result<(), F::Error> {
81 let offset = self.from as u32 + offset; 71 let offset = self.from as u32 + offset;
82 flash.write(offset, bytes)?; 72 flash.write(offset, bytes)?;
83 trace!("Wrote from 0x{:x} len {}", offset, bytes.len()); 73 trace!("Wrote from 0x{:x} len {}", offset, bytes.len());
@@ -85,7 +75,7 @@ impl Partition {
85 } 75 }
86 76
87 /// Erase part of the partition on the provided flash 77 /// Erase part of the partition on the provided flash
88 pub(crate) fn erase_blocking<F: NorFlash>(&self, flash: &mut F, from: u32, to: u32) -> Result<(), F::Error> { 78 pub fn erase_blocking<F: NorFlash>(&self, flash: &mut F, from: u32, to: u32) -> Result<(), F::Error> {
89 let from = self.from as u32 + from; 79 let from = self.from as u32 + from;
90 let to = self.from as u32 + to; 80 let to = self.from as u32 + to;
91 flash.erase(from, to)?; 81 flash.erase(from, to)?;