From e47ed41726a990bca01c644b31b2c1c1bacdd5cd Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 16 May 2025 19:04:12 +0800 Subject: [PATCH] add some prelim test routines for flash access --- services/bao-console/Cargo.toml | 1 + services/bao-console/src/main.rs | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/services/bao-console/Cargo.toml b/services/bao-console/Cargo.toml index dfc7f5057..f78315784 100644 --- a/services/bao-console/Cargo.toml +++ b/services/bao-console/Cargo.toml @@ -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 } diff --git a/services/bao-console/src/main.rs b/services/bao-console/src/main.rs index 8185cf467..0dcf9607d 100644 --- a/services/bao-console/src/main.rs +++ b/services/bao-console/src/main.rs @@ -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::(None); + + log::info!("end spi flash map test"); + #[cfg(feature = "test-scrollbars")] { let mut sl_binding = ux_api::widgets::ScrollableList::default();