Merge pull request #3583 from williams-one/add-flash-bank-selection-for-erase
STM32U5: Add flash bank selection when erasing a sector
This commit is contained in:
commit
8954c053fb
@ -72,7 +72,7 @@ rand_core = "0.6.3"
|
||||
sdio-host = "0.5.0"
|
||||
critical-section = "1.1"
|
||||
#stm32-metapac = { version = "15" }
|
||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-04833817666290047257c65c6547d28e1bd10dc9" }
|
||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-ab0ec4c19f81854189bab8215544ccd1256e1045" }
|
||||
|
||||
vcell = "0.1.3"
|
||||
nb = "1.0.0"
|
||||
@ -101,7 +101,7 @@ proc-macro2 = "1.0.36"
|
||||
quote = "1.0.15"
|
||||
|
||||
#stm32-metapac = { version = "15", default-features = false, features = ["metadata"]}
|
||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-04833817666290047257c65c6547d28e1bd10dc9", default-features = false, features = ["metadata"] }
|
||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-ab0ec4c19f81854189bab8215544ccd1256e1045", default-features = false, features = ["metadata"] }
|
||||
|
||||
[features]
|
||||
default = ["rt"]
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use core::ptr::write_volatile;
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{FlashBank, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
@ -70,12 +70,22 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E
|
||||
#[cfg(feature = "trustzone-secure")]
|
||||
pac::FLASH.seccr().modify(|w| {
|
||||
w.set_per(pac::flash::vals::SeccrPer::B_0X1);
|
||||
w.set_pnb(sector.index_in_bank)
|
||||
w.set_pnb(sector.index_in_bank);
|
||||
// TODO: add check for bank swap
|
||||
w.set_bker(match sector.bank {
|
||||
FlashBank::Bank1 => pac::flash::vals::SeccrBker::B_0X0,
|
||||
FlashBank::Bank2 => pac::flash::vals::SeccrBker::B_0X1,
|
||||
});
|
||||
});
|
||||
#[cfg(not(feature = "trustzone-secure"))]
|
||||
pac::FLASH.nscr().modify(|w| {
|
||||
w.set_per(pac::flash::vals::NscrPer::B_0X1);
|
||||
w.set_pnb(sector.index_in_bank)
|
||||
w.set_pnb(sector.index_in_bank);
|
||||
// TODO: add check for bank swap
|
||||
w.set_bker(match sector.bank {
|
||||
FlashBank::Bank1 => pac::flash::vals::NscrBker::B_0X0,
|
||||
FlashBank::Bank2 => pac::flash::vals::NscrBker::B_0X1,
|
||||
});
|
||||
});
|
||||
|
||||
#[cfg(feature = "trustzone-secure")]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user