From 68400551c590627f64c5596cd5eaa8117fa15a42 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 13 Feb 2026 02:05:09 +0800 Subject: [PATCH 1/2] cleanup warnings --- bao1x-boot/boot1/src/platform/bao1x/slots.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bao1x-boot/boot1/src/platform/bao1x/slots.rs b/bao1x-boot/boot1/src/platform/bao1x/slots.rs index bec98b8f5..be71405e3 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/slots.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/slots.rs @@ -1,5 +1,6 @@ use core::convert::TryInto; +#[allow(unused_imports)] use bao1x_api::{ CP_ID, IFR_CP_ID_BASE, IFR_HASH, SERIAL_NUMBER, SLOT_ELEMENT_LEN_BYTES, SlotIndex, SlotType, UUID, }; @@ -160,6 +161,7 @@ fn check_and_fix_acls(rram: &mut Reram, slot_mgr: &mut SlotManager, slot_list: & } } +#[cfg(feature = "print-ifr")] fn print_slots(slot_mgr: &SlotManager, slot_list: &[SlotIndex]) { for slot in slot_list.iter() { let access = slot.get_access_spec(); From f106d39d030277b238ee13c4defd79eb25181f93 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 13 Feb 2026 02:05:53 +0800 Subject: [PATCH 2/2] add die stepping detection code It occurs to me that the same boot1 code will be on both die steppings, so adding a piece of code that *should* be able to detect A0/A1 stepping - assuming the A1 stepping behaves as intended. --- bao1x-boot/boot1/src/audit.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bao1x-boot/boot1/src/audit.rs b/bao1x-boot/boot1/src/audit.rs index ea3ee63b5..9f16eb87c 100644 --- a/bao1x-boot/boot1/src/audit.rs +++ b/bao1x-boot/boot1/src/audit.rs @@ -29,6 +29,28 @@ fn hash_region(region: &[u8], description: &str) { crate::println!("{}: {}", description, hex_str); } +/// Stepping detection: attempt to modify the RRCR configuration. If bit 12 (code area protection) +/// can be flipped, then we are A0 stepping. +fn detect_stepping() -> &'static str { + use bao1x_hal::hardening::die; + let mut rram = utralib::CSR::new(utralib::utra::rrc::HW_RRC_BASE as *mut u32); + // this sets bit 12 + rram.wfo(utralib::utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE); + // attempt to clear bit 12 + rram.wfo(utralib::utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE & !(1 << 12)); + let check_val = rram.rf(utralib::utra::rrc::SFR_RRCCR_SFR_RRCCR); + let ret = if check_val != bao1x_hal::rram::SECURITY_MODE { "A0" } else { "A1" }; + // reset security mode + bollard!(die, 4); + rram.wfo(utralib::utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE); + bollard!(die, 4); + rram.wfo(utralib::utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE); + bollard!(die, 4); + rram.wfo(utralib::utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE); + bollard!(die, 4); + ret +} + pub fn audit() { let owc = OneWayCounter::new(); let boardtype = owc.get_decoded::().unwrap(); @@ -36,6 +58,7 @@ pub fn audit() { crate::println!("Boot partition is: {:?}", owc.get_decoded::()); crate::println!("Semver is: {}", crate::version::SEMVER); crate::println!("Description is: {}", crate::RELEASE_DESCRIPTION); + crate::println!("Stepping is: {}", detect_stepping()); let slot_mgr = bao1x_hal::acram::SlotManager::new(); let sn = slot_mgr.read(&bao1x_hal::board::SERIAL_NUMBER).unwrap(); crate::println!(