fix(stm32h7/flash): enhance resilience to program sequence errors (pgserr)

This commit is contained in:
Badr Bouslikhin 2024-02-06 12:30:04 +01:00
parent ad7d4494fa
commit aab5da1d3b
No known key found for this signature in database
GPG key ID: 3B081233DD4DE99B

View file

@ -77,12 +77,12 @@ pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE])
}
}
bank.cr().write(|w| w.set_pg(false));
cortex_m::asm::isb();
cortex_m::asm::dsb();
fence(Ordering::SeqCst);
bank.cr().write(|w| w.set_pg(false));
res.unwrap()
}
@ -100,6 +100,10 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E
w.set_start(true);
});
cortex_m::asm::isb();
cortex_m::asm::dsb();
fence(Ordering::SeqCst);
let ret: Result<(), Error> = blocking_wait_ready(bank);
bank.cr().modify(|w| w.set_ser(false));
bank_clear_all_err(bank);