mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
commit
c7a94a7899
5 changed files with 102 additions and 34 deletions
|
|
@ -515,7 +515,7 @@ impl Repl {
|
||||||
}
|
}
|
||||||
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
||||||
crate::println!(
|
crate::println!(
|
||||||
"{}PUB_MUT,{},{}",
|
"{}SEC.PUBMUT-{},{}",
|
||||||
BOOKEND_START,
|
BOOKEND_START,
|
||||||
if pass { "PASS" } else { "FAIL" },
|
if pass { "PASS" } else { "FAIL" },
|
||||||
BOOKEND_END
|
BOOKEND_END
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,8 @@ dabao-selftest = [
|
||||||
"xous-bio-bdma/baremetal",
|
"xous-bio-bdma/baremetal",
|
||||||
"xous-bio-bdma/bao1x",
|
"xous-bio-bdma/bao1x",
|
||||||
]
|
]
|
||||||
test-boot0-writeprotect = []
|
ci-security = []
|
||||||
spim-tests = []
|
spim-tests = []
|
||||||
|
|
||||||
verilator-only = []
|
verilator-only = []
|
||||||
default = ["bao1x-usb"]
|
default = ["bao1x-usb", "ci-security"]
|
||||||
|
|
|
||||||
|
|
@ -66,33 +66,6 @@ pub unsafe extern "C" fn rust_entry() -> ! {
|
||||||
crate::platform::early_init();
|
crate::platform::early_init();
|
||||||
crate::println!("\n~~Baremetal up!~~\n");
|
crate::println!("\n~~Baremetal up!~~\n");
|
||||||
|
|
||||||
// Test code for figuring out if boot0 write-protect is working or not.
|
|
||||||
// Keep this around because it's a quick test to make sure that the fuses were set correctly
|
|
||||||
// on a device.
|
|
||||||
//
|
|
||||||
// The test only passes when the IFR protection bits are set.
|
|
||||||
// Also, this only works once we're in baremetal - boot0 can always write boot0, and
|
|
||||||
// the coreuser setup doesn't take us out of boot0 until this stage (note that boot1,
|
|
||||||
// despite being named this, actually operates in the boot0 privilege level).
|
|
||||||
#[cfg(feature = "test-boot0-writeprotect")]
|
|
||||||
{
|
|
||||||
crate::println!("Write protection test");
|
|
||||||
let mut rram = bao1x_hal::rram::Reram::new();
|
|
||||||
// boot0 should end at 0x2_0000; boot1 ends at 0x6_0000
|
|
||||||
// expected result: the first four should have the update fail
|
|
||||||
// the fifth value (in boot1) should update
|
|
||||||
let regions = [0xF000, 0x1_1000, 0x1_F000, 0x2_1000, 0x5_0000];
|
|
||||||
for (i, ®ion) in regions.iter().enumerate() {
|
|
||||||
let test_data =
|
|
||||||
unsafe { core::slice::from_raw_parts((region + utralib::HW_RERAM_MEM) as *const u8, 32) };
|
|
||||||
let base = test_data[0]; // increment whatever is in the original area
|
|
||||||
let test = [base + 1 + i as u8; 32];
|
|
||||||
crate::println!("orig ({:x}): {:x?}", region, test_data);
|
|
||||||
rram.write_slice(region, &test).unwrap();
|
|
||||||
crate::println!("update ({:x}): {:x?} vs {:x?}", region, test_data, test);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "artyvexii")]
|
#[cfg(feature = "artyvexii")]
|
||||||
crate::platform::test_virtual_memory();
|
crate::platform::test_virtual_memory();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ use alloc::vec::Vec;
|
||||||
#[cfg(feature = "bao1x")]
|
#[cfg(feature = "bao1x")]
|
||||||
use bao1x_api::*;
|
use bao1x_api::*;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
|
use bao1x_hal::board::{BOOKEND_END, BOOKEND_START};
|
||||||
|
#[allow(unused_imports)]
|
||||||
use utralib::*;
|
use utralib::*;
|
||||||
#[cfg(any(feature = "artybio", feature = "bao1x-bio"))]
|
#[cfg(any(feature = "artybio", feature = "bao1x-bio"))]
|
||||||
use xous_bio_bdma::*;
|
use xous_bio_bdma::*;
|
||||||
|
|
@ -904,6 +906,56 @@ impl Repl {
|
||||||
crate::platform::clockset_wrapper(800_000_000);
|
crate::platform::clockset_wrapper(800_000_000);
|
||||||
crate::println!("exiting wfi");
|
crate::println!("exiting wfi");
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "ci-security")]
|
||||||
|
// write protection only works after we leave the boot environment, thus it has to be tested in
|
||||||
|
// baremetal
|
||||||
|
"boot0-wp" => {
|
||||||
|
crate::println!("Write protection test");
|
||||||
|
let mut rram = bao1x_hal::rram::Reram::new();
|
||||||
|
// boot0 should end at 0x2_0000; boot1 ends at 0x6_0000
|
||||||
|
// expected result: the first four should have the update fail
|
||||||
|
// the fifth value (in boot1) should update
|
||||||
|
let regions =
|
||||||
|
[(false, 0x0), (false, 0xF000), (false, 0x1_1000), (false, 0x1_F000), (true, 0x5_F000)];
|
||||||
|
let mut passing = true;
|
||||||
|
for (i, &(writable, region)) in regions.iter().enumerate() {
|
||||||
|
let ref_data = unsafe {
|
||||||
|
core::slice::from_raw_parts((region + utralib::HW_RERAM_MEM) as *const u8, 32)
|
||||||
|
};
|
||||||
|
let base = ref_data[0]; // increment whatever is in the original area
|
||||||
|
let try_write = [base + 1 + i as u8; 32];
|
||||||
|
// crate::println!("orig ({:x}): {:x?}", region, test_data);
|
||||||
|
rram.write_slice(region, &try_write).unwrap();
|
||||||
|
if writable {
|
||||||
|
if ref_data != try_write {
|
||||||
|
crate::println!(
|
||||||
|
"Failure on writeable {:?} ({:x}): {:x?} vs {:x?}",
|
||||||
|
writable,
|
||||||
|
region,
|
||||||
|
ref_data,
|
||||||
|
try_write
|
||||||
|
);
|
||||||
|
passing = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ref_data == try_write {
|
||||||
|
crate::println!(
|
||||||
|
"Failure on writeable {:?} ({:x}): {:x?} vs {:x?}",
|
||||||
|
writable,
|
||||||
|
region,
|
||||||
|
ref_data,
|
||||||
|
try_write
|
||||||
|
);
|
||||||
|
passing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if passing {
|
||||||
|
crate::println!("{}SEC.BOOT0WP-PASS,{}", BOOKEND_START, BOOKEND_END);
|
||||||
|
} else {
|
||||||
|
crate::println!("{}SEC.BOOT0WP-FAIL,{}", BOOKEND_START, BOOKEND_END);
|
||||||
|
}
|
||||||
|
}
|
||||||
#[cfg(feature = "bao1x-trng")]
|
#[cfg(feature = "bao1x-trng")]
|
||||||
"trngro" => {
|
"trngro" => {
|
||||||
use base64::{Engine as _, engine::general_purpose};
|
use base64::{Engine as _, engine::general_purpose};
|
||||||
|
|
|
||||||
|
|
@ -768,10 +768,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// builder.add_kernel_feature("debug-swap-verbose");
|
// builder.add_kernel_feature("debug-swap-verbose");
|
||||||
// builder.add_feature("quantum-timer"); // this isn't in bao1x..
|
// builder.add_feature("quantum-timer"); // this isn't in bao1x..
|
||||||
builder.add_kernel_feature("v2p");
|
builder.add_kernel_feature("v2p");
|
||||||
match task.as_deref() {
|
builder.target_bao1x_soc();
|
||||||
Some("baosec") => builder.target_bao1x_soc(),
|
|
||||||
_ => panic!("should be unreachable"),
|
|
||||||
};
|
|
||||||
|
|
||||||
// It is important that this is the first service added, because the swapper *must* be in PID 2
|
// It is important that this is the first service added, because the swapper *must* be in PID 2
|
||||||
builder.add_service("xous-swapper", LoaderRegion::Flash);
|
builder.add_service("xous-swapper", LoaderRegion::Flash);
|
||||||
|
|
@ -792,6 +789,52 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// builder.add_feature("modal-testing");
|
// builder.add_feature("modal-testing");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some("baosec-improper-keystore") => {
|
||||||
|
let board = "board-baosec";
|
||||||
|
let sigblock_size = 0x300;
|
||||||
|
update_flash_origin(
|
||||||
|
"loader/src/platform/bao1x/link.x",
|
||||||
|
(bao1x_api::LOADER_START + sigblock_size + STATICS_LEN) as u32,
|
||||||
|
)?;
|
||||||
|
// select the board
|
||||||
|
builder.set_board(board);
|
||||||
|
builder.add_feature(board);
|
||||||
|
builder.add_loader_feature(board);
|
||||||
|
builder.add_kernel_feature(board);
|
||||||
|
builder.set_sigblock_size(sigblock_size);
|
||||||
|
|
||||||
|
let bao_rram_pkgs = [
|
||||||
|
"xous-ticktimer",
|
||||||
|
"xous-log",
|
||||||
|
"xous-names",
|
||||||
|
"usb-bao1x",
|
||||||
|
"bao1x-hal-service",
|
||||||
|
"bao-console",
|
||||||
|
"keystore", // deliberately out of order
|
||||||
|
"bao-video",
|
||||||
|
]
|
||||||
|
.to_vec();
|
||||||
|
if !builder.is_swap_set() {
|
||||||
|
// reserve 3MiB for system services: ultimately, "pddb, modals, and bao-video"
|
||||||
|
builder.set_swap(0, bao1x_api::offsets::baosec::SWAP_RAM_LEN as _);
|
||||||
|
}
|
||||||
|
builder.add_loader_feature("swap");
|
||||||
|
builder.add_kernel_feature("swap");
|
||||||
|
builder.add_feature("swap");
|
||||||
|
|
||||||
|
builder.add_loader_feature("debug-print");
|
||||||
|
builder.add_kernel_feature("v2p");
|
||||||
|
builder.target_bao1x_soc();
|
||||||
|
|
||||||
|
// It is important that this is the first service added, because the swapper *must* be in PID 2
|
||||||
|
builder.add_service("xous-swapper", LoaderRegion::Flash);
|
||||||
|
|
||||||
|
for service in bao_rram_pkgs {
|
||||||
|
builder.add_service(service, LoaderRegion::Flash);
|
||||||
|
}
|
||||||
|
builder.add_services(&get_cratespecs());
|
||||||
|
}
|
||||||
|
|
||||||
Some("dabao") => {
|
Some("dabao") => {
|
||||||
let board = "board-dabao";
|
let board = "board-dabao";
|
||||||
let sigblock_size = 0x300;
|
let sigblock_size = 0x300;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue