Remove all notion of 'default' and 'alt' flash layouts. Now there's just the one layout.
This commit is contained in:
parent
59d839a2b8
commit
e478bdf1df
@ -6,8 +6,8 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_sync::mutex::Mutex;
|
||||
|
||||
use super::{
|
||||
blocking_read, ensure_sector_aligned, family, get_sector, Async, Error, Flash, FlashLayout, FLASH_BASE, FLASH_SIZE,
|
||||
WRITE_SIZE,
|
||||
blocking_read, ensure_sector_aligned, family, get_flash_regions, get_sector, Async, Error, Flash, FlashLayout,
|
||||
FLASH_BASE, FLASH_SIZE, WRITE_SIZE,
|
||||
};
|
||||
use crate::interrupt::InterruptExt;
|
||||
use crate::peripherals::FLASH;
|
||||
@ -34,7 +34,6 @@ impl<'d> Flash<'d, Async> {
|
||||
///
|
||||
/// See module-level documentation for details on how memory regions work.
|
||||
pub fn into_regions(self) -> FlashLayout<'d, Async> {
|
||||
assert!(family::is_default_layout());
|
||||
FlashLayout::new(self.inner)
|
||||
}
|
||||
|
||||
@ -123,7 +122,7 @@ pub(super) async unsafe fn write_chunked(base: u32, size: u32, offset: u32, byte
|
||||
pub(super) async unsafe fn erase_sectored(base: u32, from: u32, to: u32) -> Result<(), Error> {
|
||||
let start_address = base + from;
|
||||
let end_address = base + to;
|
||||
let regions = family::get_flash_regions();
|
||||
let regions = get_flash_regions();
|
||||
|
||||
ensure_sector_aligned(start_address, end_address, regions)?;
|
||||
|
||||
|
||||
@ -4,8 +4,8 @@ use core::sync::atomic::{fence, Ordering};
|
||||
use embassy_hal_internal::drop::OnDrop;
|
||||
|
||||
use super::{
|
||||
family, Async, Blocking, Error, FlashBank, FlashLayout, FlashRegion, FlashSector, FLASH_SIZE, MAX_ERASE_SIZE,
|
||||
READ_SIZE, WRITE_SIZE,
|
||||
family, get_flash_regions, Async, Blocking, Error, FlashBank, FlashLayout, FlashRegion, FlashSector, FLASH_SIZE,
|
||||
MAX_ERASE_SIZE, READ_SIZE, WRITE_SIZE,
|
||||
};
|
||||
use crate::Peri;
|
||||
use crate::_generated::FLASH_BASE;
|
||||
@ -36,7 +36,6 @@ impl<'d, MODE> Flash<'d, MODE> {
|
||||
///
|
||||
/// See module-level documentation for details on how memory regions work.
|
||||
pub fn into_blocking_regions(self) -> FlashLayout<'d, Blocking> {
|
||||
assert!(family::is_default_layout());
|
||||
FlashLayout::new(self.inner)
|
||||
}
|
||||
|
||||
@ -141,7 +140,7 @@ pub(super) unsafe fn blocking_erase(
|
||||
) -> Result<(), Error> {
|
||||
let start_address = base + from;
|
||||
let end_address = base + to;
|
||||
let regions = family::get_flash_regions();
|
||||
let regions = get_flash_regions();
|
||||
|
||||
ensure_sector_aligned(start_address, end_address, regions)?;
|
||||
|
||||
|
||||
@ -1,18 +1,10 @@
|
||||
use core::ptr::write_volatile;
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{FlashSector, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
pac::FLASH.cr().modify(|w| w.set_lock(true));
|
||||
}
|
||||
|
||||
@ -1,18 +1,10 @@
|
||||
use core::ptr::write_volatile;
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{FlashSector, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
pac::FLASH.cr().modify(|w| w.set_lock(true));
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ use core::sync::atomic::{fence, AtomicBool, Ordering};
|
||||
|
||||
use pac::flash::regs::Sr;
|
||||
|
||||
use super::{FlashBank, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{get_flash_regions, FlashBank, FlashSector, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
@ -15,14 +15,6 @@ impl FlashSector {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
pac::FLASH.cr().modify(|w| w.set_lock(true));
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ use core::sync::atomic::{fence, AtomicBool, Ordering};
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
use pac::flash::regs::Sr;
|
||||
|
||||
use super::{FlashBank, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{get_flash_regions, FlashBank, FlashSector, WRITE_SIZE};
|
||||
use crate::_generated::FLASH_SIZE;
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
@ -18,14 +18,6 @@ impl FlashSector {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn on_interrupt() {
|
||||
// Clear IRQ flags
|
||||
pac::FLASH.sr().write(|w| {
|
||||
@ -306,7 +298,7 @@ mod tests {
|
||||
|
||||
if !cfg!(feature = "dual-bank") {
|
||||
let assert_sector = |snb: u8, index_in_bank: u8, start: u32, size: u32, address: u32| {
|
||||
let sector = get_sector(address, &FLASH_REGIONS);
|
||||
let sector = get_sector(address, crate::flash::get_flash_regions());
|
||||
assert_eq!(snb, sector.snb());
|
||||
assert_eq!(
|
||||
FlashSector {
|
||||
@ -333,7 +325,7 @@ mod tests {
|
||||
assert_sector(0x0B, 11, 0x080E_0000, LARGE_SECTOR_SIZE, 0x080F_FFFF);
|
||||
} else {
|
||||
let assert_sector = |snb: u8, bank: FlashBank, index_in_bank: u8, start: u32, size: u32, address: u32| {
|
||||
let sector = get_sector(address, &FLASH_REGIONS);
|
||||
let sector = get_sector(address, crate::flash::get_flash_regions());
|
||||
assert_eq!(snb, sector.snb());
|
||||
assert_eq!(
|
||||
FlashSector {
|
||||
|
||||
@ -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::{FlashSector, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
@ -11,14 +11,6 @@ impl FlashSector {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
pac::FLASH.cr().modify(|w| w.set_lock(true));
|
||||
}
|
||||
@ -124,7 +116,7 @@ mod tests {
|
||||
start,
|
||||
size
|
||||
},
|
||||
get_sector(address, &FLASH_REGIONS)
|
||||
get_sector(address, crate::flash::get_flash_regions())
|
||||
)
|
||||
};
|
||||
|
||||
@ -157,7 +149,7 @@ mod tests {
|
||||
start,
|
||||
size
|
||||
},
|
||||
get_sector(address, &FLASH_REGIONS)
|
||||
get_sector(address, crate::flash::get_flash_regions())
|
||||
)
|
||||
};
|
||||
|
||||
@ -190,9 +182,9 @@ mod tests {
|
||||
start,
|
||||
size
|
||||
},
|
||||
get_sector(address, &FLASH_REGIONS)
|
||||
get_sector(address, crate::flash::get_flash_regions())
|
||||
);
|
||||
assert_eq!(get_sector(address, &FLASH_REGIONS).snb(), snb);
|
||||
assert_eq!(get_sector(address, crate::flash::get_flash_regions()).snb(), snb);
|
||||
};
|
||||
|
||||
assert_sector(0, 0x0800_0000, SMALL_SECTOR_SIZE, 0x0800_0000, 0x00, FlashBank::Bank1);
|
||||
|
||||
@ -3,18 +3,10 @@ use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use cortex_m::interrupt;
|
||||
|
||||
use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{FlashSector, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
pac::FLASH.cr().modify(|w| w.set_lock(true));
|
||||
}
|
||||
|
||||
@ -1,22 +1,10 @@
|
||||
use core::ptr::write_volatile;
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{FlashSector, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
// const fn is_dual_bank() -> bool {
|
||||
// FLASH_REGIONS.len() >= 2
|
||||
// }
|
||||
|
||||
pub(crate) fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
if !pac::FLASH.nscr().read().lock() {
|
||||
pac::FLASH.nscr().modify(|r| {
|
||||
|
||||
@ -8,17 +8,9 @@ use cortex_m::interrupt;
|
||||
use pac::flash::regs::Nssr;
|
||||
use pac::flash::vals::Bksel;
|
||||
|
||||
use super::{Error, FlashBank, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{Error, FlashBank, FlashSector, WRITE_SIZE};
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
pac::FLASH.nscr().modify(|w| w.set_lock(true));
|
||||
}
|
||||
|
||||
@ -1,22 +1,14 @@
|
||||
use core::ptr::write_volatile;
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use super::{FlashRegion, FlashSector, BANK1_REGION, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{FlashSector, BANK1_REGION, FLASH_REGIONS, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
const fn is_dual_bank() -> bool {
|
||||
FLASH_REGIONS.len() >= 2
|
||||
}
|
||||
|
||||
pub(crate) fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
pac::FLASH.bank(0).cr().modify(|w| w.set_lock(true));
|
||||
if is_dual_bank() {
|
||||
|
||||
@ -1,18 +1,10 @@
|
||||
use core::ptr::write_volatile;
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{FlashSector, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
#[cfg(any(flash_wl, flash_wb, flash_l4))]
|
||||
pac::FLASH.cr().modify(|w| w.set_lock(true));
|
||||
|
||||
@ -14,17 +14,9 @@ pub use common::*;
|
||||
pub use crate::_generated::flash_regions::*;
|
||||
pub use crate::_generated::{FLASH_BASE, FLASH_SIZE, MAX_ERASE_SIZE, WRITE_SIZE};
|
||||
|
||||
/// Get whether the default flash layout is being used.
|
||||
///
|
||||
/// In some chips, dual-bank is not default. This will then return `false`
|
||||
/// when dual-bank is enabled.
|
||||
pub fn is_default_layout() -> bool {
|
||||
family::is_default_layout()
|
||||
}
|
||||
|
||||
/// Get all flash regions.
|
||||
pub fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
family::get_flash_regions()
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
/// Read size (always 1)
|
||||
|
||||
@ -1,14 +1,6 @@
|
||||
#![allow(unused)]
|
||||
|
||||
use super::{Error, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
use super::{Error, FlashSector, WRITE_SIZE};
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
unimplemented!();
|
||||
|
||||
@ -3,18 +3,10 @@ use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use cortex_m::interrupt;
|
||||
|
||||
use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{FlashSector, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
pac::FLASH.cr().modify(|w| w.set_lock(true));
|
||||
}
|
||||
|
||||
@ -1,18 +1,10 @@
|
||||
use core::ptr::write_volatile;
|
||||
use core::sync::atomic::{fence, Ordering};
|
||||
|
||||
use super::{FlashBank, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE};
|
||||
use super::{FlashBank, FlashSector, WRITE_SIZE};
|
||||
use crate::flash::Error;
|
||||
use crate::pac;
|
||||
|
||||
pub(crate) const fn is_default_layout() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] {
|
||||
&FLASH_REGIONS
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn lock() {
|
||||
#[cfg(feature = "trustzone-secure")]
|
||||
pac::FLASH.seccr().modify(|w| w.set_lock(true));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user