From 1a435400378c7c382333c9d3a07ef5a6f4208ebb Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 15 Feb 2026 03:34:35 +0800 Subject: [PATCH] minor improvements across boot0 flow - improve bollards to include "die" jumps where appropriate - cleanup warnings in unsafe-dev feature - panic handler calls die repeatedly - upgrade jump api --- bao1x-boot/boot0/src/main.rs | 10 +++++----- bao1x-boot/boot0/src/platform/bao1x/bao1x.rs | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/bao1x-boot/boot0/src/main.rs b/bao1x-boot/boot0/src/main.rs index fb9c2f54b..b3acc915c 100644 --- a/bao1x-boot/boot0/src/main.rs +++ b/bao1x-boot/boot0/src/main.rs @@ -75,15 +75,15 @@ pub unsafe extern "C" fn rust_entry() -> ! { csprng.random_delay(); rram.wfo(utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE); - bollard!(4); + bollard!(bao1x_hal::sigcheck::die_no_std, 4); // Mesh check takes 100ms for the signal to propagate. Setup the mesh check here, then check the // result in boot1. In boot1, the opposite state (`true`) is checked. mesh_setup(false, None); - bollard!(4); + bollard!(bao1x_hal::sigcheck::die_no_std, 4); csprng.random_delay(); - bollard!(4); + bollard!(bao1x_hal::sigcheck::die_no_std, 4); rram.wfo(utra::rrc::SFR_RRCCR_SFR_RRCCR, bao1x_hal::rram::SECURITY_MODE); - bollard!(4); + bollard!(bao1x_hal::sigcheck::die_no_std, 4); crate::println!("\n~~boot0 up! ({})~~\n", crate::version::SEMVER); csprng.random_delay(); // always random-delay after printing @@ -361,7 +361,7 @@ pub unsafe extern "C" fn rust_entry() -> ! { if use_skipping { disable_clock_skipping(); } - jump_to((target ^ u32::from_le_bytes(tag)) as usize); + jump_to(target as usize, u32::from_le_bytes(tag) as usize); } Err(e) => { crate::println!("Sigcheck err: {:?}", e); diff --git a/bao1x-boot/boot0/src/platform/bao1x/bao1x.rs b/bao1x-boot/boot0/src/platform/bao1x/bao1x.rs index 13edc71af..9c4eb7fc6 100644 --- a/bao1x-boot/boot0/src/platform/bao1x/bao1x.rs +++ b/bao1x-boot/boot0/src/platform/bao1x/bao1x.rs @@ -150,9 +150,8 @@ pub fn early_init() -> Csprng { irq_setup(); // set up the reactive sensors - bao1x_api::bollard!(4); + bollard!(die, 4); bao1x_hal::hardening::reset_sensors(); - bao1x_api::bollard!(4); bollard!(die, 4); csprng.random_delay(); // ensure paranoid mode is respected @@ -186,9 +185,9 @@ pub fn early_init() -> Csprng { // in combination with the previous check inside init_clock_asic_350mhz means you need // three successful glitches to bypass these checks: one to skip PLL setting, and one each // for the checks. There is also a random_delay() inserted between the previous check and now. - bao1x_api::bollard!(4); + bollard!(die, 4); bao1x_hal::hardening::check_pll(); - bao1x_api::bollard!(4); + bollard!(die, 4); // this is a security-critical initialization. Failure to do this correctly breaks // all the hardware hashes. It's done once, in boot0. Note that the constants *are* @@ -215,8 +214,8 @@ pub fn early_init() -> Csprng { // TxRx setup #[cfg(feature = "unsafe-dev")] - let mut udma_uart = { - let mut udma_uart = setup_rx(perclk); + let _udma_uart = { + let udma_uart = setup_rx(perclk); enable_irq(utra::irqarray5::IRQARRAY5_IRQ); udma_uart }; @@ -285,11 +284,11 @@ pub fn init_hash() { RIPMD_X.iter().chain( RAMSEG_SHA3.iter() )))))))))))); - bao1x_api::bollard!(4); + bao1x_api::bollard!(die, 4); for (dst, &src) in sce_mem.iter_mut().zip(constants) { *dst = src; } - bao1x_api::bollard!(4); + bao1x_api::bollard!(die, 4); let mut combo_hash = CSR::new(utra::combohash::HW_COMBOHASH_BASE as *mut u32); combo_hash.wo(utra::combohash::SFR_OPT3, 0); // u32 big-endian constant load combo_hash.wfo(utra::combohash::SFR_CRFUNC_CR_FUNC, HashFunction::Init as u32); @@ -335,7 +334,9 @@ mod panic_handler { #[panic_handler] fn handle_panic(_arg: &PanicInfo) -> ! { crate::println!("{}", _arg); - loop {} + loop { + bao1x_hal::sigcheck::die_no_std(); + } } }