Merge pull request #733 from betrusted-io/more-fixes

More CI fixes
This commit is contained in:
bunnie 2025-11-19 14:12:02 +08:00 committed by GitHub
commit b1be9e6d3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 101 additions and 16 deletions

1
Cargo.lock generated
View file

@ -456,6 +456,7 @@ dependencies = [
"num-derive 0.4.2",
"num-traits",
"rand 0.8.5",
"rand_chacha 0.3.1",
"rand_core 0.6.4",
"rkyv 0.8.8",
"ux-api",

View file

@ -1,6 +1,17 @@
# Xous Core
Core files for the Xous microkernel operating system.
Xous is a microkernel operating system written in pure Rust, built for high-assurance applications.
Key features:
- Hardware memory protection
- Virtual memory via MMU
- Each process has an isolated address space
- `std` support in stable Rust (tier-3 Rust target)
- Asynchronous message passing
- Minimal code base
- [Microkernel](./kernel) architecture
- System [services](./services) live in userland
- Targeted at high-assurance embedded applications
The [Xous Book](https://betrusted.io/xous-book/) covers the architecture and structure of the kernel.

View file

@ -1195,6 +1195,64 @@ impl Repl {
}
crate::println!("...done!");
}
#[cfg(feature = "board-baosec")]
"erase_swap" => {
use bao1x_api::{baosec::PDDB_LEN, baosec::PDDB_ORIGIN};
use bao1x_hal::{
board::SPINOR_BULK_ERASE_SIZE,
ifram::IframRange,
iox::Iox,
udma::{Spim, *},
};
let perclk = 100_000_000;
let udma_global = GlobalConfig::new();
// setup the I/O pins
let iox = Iox::new(utralib::generated::HW_IOX_BASE as *mut u32);
let channel = bao1x_hal::board::setup_memory_pins(&iox);
udma_global.clock_on(PeriphId::from(channel));
// safety: this is safe because clocks have been set up
let mut flash_spim = unsafe {
Spim::new_with_ifram(
channel,
// has to be half the clock frequency reaching the block, but
// run it as fast
// as we can run perclk
perclk / 4,
perclk / 2,
SpimClkPol::LeadingEdgeRise,
SpimClkPha::CaptureOnLeading,
SpimCs::Cs0,
0,
0,
None,
256 + 16, /* just enough space to send commands + programming
* page */
4096,
Some(6),
Some(SpimMode::Standard), // guess Standard
IframRange::from_raw_parts(
bao1x_hal::board::SPIM_FLASH_IFRAM_ADDR,
bao1x_hal::board::SPIM_FLASH_IFRAM_ADDR,
4096 * 2,
),
)
};
flash_spim.identify_flash_reset_qpi();
let flash_id = flash_spim.mem_read_id_flash();
crate::println!("flash ID (init): {:x}", flash_id);
flash_spim.mem_qpi_mode(true);
let flash_id = flash_spim.mem_read_id_flash();
crate::println!("QPI flash ID: {:x}", flash_id);
crate::println!("Erasing from {:x}-{:x}...", 0, 2 * SPINOR_BULK_ERASE_SIZE);
for addr in (0..2 * SPINOR_BULK_ERASE_SIZE).step_by(SPINOR_BULK_ERASE_SIZE as usize) {
crate::println!(" {:x}...", addr);
flash_spim.flash_erase_block(addr, SPINOR_BULK_ERASE_SIZE as usize);
}
crate::println!("...done!");
}
"echo" => {
for word in args {
crate::print!("{} ", word);

View file

@ -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,17 +287,18 @@ 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) => {
println!("Kernel failed signature check. Dying: {:?}", e);
println!("{}LOADER.KERNFAIL,{}", BOOKEND_START, BOOKEND_END);
bao1x_hal::sigcheck::die_no_std();
}
}
@ -328,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
}

View file

@ -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);

View file

@ -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();
}
}

View file

@ -89,6 +89,7 @@ impl KeyStore {
}
}
log::info!("Secret ID init done.");
log::info!("{}KEYSTORE.INITDONE,{}", BOOKEND_START, BOOKEND_END);
}
}