Merge #797
797: Use correct index and bank for stm32 flash r=Dirbaio a=lulf The page index was wrong because it doesn't take FLASH_BASE into account. For l4, the page index register also depends on a bank selection register. Co-authored-by: Ulf Lilleengen <lulf@redhat.com>
This commit is contained in:
commit
77c7d8f31b
1 changed files with 10 additions and 1 deletions
|
@ -77,7 +77,14 @@ pub(crate) unsafe fn blocking_erase(from: u32, to: u32) -> Result<(), Error> {
|
||||||
|
|
||||||
#[cfg(any(flash_wl, flash_wb, flash_l4))]
|
#[cfg(any(flash_wl, flash_wb, flash_l4))]
|
||||||
{
|
{
|
||||||
let idx = page / super::ERASE_SIZE as u32;
|
let idx = (page - super::FLASH_BASE as u32) / super::ERASE_SIZE as u32;
|
||||||
|
|
||||||
|
#[cfg(flash_l4)]
|
||||||
|
let (idx, bank) = if idx > 255 {
|
||||||
|
(idx - 256, true)
|
||||||
|
} else {
|
||||||
|
(idx, false)
|
||||||
|
};
|
||||||
|
|
||||||
pac::FLASH.cr().modify(|w| {
|
pac::FLASH.cr().modify(|w| {
|
||||||
w.set_per(true);
|
w.set_per(true);
|
||||||
|
@ -86,6 +93,8 @@ pub(crate) unsafe fn blocking_erase(from: u32, to: u32) -> Result<(), Error> {
|
||||||
w.set_strt(true);
|
w.set_strt(true);
|
||||||
#[cfg(any(flash_l4))]
|
#[cfg(any(flash_l4))]
|
||||||
w.set_start(true);
|
w.set_start(true);
|
||||||
|
#[cfg(any(flash_l4))]
|
||||||
|
w.set_bker(bank);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue