fix altboot issues

- don't slot-check in altboot (altboot actually runs in a security
environment that doesn't have boot privileges)
- force bootwait ON by default if altboot is entered - otherwise
we enter a boot-loop
- update release description as towards beta-0
This commit is contained in:
bunnie 2025-11-25 00:15:36 +08:00
parent 6614cbe2a4
commit b12ce104ec
3 changed files with 16 additions and 13 deletions

View file

@ -45,7 +45,6 @@ print-ifr = []
test-boot0-keys = []
alt-boot1 = []
force-dabao = []
verilator-only = []
default = []

View file

@ -32,7 +32,7 @@ use crate::secboot::try_boot;
// Notes:
// - "Towards" - not a release yet, but working towards the stated milestone
// - Eliminating "Towards" is done at the tag-out point.
const RELEASE_DESCRIPTION: &'static str = "Alpha-1";
const RELEASE_DESCRIPTION: &'static str = "Towards Beta-0";
static UART_RX: Mutex<RefCell<VecDeque<u8>>> = Mutex::new(RefCell::new(VecDeque::new()));
#[allow(dead_code)]
@ -83,19 +83,19 @@ pub unsafe extern "C" fn rust_entry() -> ! {
#[cfg(feature = "alt-boot1")]
crate::println!("\n~~Alt-Boot1 up! ({}: {})~~\n", crate::version::SEMVER, RELEASE_DESCRIPTION);
crate::println!("Configured board type: {:?}", board_type);
#[cfg(feature = "alt-boot1")]
{
// in alt-boot1, always enable bootwait - otherwise we enter a boot loop
while one_way.get_decoded::<bao1x_api::BootWaitCoding>().expect("couldn't fetch flag")
!= bao1x_api::BootWaitCoding::Enable
{
one_way.inc_coded::<bao1x_api::BootWaitCoding>().unwrap();
}
}
if board_type == BoardTypeCoding::Baosec {
IS_BAOSEC.store(true, Ordering::SeqCst);
#[cfg(all(feature = "force-dabao", feature = "alt-boot1"))]
{
while one_way.get_decoded::<bao1x_api::BoardTypeCoding>().expect("owc coding error")
!= bao1x_api::BoardTypeCoding::Dabao
{
one_way.inc_coded::<bao1x_api::BoardTypeCoding>().expect("increment error");
}
board_type = one_way.get_decoded::<bao1x_api::BoardTypeCoding>().expect("owc coding error");
crate::println!("Re-configured board type: {:?}", board_type);
IS_BAOSEC.store(false, Ordering::SeqCst);
}
}
let iox = Iox::new(utra::iox::HW_IOX_BASE as *mut u32);

View file

@ -66,6 +66,7 @@ pub fn setup_dabao_se0_pin<T: IoSetup + IoGpio>(iox: &T) -> (IoxPort, u8) {
(DABAO_SE0_PORT, DABAO_SE0_PIN)
}
#[cfg(not(feature = "alt-boot1"))]
pub fn setup_backup_region() -> u32 {
let mut bu_mgr = bao1x_hal::buram::BackupManager::new();
if !bu_mgr.is_backup_valid() {
@ -139,6 +140,7 @@ 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!");
}
@ -331,6 +333,8 @@ pub fn early_init(mut board_type: bao1x_api::BoardTypeCoding) -> (bao1x_api::Boa
let mut cu = bao1x_hal::coreuser::Coreuser::new();
// Coreuser needs to be set up correctly for check_slots to succeed.
cu.set();
// can't check slots in alt-boot mode because it's effectively baremetal as far as permissions go
#[cfg(not(feature = "alt-boot1"))]
crate::platform::slots::check_slots(&board_type);
// protect() is called inside sigcheck on boot!