summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-10-19 07:29:12 +0000
committerGitHub <noreply@github.com>2022-10-19 07:29:12 +0000
commitd9c773f47598666c322a5e25c1f3d2681c3d3c01 (patch)
tree01c3a1a35dc8624f661c1bf9843f3df0de82536a
parenta669f4cfd8b178e924482cf008d5eaec7889e415 (diff)
parent6c5d81ada52bfac1592c7be025038a3eea3acc42 (diff)
downloadembassy-d9c773f47598666c322a5e25c1f3d2681c3d3c01.zip
Merge #1014
1014: Add memory barriers to H7 flash driver to mitigate PGSERR errors r=lulf a=matoushybl The stm32h7xx-hal uses only the ordering barrier, while the CubeMX uses the DSB and ISB instructions, to be on the safe side, both are used here. Without the barrier, the PG bit is not set, when the writes are being done, resulting in an error. Co-authored-by: Matous Hybl <hyblmatous@gmail.com>
-rw-r--r--embassy-stm32/src/flash/h7.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/embassy-stm32/src/flash/h7.rs b/embassy-stm32/src/flash/h7.rs
index 7ce0ac77..3f2129de 100644
--- a/embassy-stm32/src/flash/h7.rs
+++ b/embassy-stm32/src/flash/h7.rs
@@ -39,6 +39,10 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error
w.set_psize(2); // 32 bits at once
});
+ cortex_m::asm::isb();
+ cortex_m::asm::dsb();
+ atomic_polyfill::fence(atomic_polyfill::Ordering::SeqCst);
+
let ret = {
let mut ret: Result<(), Error> = Ok(());
let mut offset = offset;
@@ -64,6 +68,10 @@ pub(crate) unsafe fn blocking_write(offset: u32, buf: &[u8]) -> Result<(), Error
bank.cr().write(|w| w.set_pg(false));
+ cortex_m::asm::isb();
+ cortex_m::asm::dsb();
+ atomic_polyfill::fence(atomic_polyfill::Ordering::SeqCst);
+
ret
}