mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add pddb erase on altboot for oem mode
This commit is contained in:
parent
8964027fff
commit
0dc2c133f5
1 changed files with 66 additions and 0 deletions
|
|
@ -249,6 +249,72 @@ pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::Boa
|
|||
|
||||
// power on
|
||||
iox.set_gpio_pin_value(oled_on_port, oled_on_pin, IoxValue::High);
|
||||
|
||||
#[cfg(feature = "alt-boot1")]
|
||||
{
|
||||
crate::println!("entering pddb_erase");
|
||||
// setup all the board pins to a known state
|
||||
let iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32);
|
||||
bao1x_hal::board::setup_memory_pins(&iox);
|
||||
|
||||
// this routine is used to initialize baosec products - sets the board type and
|
||||
// erases the off-chip FLASH
|
||||
use bao1x_api::baosec::PDDB_ORIGIN;
|
||||
use bao1x_hal::{
|
||||
board::SPINOR_BULK_ERASE_SIZE,
|
||||
ifram::IframRange,
|
||||
iox::Iox,
|
||||
udma::{Spim, *},
|
||||
};
|
||||
let perclk = 100_000_000;
|
||||
let udma_global = GlobalConfig::new();
|
||||
|
||||
// setup the I/O pins
|
||||
let channel = bao1x_hal::board::setup_memory_pins(&iox);
|
||||
udma_global.clock_on(bao1x_api::PeriphId::from(channel));
|
||||
// safety: this is safe because clocks have been set up
|
||||
let mut flash_spim = unsafe {
|
||||
Spim::new_with_ifram(
|
||||
channel,
|
||||
// has to be half the clock frequency reaching the block, but
|
||||
// run it as fast
|
||||
// as we can run perclk
|
||||
perclk / 4,
|
||||
perclk / 2,
|
||||
SpimClkPol::LeadingEdgeRise,
|
||||
SpimClkPha::CaptureOnLeading,
|
||||
SpimCs::Cs0,
|
||||
0,
|
||||
0,
|
||||
None,
|
||||
256 + 16, /* just enough space to send commands + programming
|
||||
* page */
|
||||
4096,
|
||||
Some(6),
|
||||
Some(SpimMode::Standard), // guess Standard
|
||||
IframRange::from_raw_parts(
|
||||
bao1x_hal::board::SPIM_FLASH_IFRAM_ADDR,
|
||||
bao1x_hal::board::SPIM_FLASH_IFRAM_ADDR,
|
||||
4096 * 2,
|
||||
),
|
||||
)
|
||||
};
|
||||
flash_spim.identify_flash_reset_qpi();
|
||||
let flash_id = flash_spim.mem_read_id_flash();
|
||||
crate::println!("flash ID (init): {:x}", flash_id);
|
||||
if bao1x_api::SPI_FLASH_IDS.contains(&(flash_id & 0xFF_FF_FF)) {
|
||||
let pddb_erase_len = SPINOR_BULK_ERASE_SIZE as usize * 2;
|
||||
for addr in
|
||||
(PDDB_ORIGIN..PDDB_ORIGIN + pddb_erase_len).step_by(SPINOR_BULK_ERASE_SIZE as usize)
|
||||
{
|
||||
crate::println!(" {:x}...", addr);
|
||||
flash_spim.flash_erase_block(addr, SPINOR_BULK_ERASE_SIZE as usize);
|
||||
}
|
||||
crate::println!("...done!");
|
||||
} else {
|
||||
crate::println!("...skipped, couldn't find FLASH part");
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "oem"))]
|
||||
BoardTypeCoding::Oem => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue