mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add more annotations & set bootwait on setting board type
bootwait allows automation to load the swap image after the board type is set correctly breaks the paradox that you can't init swap on a blank chip because it doesn't know it has swap
This commit is contained in:
parent
b587f63279
commit
3893bc78a7
3 changed files with 28 additions and 17 deletions
|
|
@ -93,6 +93,8 @@ pub mod swap;
|
|||
use core::{mem, ptr, slice};
|
||||
|
||||
use asm::*;
|
||||
#[cfg(feature = "bao1x")]
|
||||
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
||||
use bootconfig::BootConfig;
|
||||
use consts::*;
|
||||
pub use loader::*;
|
||||
|
|
@ -285,18 +287,16 @@ pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32)
|
|||
// out at this point. Thus, ensure that the system is already in developer mode.
|
||||
let owc = bao1x_hal::acram::OneWayCounter::new();
|
||||
if owc.get(bao1x_api::DEVELOPER_MODE).unwrap() == 0 {
|
||||
crate::println!(
|
||||
"Kernel is devkey signed, but system is not in developer mode. Dying!"
|
||||
);
|
||||
println!("{}LOADER.KERNDIE,{}", BOOKEND_START, BOOKEND_END);
|
||||
println!("Kernel is devkey signed, but system is not in developer mode. Dying!");
|
||||
bao1x_hal::sigcheck::die_no_std();
|
||||
} else {
|
||||
crate::println!("Developer key detected on kernel. Proceeding in developer mode!");
|
||||
println!("{}LOADER.KERNDEV,{}", BOOKEND_START, BOOKEND_END);
|
||||
println!("Developer key detected on kernel. Proceeding in developer mode!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
||||
|
||||
println!("Kernel failed signature check. Dying: {:?}", e);
|
||||
println!("{}LOADER.KERNFAIL,{}", BOOKEND_START, BOOKEND_END);
|
||||
bao1x_hal::sigcheck::die_no_std();
|
||||
|
|
@ -331,19 +331,20 @@ pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32)
|
|||
// out at this point. Thus, ensure that the system is already in developer mode.
|
||||
let owc = bao1x_hal::acram::OneWayCounter::new();
|
||||
if owc.get(bao1x_api::DEVELOPER_MODE).unwrap() == 0 {
|
||||
crate::println!(
|
||||
println!("{}LOADER.APPDIE,{}", BOOKEND_START, BOOKEND_END);
|
||||
println!(
|
||||
"Detached app is devkey signed, but system is not in developer mode. Dying!"
|
||||
);
|
||||
bao1x_hal::sigcheck::die_no_std();
|
||||
} else {
|
||||
crate::println!(
|
||||
"Developer key detected on detached app. Proceeding in developer mode!"
|
||||
);
|
||||
println!("{}LOADER.APPDEV,{}", BOOKEND_START, BOOKEND_END);
|
||||
println!("Developer key detected on detached app. Proceeding in developer mode!");
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
Err(_e) => {
|
||||
println!("{}LOADER.APPFAIL,{}", BOOKEND_START, BOOKEND_END);
|
||||
println!("No valid detached app found");
|
||||
false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,12 +108,21 @@ pub fn early_init_hw() -> u32 {
|
|||
let board_type =
|
||||
one_way.get_decoded::<bao1x_api::BoardTypeCoding>().expect("Board type coding error");
|
||||
if board_type != bao1x_api::BoardTypeCoding::Baosec {
|
||||
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
||||
|
||||
crate::println!("Board type is not Baosec; resetting it and rebooting!");
|
||||
while one_way.get_decoded::<bao1x_api::BoardTypeCoding>().expect("owc coding error")
|
||||
!= bao1x_api::BoardTypeCoding::Baosec
|
||||
{
|
||||
one_way.inc_coded::<bao1x_api::BoardTypeCoding>().expect("increment error");
|
||||
}
|
||||
// set bootwait, because we need to provision swap
|
||||
while one_way.get_decoded::<bao1x_api::BootWaitCoding>().expect("owc coding error")
|
||||
!= bao1x_api::BootWaitCoding::Enable
|
||||
{
|
||||
one_way.inc_coded::<bao1x_api::BootWaitCoding>().expect("increment error");
|
||||
}
|
||||
crate::println!("{}LOADER.SETBOARD,{}", BOOKEND_START, BOOKEND_END);
|
||||
crate::println!("Board type set to baosec, rebooting so boot1 can provision keys!");
|
||||
let mut rcurst = CSR::new(utra::sysctrl::HW_SYSCTRL_BASE as *mut u32);
|
||||
rcurst.wo(utra::sysctrl::SFR_RCURST0, 0x55AA);
|
||||
|
|
|
|||
|
|
@ -261,22 +261,22 @@ impl SwapHal {
|
|||
// ensure that the system is already in developer mode.
|
||||
let owc = bao1x_hal::acram::OneWayCounter::new();
|
||||
if owc.get(bao1x_api::DEVELOPER_MODE).unwrap() == 0 {
|
||||
crate::println!(
|
||||
println!("{}LOADER.SWAPDIE,{}", BOOKEND_START, BOOKEND_END);
|
||||
println!(
|
||||
"Swap is devkey signed, but system is not in developer mode. Dying!"
|
||||
);
|
||||
bao1x_hal::sigcheck::die_no_std();
|
||||
} else {
|
||||
crate::println!(
|
||||
println!("{}LOADER.SWAPDEV,{}", BOOKEND_START, BOOKEND_END);
|
||||
println!(
|
||||
"Developer key detected on swap. Proceeding in developer mode!"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
crate::println!(
|
||||
"Fresh swap image did not pass public key validation: {:?}",
|
||||
e
|
||||
);
|
||||
println!("{}LOADER.SWAPSIGFAIL,{}", BOOKEND_START, BOOKEND_END);
|
||||
println!("Fresh swap image did not pass public key validation: {:?}", e);
|
||||
bao1x_hal::sigcheck::die_no_std();
|
||||
}
|
||||
}
|
||||
|
|
@ -288,7 +288,8 @@ impl SwapHal {
|
|||
// replace the cipher with the new key
|
||||
hal.src_cipher = Aes256GcmSiv::new((*swap_key).into());
|
||||
if hal.decrypt_src_page_at(0).is_err() {
|
||||
crate::println!("Swap image failed cryptographic integrity checks!");
|
||||
println!("{}LOADER.SWAPDECFAIL,{}", BOOKEND_START, BOOKEND_END);
|
||||
println!("Swap image failed cryptographic integrity checks!");
|
||||
bao1x_hal::sigcheck::die_no_std();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue