add some prelim test routines for flash access

This commit is contained in:
bunnie 2025-05-16 19:04:12 +08:00
parent 3872ae2a1c
commit e47ed41726
2 changed files with 24 additions and 0 deletions

View file

@ -22,6 +22,7 @@ usb-cramium = { path = "../usb-cramium" }
modals = { path = "../modals", default-features = false }
ux-api = { path = "../../libs/ux-api", optional = true }
pddb = { path = "../pddb", optional = true }
xous-swapper = { path = "../xous-swapper" }
# pddb testing
rand = { version = "0.8.5", features = ["getrandom"], optional = true }

View file

@ -12,6 +12,29 @@ fn main() {
let tt = ticktimer::Ticktimer::new().unwrap();
shell::start_shell();
log::info!("start spi flash map test");
let spimap = xous::map_memory(
None,
xous::MemoryAddress::new(xous::arch::MMAP_VIRT_BASE),
cramium_hal::board::SPINOR_LEN as usize,
xous::MemoryFlags::R | xous::MemoryFlags::W | xous::MemoryFlags::VIRT,
)
.expect("couldn't map spi range");
log::info!("spimap: {:x?}", spimap);
// we have the mapping, now try to dereference it and read something to test it
let spislice: &[u32] = unsafe { spimap.as_slice() };
// this should trigger the page fault and thus the handler
log::info!("spislice: {:x?}", &spislice[..32]);
// marks modified pages as dirty.
xous_swapper::mark_dirty(&spislice[..32]);
// Calls sync to explicitly flush the dirty pages now
xous_swapper::sync(Some(&spislice[..32]));
// xous_swapper::sync::<u8>(None);
log::info!("end spi flash map test");
#[cfg(feature = "test-scrollbars")]
{
let mut sl_binding = ux_api::widgets::ScrollableList::default();