mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
Merge pull request #829 from betrusted-io/dabao-tester
More tester code
This commit is contained in:
commit
a846f680a8
6 changed files with 51 additions and 27 deletions
|
|
@ -398,7 +398,7 @@ impl Repl {
|
|||
|
||||
// this routine is used to initialize baosec products - sets the board type and
|
||||
// erases the off-chip FLASH
|
||||
use bao1x_api::{baosec::PDDB_LEN, baosec::PDDB_ORIGIN};
|
||||
use bao1x_api::baosec::PDDB_ORIGIN;
|
||||
use bao1x_hal::{
|
||||
board::SPINOR_BULK_ERASE_SIZE,
|
||||
ifram::IframRange,
|
||||
|
|
@ -446,8 +446,15 @@ impl Repl {
|
|||
return Err(Error::help("Supported SPI device not found. Aborting operation."));
|
||||
}
|
||||
|
||||
crate::println!("Erasing from {:x}-{:x}...", 0, PDDB_ORIGIN + PDDB_LEN);
|
||||
for addr in (0..PDDB_ORIGIN + PDDB_LEN).step_by(SPINOR_BULK_ERASE_SIZE as usize) {
|
||||
crate::println!("Erasing headers...");
|
||||
for addr in (0..SPINOR_BULK_ERASE_SIZE as usize * 2).step_by(SPINOR_BULK_ERASE_SIZE as usize)
|
||||
{
|
||||
crate::println!(" {:x}...", addr);
|
||||
flash_spim.flash_erase_block(addr, SPINOR_BULK_ERASE_SIZE as usize);
|
||||
}
|
||||
for addr in (PDDB_ORIGIN..PDDB_ORIGIN + SPINOR_BULK_ERASE_SIZE as usize * 2)
|
||||
.step_by(SPINOR_BULK_ERASE_SIZE as usize)
|
||||
{
|
||||
crate::println!(" {:x}...", addr);
|
||||
flash_spim.flash_erase_block(addr, SPINOR_BULK_ERASE_SIZE as usize);
|
||||
}
|
||||
|
|
@ -485,15 +492,13 @@ impl Repl {
|
|||
#[cfg(not(feature = "oem-baosec-lite"))]
|
||||
{
|
||||
crate::println!("{}BOOT1.SETBOARD,{}", BOOKEND_START, BOOKEND_END);
|
||||
crate::println!("Board type set to baosec, rebooting so boot1 can provision keys!");
|
||||
crate::println!("Board type set to baosec");
|
||||
}
|
||||
#[cfg(feature = "oem-baosec-lite")]
|
||||
{
|
||||
crate::println!("Board type set to baosec-lite, rebooting so boot1 can provision keys!");
|
||||
crate::println!("Board type set to baosec-lite");
|
||||
crate::println!("{}BOOT1.SETBOARD-LITE,{}", BOOKEND_START, BOOKEND_END);
|
||||
}
|
||||
let mut rcurst = CSR::new(utra::sysctrl::HW_SYSCTRL_BASE as *mut u32);
|
||||
rcurst.wo(utra::sysctrl::SFR_RCURST0, 0x55AA);
|
||||
}
|
||||
"ifr" => {
|
||||
// safety: the IFR region is aligned and exists here. It is sealed by hardware in USER mode,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateSet("baremetal", "dabao", "baosec", "bootloader", "kernel", "loader", "swap", "apps", "boot1", "alt-boot1")]
|
||||
[ValidateSet("baremetal", "dabao", "baosec", "bootloader", "kernel", "loader", "swap", "apps", "boot1", "alt-boot1", "baosec-lite")]
|
||||
[string]$Config,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
|
|
@ -44,6 +44,13 @@ $configurations = @{
|
|||
@{ Image = "xous.img"; FunctionCode = "kernel" ; TargetDir = "target\riscv32imac-unknown-xous-elf\release" }
|
||||
@{ Image = "swap.img"; FunctionCode = "swap" ; TargetDir = "target\riscv32imac-unknown-xous-elf\release" }
|
||||
)
|
||||
"baosec-lite" = @(
|
||||
@{ Image = "loader.bin"; FunctionCode = "loader" ; TargetDir = "target\riscv32imac-unknown-xous-elf\release" }
|
||||
@{ Image = "xous.img"; FunctionCode = "kernel" ; TargetDir = "target\riscv32imac-unknown-xous-elf\release" }
|
||||
@{ Image = "swap.img"; FunctionCode = "swap" ; TargetDir = "target\riscv32imac-unknown-xous-elf\release" }
|
||||
@{ Image = "bao1x-boot1.img"; FunctionCode = "boot1" ; TargetDir = "target\riscv32imac-unknown-none-elf\release" },
|
||||
@{ Image = "bao1x-alt-boot1.img"; FunctionCode = "loader" ; TargetDir = "target\riscv32imac-unknown-none-elf\release" }
|
||||
)
|
||||
"kernel" = @(
|
||||
@{ Image = "xous.img"; FunctionCode = "kernel" ; TargetDir = "target\riscv32imac-unknown-xous-elf\release" }
|
||||
)
|
||||
|
|
|
|||
|
|
@ -621,6 +621,15 @@ pub fn wrapped_main(main_thread_token: MainThreadToken) -> ! {
|
|||
// stop on the next frame.
|
||||
if let Some(mut envelope) = qr_request.take() {
|
||||
let metadata = format!("{:?}", meta);
|
||||
#[cfg(not(feature = "hosted-baosec"))]
|
||||
if content.starts_with("test://") {
|
||||
log::info!(
|
||||
"{}{},{}",
|
||||
bao1x_hal::board::BOOKEND_START,
|
||||
content,
|
||||
bao1x_hal::board::BOOKEND_END
|
||||
);
|
||||
}
|
||||
let acquisition =
|
||||
QrAcquisition { content: Some(content), meta: Some(metadata) };
|
||||
let mut response = unsafe {
|
||||
|
|
|
|||
|
|
@ -2261,7 +2261,6 @@ impl PddbOs {
|
|||
// step 1. Erase the entire PDDB region - leaves the state in all 1's
|
||||
if !fast {
|
||||
log::info!("Erasing the PDDB region");
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals
|
||||
.start_progress(
|
||||
|
|
@ -2311,7 +2310,6 @@ impl PddbOs {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals.update_progress(PDDB_A_LOC + PDDB_A_LEN as u32).expect("couldn't update progress bar");
|
||||
modals.finish_progress().expect("couldn't dismiss progress bar");
|
||||
|
|
@ -2321,7 +2319,6 @@ impl PddbOs {
|
|||
}
|
||||
|
||||
// step 2. fill in the page table with junk, which marks it as cryptographically empty
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals
|
||||
.start_progress(t!("pddb.initpt", locales::LANG), 0, size_of::<PageTableInFlash>() as u32, 0)
|
||||
|
|
@ -2337,7 +2334,6 @@ impl PddbOs {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals
|
||||
.update_progress(size_of::<PageTableInFlash>() as u32)
|
||||
|
|
@ -2355,7 +2351,6 @@ impl PddbOs {
|
|||
}
|
||||
self.patch_pagetable_raw(&temp, remainder_start as u32);
|
||||
}
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals.finish_progress().expect("couldn't dismiss progress bar");
|
||||
#[cfg(feature = "ux-swap-delay")]
|
||||
|
|
@ -2367,7 +2362,6 @@ impl PddbOs {
|
|||
//if !self.rootkeys.ensure_aes_password() {
|
||||
// return Err(Error::new(ErrorKind::PermissionDenied, "unlock password was incorrect"));
|
||||
//}
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals
|
||||
.start_progress(t!("pddb.key", locales::LANG), 0, 100, 0)
|
||||
|
|
@ -2394,7 +2388,6 @@ impl PddbOs {
|
|||
self.system_basis_key = Some(BasisKeys { pt: system_basis_key_pt, data: system_basis_key }); // this causes system_basis_key to be owned by self and go out of scope
|
||||
let mut crypto_keys = StaticCryptoData::default();
|
||||
crypto_keys.version = SCD_VERSION; // should already be set by `default()` but let's be sure.
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals.update_progress(50).expect("couldn't update progress bar");
|
||||
#[cfg(feature = "ux-swap-delay")]
|
||||
|
|
@ -2414,7 +2407,6 @@ impl PddbOs {
|
|||
self.entropy.borrow_mut().get_slice(&mut crypto_keys.salt_base);
|
||||
// commit keys
|
||||
self.patch_keys(crypto_keys.deref(), 0);
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals.update_progress(100).expect("couldn't update progress bar");
|
||||
#[cfg(feature = "ux-swap-delay")]
|
||||
|
|
@ -2436,7 +2428,6 @@ impl PddbOs {
|
|||
// step 5. fscb handling
|
||||
// pick a set of random pages from the free pool and assign it to the fscb
|
||||
// pass the generator an empty cache - this causes it to treat the entire disk as free space
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals
|
||||
.start_progress(t!("pddb.fastspace", locales::LANG), 0, 100, 0)
|
||||
|
|
@ -2448,7 +2439,6 @@ impl PddbOs {
|
|||
for (&src, dst) in free_pool.iter().zip(fast_space.free_pool.iter_mut()) {
|
||||
*dst = src;
|
||||
}
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals.update_progress(50).expect("couldn't update progress bar");
|
||||
#[cfg(feature = "ux-swap-delay")]
|
||||
|
|
@ -2470,7 +2460,6 @@ impl PddbOs {
|
|||
// step 5. salt the free space with random numbers. this can take a while, we might need a "progress
|
||||
// report" of some kind... this is coded using "direct disk" offsets...under the assumption
|
||||
// that we only ever really want to do this here, and not re-use this routine elsewhere.
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals
|
||||
.start_progress(
|
||||
|
|
@ -2524,7 +2513,6 @@ impl PddbOs {
|
|||
#[cfg(all(feature = "gen2", target_os = "xous"))]
|
||||
self.patch(&temp, offset);
|
||||
}
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals.update_progress(PDDB_A_LEN as u32).expect("couldn't update progress bar");
|
||||
#[cfg(feature = "ux-swap-delay")]
|
||||
|
|
@ -2535,7 +2523,6 @@ impl PddbOs {
|
|||
}
|
||||
|
||||
// step 6. create the system basis root structure
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals
|
||||
.start_progress(t!("pddb.structure", locales::LANG), 0, 100, 0)
|
||||
|
|
@ -2553,7 +2540,6 @@ impl PddbOs {
|
|||
|
||||
// step 7. Create a hashmap for our reverse PTE, allocate sectors, and add it to the Pddb's cache
|
||||
self.fast_space_read(); // we reconstitute our fspace map even though it was just generated, partially as a sanity check that everything is ok
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals.update_progress(33).expect("couldn't update progress bar");
|
||||
#[cfg(feature = "ux-swap-delay")]
|
||||
|
|
@ -2590,7 +2576,6 @@ impl PddbOs {
|
|||
let syskey = self.system_basis_key.take().unwrap(); // take the key out
|
||||
self.data_encrypt_and_patch_page_with_commit(&syskey.data, &aad, &mut block, &pp);
|
||||
self.system_basis_key = Some(syskey); // put the key back
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals.update_progress(66).expect("couldn't update progress bar");
|
||||
#[cfg(feature = "ux-swap-delay")]
|
||||
|
|
@ -2603,7 +2588,6 @@ impl PddbOs {
|
|||
// mark the entry as clean, as it has been sync'd to disk
|
||||
phys.set_clean(true);
|
||||
}
|
||||
#[cfg(feature = "gen1")]
|
||||
if let Some(modals) = progress {
|
||||
modals.update_progress(100).expect("couldn't update progress bar");
|
||||
#[cfg(feature = "ux-swap-delay")]
|
||||
|
|
|
|||
|
|
@ -813,6 +813,7 @@ fn wrapped_main() -> ! {
|
|||
false
|
||||
}
|
||||
}
|
||||
let modals = modals::Modals::new(&xns).expect("can't connect to Modals server");
|
||||
match pddb_os.ensure_password() {
|
||||
PasswordState::Correct => {
|
||||
// The behavior in gen2 is mount-or-format: no user approval
|
||||
|
|
@ -820,7 +821,7 @@ fn wrapped_main() -> ! {
|
|||
// of data corruption but I think this is the "right" user experience
|
||||
if !try_mount(&mut pddb_os, &mut basis_cache, &mut basis_monitor_notifications) {
|
||||
log::warn!("PDDB not formatted - formatting the PDDB!");
|
||||
pddb_os.pddb_format(false, None).expect("couldn't format PDDB");
|
||||
pddb_os.pddb_format(false, Some(&modals)).expect("couldn't format PDDB");
|
||||
if !try_mount(
|
||||
&mut pddb_os,
|
||||
&mut basis_cache,
|
||||
|
|
@ -832,7 +833,7 @@ fn wrapped_main() -> ! {
|
|||
}
|
||||
PasswordState::Uninit => {
|
||||
log::warn!("PDDB not formatted - formatting the PDDB!");
|
||||
pddb_os.pddb_format(false, None).expect("couldn't format PDDB");
|
||||
pddb_os.pddb_format(false, Some(&modals)).expect("couldn't format PDDB");
|
||||
if !try_mount(&mut pddb_os, &mut basis_cache, &mut basis_monitor_notifications) {
|
||||
panic!("Couldn't format & mount PDDB");
|
||||
}
|
||||
|
|
@ -842,7 +843,7 @@ fn wrapped_main() -> ! {
|
|||
}
|
||||
PasswordState::Incorrect(_failcount) => {
|
||||
log::warn!("PDDB formatted, but keys rotated. Formatting PDDB!");
|
||||
pddb_os.pddb_format(false, None).expect("couldn't format PDDB");
|
||||
pddb_os.pddb_format(false, Some(&modals)).expect("couldn't format PDDB");
|
||||
if !try_mount(&mut pddb_os, &mut basis_cache, &mut basis_monitor_notifications) {
|
||||
panic!("Couldn't format & mount PDDB");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,12 +71,30 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.required(false)
|
||||
.help("Explicit git describe version for swap signing (e.g., 'v0.10.0-19-g0d934e1'). If not specified, uses git describe."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("empty-loader")
|
||||
.long("empty-loader")
|
||||
.required(false)
|
||||
.help("When specified, creates a short loader file with all 0's as data. Used for resetting device state in CI testing.")
|
||||
)
|
||||
.get_matches();
|
||||
|
||||
let mut process_names = ProcessNames::new();
|
||||
|
||||
let mut pid: u32 = 1;
|
||||
|
||||
if matches.is_present("empty-loader") {
|
||||
let empty_uf2 = "empty.uf2";
|
||||
let empty = vec![0u8; 16384];
|
||||
let uf2_blob =
|
||||
bin_to_uf2(&empty, bao1x_api::BAOCHIP_1X_UF2_FAMILY, bao1x_api::common::LOADER_START as _)?;
|
||||
let mut f =
|
||||
File::create(empty_uf2).unwrap_or_else(|_| panic!("Couldn't create output file {}", empty_uf2));
|
||||
f.write(&uf2_blob)?;
|
||||
println!("Created empty UF2 at {}", empty_uf2);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let anti_rollback = if let Some(arb) = matches.value_of("antirollback") {
|
||||
parse_u32(arb).map_err(|_| String::from("Antirollback should be a number"))?
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue