From c1b7612e7ec16dcccc2787f8fc10752edd70fc5c Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 10 Feb 2026 03:28:31 +0800 Subject: [PATCH] add one-way counter offset for auto-audit for the first few boots (3 in this case), automatically print an audit to the console. This is used to verify that the chip was programmed correctly in chip probe. --- libs/bao1x-api/src/lib.rs | 7 +++++++ libs/bao1x-api/src/offsets/common.rs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/libs/bao1x-api/src/lib.rs b/libs/bao1x-api/src/lib.rs index f3d199bc7..9efda4583 100644 --- a/libs/bao1x-api/src/lib.rs +++ b/libs/bao1x-api/src/lib.rs @@ -50,6 +50,13 @@ pub const SERVER_NAME_KBD: &str = "_Matrix keyboard driver_"; /// circular dependencies on the IFRAM block. pub const SERVER_NAME_BAO1X_HAL: &str = "_bao1x-SoC HAL_"; +/// Number of boots to trigger the 'audit' command. It's set to be bigger than 1, because +/// the chip tester may power cycle the chip during the provisioning process before the +/// log can be displayed. Once we have seen the actual chip tester infrastructure working, +/// we can dial this down; but 3 times should be enough for us to capture a log during +/// tester bring-up. +pub const AUTO_AUDIT_LIMIT: u32 = 3; + /// Flags register in the backup register bank. Used to track system state between soft resets. #[bitfield(u32)] #[derive(PartialEq, Eq, Debug)] diff --git a/libs/bao1x-api/src/offsets/common.rs b/libs/bao1x-api/src/offsets/common.rs index 12741c764..ca0ac9e42 100644 --- a/libs/bao1x-api/src/offsets/common.rs +++ b/libs/bao1x-api/src/offsets/common.rs @@ -66,6 +66,12 @@ macro_rules! encode_oneway { // =========== ONE WAY COUNTER SLOTS ============== +/// This is used to count the number of boots, up to a certain threshold. The main +/// purpose is to turn off the "audit" auto-print which is used to verify chip testing. +pub const EARLY_BOOT_COUNT: usize = 47; + +// gap of 8 slots [48..=55] left in case more anti-rollback slots are desired + /// Anti-rollback counters only count up and are used to note what is the minimum rollback /// version allowed for a firmware stage. Note that this is different from a semver because /// semvers can change without there being security problems. Anti-rollback counter is in