diff --git a/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs b/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs index a7922fbd9..81fa21c6d 100644 --- a/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs +++ b/bao1x-boot/boot1/src/platform/bao1x/bao1x.rs @@ -140,10 +140,9 @@ pub fn setup_backup_region() -> u32 { /// This can change the board type coding to a safer, simpler board type if the declared board type has /// problems booting. pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::BoardTypeCoding, u32) { - #[cfg(not(feature = "alt-boot1"))] - if setup_backup_region() == 0 { - crate::println!("backup region is clean!"); - } + // This can be used to debug stuff early on dabao, assuming boot0 setup the console UART. It normally + // does, but we leave this commented out for non-debug situations because it's a weak guarantee. + // crate::debug::USE_CONSOLE.store(true, core::sync::atomic::Ordering::SeqCst); irq_setup(); // all sensors & IRQs setup already by boot0, but it doesn't hurt to re-write these registers @@ -157,6 +156,13 @@ pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::Boa let iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32); + // this has to happen after the IRQs are enabled because if a false security alarm is triggered the + // system won't reboot properly at the end of the set_backup_region() routine + #[cfg(not(feature = "alt-boot1"))] + if setup_backup_region() == 0 { + crate::println!("backup region is clean!"); + } + // setup board-specific I/Os - early boot set. These are items that have to be // done in a time-sensitive fashion. match board_type { diff --git a/baosign.ps1 b/baosign.ps1 index 02a2fa240..e3e03e636 100644 --- a/baosign.ps1 +++ b/baosign.ps1 @@ -16,7 +16,7 @@ param( [string]$CredentialFile = "beta.json", [Parameter(Mandatory = $false)] - [string]$Target = "bunnie@10.0.245.183:code/jtag-tools/" + [string]$Target = "bunnie@10.0.245.50:code/csp-tool/" ) # Configuration diff --git a/loader/src/main.rs b/loader/src/main.rs index 718988f3e..21a8021f3 100644 --- a/loader/src/main.rs +++ b/loader/src/main.rs @@ -300,14 +300,13 @@ pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32) csprng.random_delay(); bollard!(bao1x_hal::sigcheck::die_no_std, 4); // this has to gate on keys being initialized, because without key setup nothing gets erased - if (tag == *bao1x_api::pubkeys::KEYSLOT_INITIAL_TAGS[bao1x_api::pubkeys::DEVELOPER_KEY_SLOT] - || key == bao1x_api::pubkeys::DEVELOPER_KEY_SLOT) - && (init1 != 0) + if tag == *bao1x_api::pubkeys::KEYSLOT_INITIAL_TAGS[bao1x_api::pubkeys::DEVELOPER_KEY_SLOT] + || key == bao1x_api::pubkeys::DEVELOPER_KEY_SLOT { csprng.random_delay(); let erase_proof: &[u8; 32] = backup.get_slice(ERASURE_PROOF_RANGE_BYTES).try_into().unwrap(); - if dev_mode1 == 0 || erase_proof != &[ERASE_VALUE; 32] { + if dev_mode1 == 0 || (erase_proof != &[ERASE_VALUE; 32]) && (init1 != 0) { if paranoid1 == 0 && paranoid2 == 0 { println!("{}LOADER.KERNDIE,{}", BOOKEND_START, BOOKEND_END); println!("Kernel is devkey signed, but system is not in developer mode. Dying!"); @@ -322,11 +321,11 @@ pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32) // this consumes dev_mode2 & !k2 - the alternate version - preventing the check from being // optimized out bollard!(bao1x_hal::sigcheck::die_no_std, 4); - if (!key_inv == bao1x_api::pubkeys::DEVELOPER_KEY_SLOT) && (init2 != 0) { + if !key_inv == bao1x_api::pubkeys::DEVELOPER_KEY_SLOT { csprng.random_delay(); let erase_proof: &[u8; 32] = backup.get_slice(ERASURE_PROOF_RANGE_BYTES).try_into().unwrap(); - if dev_mode2 == 0 || erase_proof != &[ERASE_VALUE; 32] { + if dev_mode2 == 0 || (erase_proof != &[ERASE_VALUE; 32] && (init2 != 0)) { if paranoid1 == 0 && paranoid2 == 0 { println!("{}LOADER.KERNDIE,{}", BOOKEND_START, BOOKEND_END); println!("Kernel is devkey signed, but system is not in developer mode. Dying!");