make the flash test optional based on the configuration

allow the console to be built for hosted targets
This commit is contained in:
bunnie 2025-05-18 09:25:01 +08:00
parent 7947949589
commit 4251686c1f
2 changed files with 36 additions and 31 deletions

View file

@ -22,7 +22,7 @@ usb-cramium = { path = "../usb-cramium" }
modals = { path = "../modals", default-features = false } modals = { path = "../modals", default-features = false }
ux-api = { path = "../../libs/ux-api", optional = true } ux-api = { path = "../../libs/ux-api", optional = true }
pddb = { path = "../pddb", optional = true } pddb = { path = "../pddb", optional = true }
xous-swapper = { path = "../xous-swapper" } xous-swapper = { path = "../xous-swapper", optional = true }
# pddb testing # pddb testing
rand = { version = "0.8.5", features = ["getrandom"], optional = true } rand = { version = "0.8.5", features = ["getrandom"], optional = true }
@ -40,6 +40,7 @@ board-baosec = [
"cramium-hal", "cramium-hal",
"usb-cramium/board-baosec", "usb-cramium/board-baosec",
"pddb/board-baosec", "pddb/board-baosec",
"xous-swapper",
] ]
hosted-baosec = [ hosted-baosec = [
"modals/hosted-baosec", "modals/hosted-baosec",
@ -54,4 +55,5 @@ test-rekey = []
autobasis = ["rand_chacha", "rand"] autobasis = ["rand_chacha", "rand"]
modal-testing = ["ux-api", "modals/modal-testing"] modal-testing = ["ux-api", "modals/modal-testing"]
test-scrollbars = [] test-scrollbars = []
default = [] test-flash = []
default = ["test-flash"]

View file

@ -3,7 +3,6 @@ mod repl;
mod shell; mod shell;
use cmds::*; use cmds::*;
use xous_swapper::FlashPage;
fn main() { fn main() {
log_server::init_wait().unwrap(); log_server::init_wait().unwrap();
@ -15,36 +14,40 @@ fn main() {
tt.sleep_ms(4000).ok(); tt.sleep_ms(4000).ok();
log::info!("start spi flash map test"); #[cfg(all(feature = "board-baosec", feature = "test-flash"))]
let swapper = xous_swapper::Swapper::new().unwrap(); {
log::info!("got handle on swapper object"); use xous_swapper::FlashPage;
let mut spimap = xous::map_memory( log::info!("start spi flash map test");
None, let swapper = xous_swapper::Swapper::new().unwrap();
xous::MemoryAddress::new(xous::arch::MMAP_VIRT_BASE), log::info!("got handle on swapper object");
cramium_hal::board::SPINOR_LEN as usize, let mut spimap = xous::map_memory(
xous::MemoryFlags::R | xous::MemoryFlags::W | xous::MemoryFlags::VIRT, None,
) xous::MemoryAddress::new(xous::arch::MMAP_VIRT_BASE),
.expect("couldn't map spi range"); cramium_hal::board::SPINOR_LEN as usize,
log::info!("spimap: {:x?}", spimap); xous::MemoryFlags::R | xous::MemoryFlags::W | xous::MemoryFlags::VIRT,
// we have the mapping, now try to dereference it and read something to test it )
let spislice: &mut [u8] = unsafe { spimap.as_slice_mut() }; .expect("couldn't map spi range");
// this should trigger the page fault and thus the handler log::info!("spimap: {:x?}", spimap);
log::info!("spislice read 0..64: {:x?}", &spislice[..64]); // we have the mapping, now try to dereference it and read something to test it
log::info!("spislice read 256..264: {:x?}", &spislice[256..264]); let spislice: &mut [u8] = unsafe { spimap.as_slice_mut() };
let test_start = 8192 * 1024 + 4096; // this should trigger the page fault and thus the handler
log::info!("spislice read 8M: {:x?}", &spislice[test_start..test_start + 16]); log::info!("spislice read 0..64: {:x?}", &spislice[..64]);
log::info!("spislice read 256..264: {:x?}", &spislice[256..264]);
let test_start = 8192 * 1024 + 4096;
log::info!("spislice read 8M: {:x?}", &spislice[test_start..test_start + 16]);
let mut fp = FlashPage::new(); let mut fp = FlashPage::new();
fp.data.copy_from_slice(&spislice[test_start..test_start + 4096]); fp.data.copy_from_slice(&spislice[test_start..test_start + 4096]);
for (i, d) in fp.data[..32].iter_mut().enumerate() { for (i, d) in fp.data[..32].iter_mut().enumerate() {
*d = 128u8 - i as u8; *d = 128u8 - i as u8;
}
swapper
.write_page(spislice[test_start..test_start + 32].as_ptr() as usize, fp)
.expect("couldn't write page");
log::info!("spislice read 8M (again): {:x?}", &spislice[test_start..test_start + 16]);
log::info!("end spi flash map test");
} }
swapper
.write_page(spislice[test_start..test_start + 32].as_ptr() as usize, fp)
.expect("couldn't write page");
log::info!("spislice read 8M (again): {:x?}", &spislice[test_start..test_start + 16]);
log::info!("end spi flash map test");
#[cfg(feature = "test-scrollbars")] #[cfg(feature = "test-scrollbars")]
{ {