more renode tests for flash access

This commit is contained in:
bunnie 2025-05-16 19:04:30 +08:00
parent e47ed41726
commit 3f96f876c7
2 changed files with 20 additions and 4 deletions

View file

@ -23,7 +23,7 @@ rkyv = { version = "0.8.8", default-features = false, features = [
"std",
"alloc",
] }
xous-swapper = { path = "../xous-swapper" }
utralib = { version = "0.1.25", optional = true, default-features = false }

View file

@ -29,9 +29,10 @@ fn main() -> ! {
}
log::info!("start spi flash map test");
let spimap = xous::map_memory(
let mut spimap = xous::map_memory(
None,
xous::MemoryAddress::new(xous::arch::MMAP_VIRT_BASE),
// should normally be cramium_hal::board::SPINOR_LEN
16 * 1024 * 1024,
xous::MemoryFlags::R | xous::MemoryFlags::W | xous::MemoryFlags::VIRT,
)
@ -39,15 +40,30 @@ fn main() -> ! {
log::info!("spimap: {:x?}", spimap);
// cache_flush();
// we have the mapping, now try to dereference it and read something to test it
let spislice: &[u32] = unsafe { spimap.as_slice() };
let spislice: &mut [u32] = unsafe { spimap.as_slice_mut() };
log::info!("spislice ptr: {:x}", spislice.as_ptr() as usize);
// this should trigger the page fault and thus the handler
log::info!("spislice @ 0: {:x?}", &spislice[..32]);
log::info!("spislice @ 16384: {:x?}", &spislice[16384..16384 + 32]);
log::info!("spislice @ 8190: {:x?}", &spislice[8190..8190 + 32]);
// poke some data into the slice for flushing
log::info!("writing data");
for (i, d) in spislice[4096 / size_of::<u32>()..(4096 / size_of::<u32>()) + 4].iter_mut().enumerate() {
*d = i as u32 | 0x1111_0000;
}
log::info!("wrote: {:x?}", &spislice[4096 / size_of::<u32>()..(4096 / size_of::<u32>()) + 4]);
// marks modified pages as dirty.
xous_swapper::mark_dirty(&spislice[4096 / size_of::<u32>()..(4096 / size_of::<u32>()) + 4]);
log::info!("pages marked as dirty; now doing sync");
// Calls sync to explicitly flush the dirty pages now
xous_swapper::sync(Some(&spislice[4096 / size_of::<u32>()..(4096 / size_of::<u32>()) + 4]));
// xous_swapper::sync::<u8>(None);
log::info!("sync call done");
log::info!("end spi flash map test");
loop {}
const DELAY_MS: u64 = 1000;
for i in 0.. {