From 1faaf2c0924461861732133a00507c6fc2216ed0 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 22 May 2024 18:15:03 +0800 Subject: [PATCH] note timeouts on read in the HAL driver --- .../xous-swapper/src/platform/cramium/hw.rs | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/services/xous-swapper/src/platform/cramium/hw.rs b/services/xous-swapper/src/platform/cramium/hw.rs index 7f4b67474..3e6f4a0d8 100644 --- a/services/xous-swapper/src/platform/cramium/hw.rs +++ b/services/xous-swapper/src/platform/cramium/hw.rs @@ -110,12 +110,29 @@ impl SwapHal { nonce[9..12].copy_from_slice(&(vpage_masked as u32).to_be_bytes()[..3]); let aad: &[u8] = &[]; let mut tag = [0u8; size_of::()]; - self.ram_spim.mem_read( + if !self.ram_spim.mem_read( (self.swap_mac_start + (src_offset / PAGE_SIZE) * size_of::()) as u32, &mut tag, false, - ); - self.ram_spim.mem_read(src_offset as u32, buf, false); + ) { + writeln!( + DebugUart {}, + "Read timeout of MAC at offset {:x}; data result: {:x?}", + (self.swap_mac_start + (src_offset / PAGE_SIZE) * size_of::()) as u32, + &tag + ) + .ok(); + } + if !self.ram_spim.mem_read(src_offset as u32, buf, false) { + writeln!( + DebugUart {}, + "Read timeout of data at offset {:x}; data result: {:x?} .. {:x?}", + (self.swap_mac_start + (src_offset / PAGE_SIZE) * size_of::()) as u32, + &buf[..16], + &buf[buf.len() - 16..] + ) + .ok(); + }; self.cipher.decrypt_in_place_detached(Nonce::from_slice(&nonce), aad, buf, (&tag).into()) } }