mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
Merge pull request #823 from betrusted-io/sram-tests
add tests to check sram glitch event triggers in baremetal
This commit is contained in:
commit
a56ed768e8
4 changed files with 30 additions and 0 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -2,9 +2,11 @@ on:
|
|||
push:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- dev
|
||||
|
||||
name: Build xous-core
|
||||
|
||||
|
|
|
|||
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -614,6 +614,7 @@ dependencies = [
|
|||
"critical-section",
|
||||
"digest 0.10.7",
|
||||
"ed25519-dalek-bao1x",
|
||||
"hex 0.4.3",
|
||||
"hex-literal 1.0.0",
|
||||
"linked_list_allocator",
|
||||
"riscv",
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ base64 = { version = "0.22.1", optional = true, default-features = false, featur
|
|||
] }
|
||||
sha2-bao1x = { path = "../bao1x-boot/sha2-bao1x", optional = true, default-features = false }
|
||||
hex-literal = "1.0.0"
|
||||
hex = { version = "0.4.3", default-features = false }
|
||||
|
||||
[features]
|
||||
artybio = [
|
||||
|
|
|
|||
|
|
@ -1205,6 +1205,27 @@ impl Repl {
|
|||
}
|
||||
}
|
||||
"sensor" => {
|
||||
use core::convert::TryInto;
|
||||
|
||||
use digest::Digest;
|
||||
use sha2_bao1x::Sha512;
|
||||
fn hash_region(region: &[u8]) -> [u8; 128] {
|
||||
let mut hasher = Sha512::new();
|
||||
hasher.update(®ion);
|
||||
let digest: [u8; 64] = hasher.finalize().try_into().unwrap();
|
||||
let mut buffer = [0u8; 128];
|
||||
hex::encode_to_slice(digest, &mut buffer).unwrap();
|
||||
buffer
|
||||
}
|
||||
// hash a ~1.5M region of RAM, avoiding stack/heap areas
|
||||
let mem_region = unsafe { core::slice::from_raw_parts(0x6101_0000 as *const u8, 0x1D_0000) };
|
||||
let init_hash = hash_region(&mem_region);
|
||||
let init_str = core::str::from_utf8(&init_hash).unwrap();
|
||||
crate::println!("init hash: {}", init_str);
|
||||
|
||||
let sramtrm = CSR::new(utra::coresub_sramtrm::HW_CORESUB_SRAMTRM_BASE as *mut u32);
|
||||
crate::println!("sramsec: {:x}", sramtrm.r(utra::coresub_sramtrm::SFR_RAMSEC));
|
||||
|
||||
let mut sensor = CSR::new(utra::sensorc::HW_SENSORC_BASE as *mut u32);
|
||||
let mut irq13 = CSR::new(utra::irqarray13::HW_IRQARRAY13_BASE as *mut u32);
|
||||
let mut irq15 = CSR::new(utra::irqarray15::HW_IRQARRAY15_BASE as *mut u32);
|
||||
|
|
@ -1271,6 +1292,11 @@ impl Repl {
|
|||
crate::println!("irq15: {:x}", cur_irq15);
|
||||
last_irq15 = cur_irq15;
|
||||
}
|
||||
let check_hash = hash_region(&mem_region);
|
||||
if check_hash != init_hash {
|
||||
let check_str = core::str::from_utf8(&check_hash).unwrap();
|
||||
crate::println!("check hash: {}", check_str);
|
||||
}
|
||||
critical_section::with(|cs| {
|
||||
if crate::USB_RX.borrow(cs).borrow().len() > 0
|
||||
|| crate::UART_RX.borrow(cs).borrow().len() > 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue