From 0a4f8f832b24a05b608f69cf6d5646a3ebc87ef2 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sat, 14 Feb 2026 01:31:35 +0800 Subject: [PATCH 1/3] add tests to check sram glitch event triggers in baremetal --- Cargo.lock | 1 + baremetal/Cargo.toml | 1 + baremetal/src/repl.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 390e5a049..cbb3c4dc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/baremetal/Cargo.toml b/baremetal/Cargo.toml index 56e71c097..a668c16d8 100644 --- a/baremetal/Cargo.toml +++ b/baremetal/Cargo.toml @@ -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 = [ diff --git a/baremetal/src/repl.rs b/baremetal/src/repl.rs index ab314731c..7d2cefe01 100644 --- a/baremetal/src/repl.rs +++ b/baremetal/src/repl.rs @@ -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 From 7d6272fc8afb15fcd9697d2455560e1a6c68009c Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 18 Feb 2026 21:20:41 +0800 Subject: [PATCH 2/3] fix formatting regression --- xtask/src/versioning.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/xtask/src/versioning.rs b/xtask/src/versioning.rs index 26195f83e..984badeb4 100644 --- a/xtask/src/versioning.rs +++ b/xtask/src/versioning.rs @@ -19,16 +19,9 @@ pub(crate) fn generate_version(add_timestamp: bool, forced_version: Option Date: Wed, 18 Feb 2026 21:22:47 +0800 Subject: [PATCH 3/3] fix CI to run on dev branch as well as main --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afb5e78dc..6acb8de85 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,11 @@ on: push: branches: - main + - dev pull_request: branches: - main + - dev name: Build xous-core