aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-boot/stm32/Cargo.toml2
-rw-r--r--embassy-stm32/src/flash/mod.rs112
-rw-r--r--embassy-stm32/src/lib.rs2
-rw-r--r--examples/boot/stm32f3/.cargo/config.toml6
-rw-r--r--examples/boot/stm32f3/Cargo.toml26
-rw-r--r--examples/boot/stm32f3/README.md29
-rw-r--r--examples/boot/stm32f3/build.rs37
-rw-r--r--examples/boot/stm32f3/memory.x15
-rw-r--r--examples/boot/stm32f3/src/bin/a.rs44
-rw-r--r--examples/boot/stm32f3/src/bin/b.rs25
-rw-r--r--examples/stm32f3/Cargo.toml1
-rw-r--r--examples/stm32f3/src/bin/blinky.rs2
-rw-r--r--examples/stm32f3/src/bin/flash.rs43
m---------stm32-data0
14 files changed, 313 insertions, 31 deletions
diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml
index a706e4c06..78339b0a2 100644
--- a/embassy-boot/stm32/Cargo.toml
+++ b/embassy-boot/stm32/Cargo.toml
@@ -2,7 +2,7 @@
2authors = [ 2authors = [
3 "Ulf Lilleengen <[email protected]>", 3 "Ulf Lilleengen <[email protected]>",
4] 4]
5edition = "2018" 5edition = "2021"
6name = "embassy-boot-stm32" 6name = "embassy-boot-stm32"
7version = "0.1.0" 7version = "0.1.0"
8description = "Bootloader for STM32 chips" 8description = "Bootloader for STM32 chips"
diff --git a/embassy-stm32/src/flash/mod.rs b/embassy-stm32/src/flash/mod.rs
index cff3119fd..0ce74a5e4 100644
--- a/embassy-stm32/src/flash/mod.rs
+++ b/embassy-stm32/src/flash/mod.rs
@@ -33,13 +33,13 @@ impl<'d> Flash<'d> {
33 33
34 pub fn unlock(p: impl Unborrow<Target = FLASH>) -> Self { 34 pub fn unlock(p: impl Unborrow<Target = FLASH>) -> Self {
35 let flash = Self::new(p); 35 let flash = Self::new(p);
36 #[cfg(any(flash_wl, flash_wb, flash_l4))] 36 #[cfg(any(flash_wl, flash_wb, flash_l4, flash_f3))]
37 unsafe { 37 unsafe {
38 pac::FLASH.keyr().write(|w| w.set_keyr(0x4567_0123)); 38 pac::FLASH.keyr().write(|w| w.set_keyr(0x4567_0123));
39 pac::FLASH.keyr().write(|w| w.set_keyr(0xCDEF_89AB)); 39 pac::FLASH.keyr().write(|w| w.set_keyr(0xCDEF_89AB));
40 } 40 }
41 41
42 #[cfg(any(flash_l0))] 42 #[cfg(any(flash_l0, flash_l1))]
43 unsafe { 43 unsafe {
44 pac::FLASH.pekeyr().write(|w| w.set_pekeyr(0x89ABCDEF)); 44 pac::FLASH.pekeyr().write(|w| w.set_pekeyr(0x89ABCDEF));
45 pac::FLASH.pekeyr().write(|w| w.set_pekeyr(0x02030405)); 45 pac::FLASH.pekeyr().write(|w| w.set_pekeyr(0x02030405));
@@ -51,7 +51,7 @@ impl<'d> Flash<'d> {
51 } 51 }
52 52
53 pub fn lock(&mut self) { 53 pub fn lock(&mut self) {
54 #[cfg(any(flash_wl, flash_wb, flash_l4))] 54 #[cfg(any(flash_wl, flash_wb, flash_l4, flash_f3))]
55 unsafe { 55 unsafe {
56 pac::FLASH.cr().modify(|w| w.set_lock(true)); 56 pac::FLASH.cr().modify(|w| w.set_lock(true));
57 } 57 }
@@ -89,31 +89,56 @@ impl<'d> Flash<'d> {
89 89
90 self.clear_all_err(); 90 self.clear_all_err();
91 91
92 #[cfg(any(flash_wl, flash_wb, flash_l4))] 92 #[cfg(any(flash_wl, flash_wb, flash_l4, flash_f3))]
93 unsafe { 93 unsafe {
94 pac::FLASH.cr().write(|w| w.set_pg(true)) 94 pac::FLASH.cr().write(|w| w.set_pg(true))
95 } 95 }
96 96
97 let mut ret: Result<(), Error> = Ok(()); 97 #[cfg(not(flash_f3))]
98 let mut offset = offset; 98 let ret = {
99 for chunk in buf.chunks(WRITE_SIZE) { 99 let mut ret: Result<(), Error> = Ok(());
100 for val in chunk.chunks(4) { 100 let mut offset = offset;
101 for chunk in buf.chunks(WRITE_SIZE) {
102 for val in chunk.chunks(4) {
103 unsafe {
104 write_volatile(
105 offset as *mut u32,
106 u32::from_le_bytes(val[0..4].try_into().unwrap()),
107 );
108 }
109 offset += val.len() as u32;
110 }
111
112 ret = self.blocking_wait_ready();
113 if ret.is_err() {
114 break;
115 }
116 }
117 ret
118 };
119
120 #[cfg(flash_f3)]
121 let ret = {
122 let mut ret: Result<(), Error> = Ok(());
123 let mut offset = offset;
124 for chunk in buf.chunks(2) {
101 unsafe { 125 unsafe {
102 write_volatile( 126 write_volatile(
103 offset as *mut u32, 127 offset as *mut u16,
104 u32::from_le_bytes(val[0..4].try_into().unwrap()), 128 u16::from_le_bytes(chunk[0..2].try_into().unwrap()),
105 ); 129 );
106 } 130 }
107 offset += val.len() as u32; 131 offset += chunk.len() as u32;
108 }
109 132
110 ret = self.blocking_wait_ready(); 133 ret = self.blocking_wait_ready();
111 if ret.is_err() { 134 if ret.is_err() {
112 break; 135 break;
136 }
113 } 137 }
114 } 138 ret
139 };
115 140
116 #[cfg(any(flash_wl, flash_wb, flash_l4))] 141 #[cfg(any(flash_wl, flash_wb, flash_l4, flash_f3))]
117 unsafe { 142 unsafe {
118 pac::FLASH.cr().write(|w| w.set_pg(false)) 143 pac::FLASH.cr().write(|w| w.set_pg(false))
119 } 144 }
@@ -144,23 +169,41 @@ impl<'d> Flash<'d> {
144 write_volatile(page as *mut u32, 0xFFFFFFFF); 169 write_volatile(page as *mut u32, 0xFFFFFFFF);
145 } 170 }
146 171
147 #[cfg(any(flash_wl, flash_wb, flash_l4))] 172 #[cfg(any(flash_wl, flash_wb, flash_l4, flash_f3))]
148 unsafe { 173 unsafe {
174 #[cfg(not(flash_f3))]
149 let idx = page / ERASE_SIZE as u32; 175 let idx = page / ERASE_SIZE as u32;
150 176
151 pac::FLASH.cr().modify(|w| { 177 pac::FLASH.cr().modify(|w| {
152 w.set_per(true); 178 w.set_per(true);
179 #[cfg(not(flash_f3))]
153 w.set_pnb(idx as u8); 180 w.set_pnb(idx as u8);
154 #[cfg(any(flash_wl, flash_wb))] 181 #[cfg(any(flash_wl, flash_wb))]
155 w.set_strt(true); 182 w.set_strt(true);
156 #[cfg(any(flash_l4))] 183 #[cfg(any(flash_l4))]
157 w.set_start(true); 184 w.set_start(true);
158 }); 185 });
186
187 #[cfg(flash_f3)]
188 pac::FLASH.ar().write(|w| w.set_far(page));
189
190 #[cfg(flash_f3)]
191 pac::FLASH.cr().modify(|w| {
192 w.set_strt(true);
193 });
159 } 194 }
160 195
161 let ret: Result<(), Error> = self.blocking_wait_ready(); 196 let ret: Result<(), Error> = self.blocking_wait_ready();
162 197
163 #[cfg(any(flash_wl, flash_wb, flash_l4))] 198 unsafe {
199 if pac::FLASH.sr().read().eop() {
200 pac::FLASH.sr().modify(|w| w.set_eop(true));
201 } else {
202 panic!("wtf")
203 }
204 }
205
206 #[cfg(any(flash_wl, flash_wb, flash_l4, flash_f3))]
164 unsafe { 207 unsafe {
165 pac::FLASH.cr().modify(|w| w.set_per(false)); 208 pac::FLASH.cr().modify(|w| w.set_per(false));
166 } 209 }
@@ -196,10 +239,12 @@ impl<'d> Flash<'d> {
196 return Err(Error::Protected); 239 return Err(Error::Protected);
197 } 240 }
198 241
242 #[cfg(not(flash_f3))]
199 if sr.pgaerr() { 243 if sr.pgaerr() {
200 return Err(Error::Unaligned); 244 return Err(Error::Unaligned);
201 } 245 }
202 246
247 #[cfg(not(flash_f3))]
203 if sr.sizerr() { 248 if sr.sizerr() {
204 return Err(Error::Size); 249 return Err(Error::Size);
205 } 250 }
@@ -213,6 +258,11 @@ impl<'d> Flash<'d> {
213 if sr.pgserr() { 258 if sr.pgserr() {
214 return Err(Error::Seq); 259 return Err(Error::Seq);
215 } 260 }
261
262 #[cfg(flash_f3)]
263 if sr.pgerr() {
264 return Err(Error::Seq);
265 }
216 return Ok(()); 266 return Ok(());
217 } 267 }
218 } 268 }
@@ -223,36 +273,42 @@ impl<'d> Flash<'d> {
223 pac::FLASH.sr().modify(|w| { 273 pac::FLASH.sr().modify(|w| {
224 #[cfg(any(flash_wl, flash_wb, flash_l4, flash_l0))] 274 #[cfg(any(flash_wl, flash_wb, flash_l4, flash_l0))]
225 if w.rderr() { 275 if w.rderr() {
226 w.set_rderr(false); 276 w.set_rderr(true);
227 } 277 }
228 #[cfg(any(flash_wl, flash_wb, flash_l4))] 278 #[cfg(any(flash_wl, flash_wb, flash_l4))]
229 if w.fasterr() { 279 if w.fasterr() {
230 w.set_fasterr(false); 280 w.set_fasterr(true);
231 } 281 }
232 #[cfg(any(flash_wl, flash_wb, flash_l4))] 282 #[cfg(any(flash_wl, flash_wb, flash_l4))]
233 if w.miserr() { 283 if w.miserr() {
234 w.set_miserr(false); 284 w.set_miserr(true);
235 } 285 }
236 #[cfg(any(flash_wl, flash_wb, flash_l4))] 286 #[cfg(any(flash_wl, flash_wb, flash_l4))]
237 if w.pgserr() { 287 if w.pgserr() {
238 w.set_pgserr(false); 288 w.set_pgserr(true);
289 }
290 #[cfg(flash_f3)]
291 if w.pgerr() {
292 w.set_pgerr(true);
239 } 293 }
294 #[cfg(not(flash_f3))]
240 if w.sizerr() { 295 if w.sizerr() {
241 w.set_sizerr(false); 296 w.set_sizerr(true);
242 } 297 }
298 #[cfg(not(flash_f3))]
243 if w.pgaerr() { 299 if w.pgaerr() {
244 w.set_pgaerr(false); 300 w.set_pgaerr(true);
245 } 301 }
246 if w.wrperr() { 302 if w.wrperr() {
247 w.set_wrperr(false); 303 w.set_wrperr(true);
248 } 304 }
249 #[cfg(any(flash_wl, flash_wb, flash_l4))] 305 #[cfg(any(flash_wl, flash_wb, flash_l4))]
250 if w.progerr() { 306 if w.progerr() {
251 w.set_progerr(false); 307 w.set_progerr(true);
252 } 308 }
253 #[cfg(any(flash_wl, flash_wb, flash_l4))] 309 #[cfg(any(flash_wl, flash_wb, flash_l4))]
254 if w.operr() { 310 if w.operr() {
255 w.set_operr(false); 311 w.set_operr(true);
256 } 312 }
257 }); 313 });
258 } 314 }
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index ba426128f..8f9b4a58d 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -50,7 +50,7 @@ pub mod i2c;
50 50
51#[cfg(crc)] 51#[cfg(crc)]
52pub mod crc; 52pub mod crc;
53#[cfg(any(flash_l0, flash_l1, flash_wl, flash_wb, flash_l4))] 53#[cfg(any(flash_l0, flash_l1, flash_wl, flash_wb, flash_l4, flash_f3))]
54pub mod flash; 54pub mod flash;
55pub mod pwm; 55pub mod pwm;
56#[cfg(rng)] 56#[cfg(rng)]
diff --git a/examples/boot/stm32f3/.cargo/config.toml b/examples/boot/stm32f3/.cargo/config.toml
new file mode 100644
index 000000000..eb8a8b335
--- /dev/null
+++ b/examples/boot/stm32f3/.cargo/config.toml
@@ -0,0 +1,6 @@
1[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2# replace STM32F429ZITx with your chip as listed in `probe-run --list-chips`
3runner = "probe-run --chip STM32F303VCTx"
4
5[build]
6target = "thumbv7em-none-eabihf"
diff --git a/examples/boot/stm32f3/Cargo.toml b/examples/boot/stm32f3/Cargo.toml
new file mode 100644
index 000000000..d4ca600f8
--- /dev/null
+++ b/examples/boot/stm32f3/Cargo.toml
@@ -0,0 +1,26 @@
1[package]
2authors = ["Ulf Lilleengen <[email protected]>"]
3edition = "2021"
4name = "embassy-boot-stm32f3-examples"
5version = "0.1.0"
6
7[dependencies]
8embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] }
9embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] }
10embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
11embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" }
12
13defmt = { version = "0.3", optional = true }
14defmt-rtt = { version = "0.3", optional = true }
15panic-reset = { version = "0.1.1" }
16embedded-hal = { version = "0.2.6" }
17
18cortex-m = "0.7.3"
19cortex-m-rt = "0.7.0"
20
21[features]
22defmt = [
23 "dep:defmt",
24 "embassy-stm32/defmt",
25 "embassy-boot-stm32/defmt",
26]
diff --git a/examples/boot/stm32f3/README.md b/examples/boot/stm32f3/README.md
new file mode 100644
index 000000000..e92ffb692
--- /dev/null
+++ b/examples/boot/stm32f3/README.md
@@ -0,0 +1,29 @@
1# Examples using bootloader
2
3Example for STM32F3 demonstrating the bootloader. The example consists of application binaries, 'a'
4which allows you to press a button to start the DFU process, and 'b' which is the updated
5application.
6
7
8## Prerequisites
9
10* `cargo-binutils`
11* `cargo-flash`
12* `embassy-boot-stm32`
13
14## Usage
15
16```
17# Flash bootloader
18cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32f303re --chip STM32F303RETx
19# Build 'b'
20cargo build --release --bin b
21# Generate binary for 'b'
22cargo objcopy --release --bin b -- -O binary b.bin
23```
24
25# Flash `a` (which includes b.bin)
26
27```
28cargo flash --release --bin a --chip STM32F303RETx
29```
diff --git a/examples/boot/stm32f3/build.rs b/examples/boot/stm32f3/build.rs
new file mode 100644
index 000000000..e1da69328
--- /dev/null
+++ b/examples/boot/stm32f3/build.rs
@@ -0,0 +1,37 @@
1//! This build script copies the `memory.x` file from the crate root into
2//! a directory where the linker can always find it at build time.
3//! For many projects this is optional, as the linker always searches the
4//! project root directory -- wherever `Cargo.toml` is. However, if you
5//! are using a workspace or have a more complicated build setup, this
6//! build script becomes required. Additionally, by requesting that
7//! Cargo re-run the build script whenever `memory.x` is changed,
8//! updating `memory.x` ensures a rebuild of the application with the
9//! new memory settings.
10
11use std::env;
12use std::fs::File;
13use std::io::Write;
14use std::path::PathBuf;
15
16fn main() {
17 // Put `memory.x` in our output directory and ensure it's
18 // on the linker search path.
19 let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
20 File::create(out.join("memory.x"))
21 .unwrap()
22 .write_all(include_bytes!("memory.x"))
23 .unwrap();
24 println!("cargo:rustc-link-search={}", out.display());
25
26 // By default, Cargo will re-run a build script whenever
27 // any file in the project changes. By specifying `memory.x`
28 // here, we ensure the build script is only re-run when
29 // `memory.x` is changed.
30 println!("cargo:rerun-if-changed=memory.x");
31
32 println!("cargo:rustc-link-arg-bins=--nmagic");
33 println!("cargo:rustc-link-arg-bins=-Tlink.x");
34 if env::var("CARGO_FEATURE_DEFMT").is_ok() {
35 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
36 }
37}
diff --git a/examples/boot/stm32f3/memory.x b/examples/boot/stm32f3/memory.x
new file mode 100644
index 000000000..14b2a2c9f
--- /dev/null
+++ b/examples/boot/stm32f3/memory.x
@@ -0,0 +1,15 @@
1MEMORY
2{
3 /* NOTE 1 K = 1 KiBi = 1024 bytes */
4 BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K
5 BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K
6 FLASH : ORIGIN = 0x08008000, LENGTH = 32K
7 DFU : ORIGIN = 0x08010000, LENGTH = 36K
8 RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K
9}
10
11__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER);
12__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER);
13
14__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER);
15__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER);
diff --git a/examples/boot/stm32f3/src/bin/a.rs b/examples/boot/stm32f3/src/bin/a.rs
new file mode 100644
index 000000000..db9262f43
--- /dev/null
+++ b/examples/boot/stm32f3/src/bin/a.rs
@@ -0,0 +1,44 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use embassy_boot_stm32::FirmwareUpdater;
6use embassy_stm32::exti::ExtiInput;
7use embassy_stm32::flash::Flash;
8use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
9use embassy_stm32::Peripherals;
10use embassy_traits::adapter::BlockingAsync;
11use panic_reset as _;
12
13#[cfg(feature = "defmt-rtt")]
14use defmt_rtt::*;
15
16static APP_B: &[u8] = include_bytes!("../../b.bin");
17
18#[embassy::main]
19async fn main(_s: embassy::executor::Spawner, p: Peripherals) {
20 let flash = Flash::unlock(p.FLASH);
21 let mut flash = BlockingAsync::new(flash);
22
23 let button = Input::new(p.PC13, Pull::Up);
24 let mut button = ExtiInput::new(button, p.EXTI13);
25
26 let mut led = Output::new(p.PA5, Level::Low, Speed::Low);
27 led.set_high();
28
29 let mut updater = FirmwareUpdater::default();
30 button.wait_for_falling_edge().await;
31 let mut offset = 0;
32 for chunk in APP_B.chunks(2048) {
33 let mut buf: [u8; 2048] = [0; 2048];
34 buf[..chunk.len()].copy_from_slice(chunk);
35 updater
36 .write_firmware(offset, &buf, &mut flash, 2048)
37 .await
38 .unwrap();
39 offset += chunk.len();
40 }
41 updater.update(&mut flash).await.unwrap();
42 led.set_low();
43 cortex_m::peripheral::SCB::sys_reset();
44}
diff --git a/examples/boot/stm32f3/src/bin/b.rs b/examples/boot/stm32f3/src/bin/b.rs
new file mode 100644
index 000000000..814275988
--- /dev/null
+++ b/examples/boot/stm32f3/src/bin/b.rs
@@ -0,0 +1,25 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use embassy::executor::Spawner;
6use embassy::time::{Duration, Timer};
7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_stm32::Peripherals;
9use panic_reset as _;
10
11#[cfg(feature = "defmt-rtt")]
12use defmt_rtt::*;
13
14#[embassy::main]
15async fn main(_spawner: Spawner, p: Peripherals) {
16 let mut led = Output::new(p.PA5, Level::High, Speed::Low);
17
18 loop {
19 led.set_high();
20 Timer::after(Duration::from_millis(500)).await;
21
22 led.set_low();
23 Timer::after(Duration::from_millis(500)).await;
24 }
25}
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml
index 37f99fea2..e7a44c11e 100644
--- a/examples/stm32f3/Cargo.toml
+++ b/examples/stm32f3/Cargo.toml
@@ -19,3 +19,4 @@ panic-probe = { version = "0.3", features = ["print-defmt"] }
19futures = { version = "0.3.17", default-features = false, features = ["async-await"] } 19futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
20heapless = { version = "0.7.5", default-features = false } 20heapless = { version = "0.7.5", default-features = false }
21nb = "1.0.0" 21nb = "1.0.0"
22embedded-storage = "0.3.0"
diff --git a/examples/stm32f3/src/bin/blinky.rs b/examples/stm32f3/src/bin/blinky.rs
index b3643a26f..4b181a784 100644
--- a/examples/stm32f3/src/bin/blinky.rs
+++ b/examples/stm32f3/src/bin/blinky.rs
@@ -15,7 +15,7 @@ use panic_probe as _;
15async fn main(_spawner: Spawner, p: Peripherals) { 15async fn main(_spawner: Spawner, p: Peripherals) {
16 info!("Hello World!"); 16 info!("Hello World!");
17 17
18 let mut led = Output::new(p.PE12, Level::High, Speed::Low); 18 let mut led = Output::new(p.PA5, Level::High, Speed::Low);
19 19
20 loop { 20 loop {
21 info!("high"); 21 info!("high");
diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs
new file mode 100644
index 000000000..3890f0514
--- /dev/null
+++ b/examples/stm32f3/src/bin/flash.rs
@@ -0,0 +1,43 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::{info, unwrap};
6use embassy::executor::Spawner;
7use embassy_stm32::flash::Flash;
8use embassy_stm32::Peripherals;
9use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
10
11use defmt_rtt as _; // global logger
12use panic_probe as _;
13
14#[embassy::main]
15async fn main(_spawner: Spawner, p: Peripherals) {
16 info!("Hello Flash!");
17
18 const ADDR: u32 = 0x26000;
19
20 let mut f = Flash::unlock(p.FLASH);
21
22 info!("Reading...");
23 let mut buf = [0u8; 8];
24 unwrap!(f.read(ADDR, &mut buf));
25 info!("Read: {=[u8]:x}", buf);
26
27 info!("Erasing...");
28 unwrap!(f.erase(ADDR, ADDR + 2048));
29
30 info!("Reading...");
31 let mut buf = [0u8; 8];
32 unwrap!(f.read(ADDR, &mut buf));
33 info!("Read after erase: {=[u8]:x}", buf);
34
35 info!("Writing...");
36 unwrap!(f.write(ADDR, &[1, 2, 3, 4, 5, 6, 7, 8]));
37
38 info!("Reading...");
39 let mut buf = [0u8; 8];
40 unwrap!(f.read(ADDR, &mut buf));
41 info!("Read: {=[u8]:x}", buf);
42 assert_eq!(&buf[..], &[1, 2, 3, 4, 5, 6, 7, 8]);
43}
diff --git a/stm32-data b/stm32-data
Subproject 9abfa9d2b51e6071fdc7e680b4a171e4fa20c2f Subproject b2d7a9f5de7dc3ae17c87c1ff94e13a822d18e7