Merge pull request #761 from betrusted-io/size-opt

Size optimizations
This commit is contained in:
bunnie 2025-12-22 16:37:14 +08:00 committed by GitHub
commit b0a70f385f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 69 additions and 7 deletions

View file

@ -68,6 +68,7 @@ enum-iterator = "0.6.0"
board-baosec = [
"bao1x-hal-service",
"ux-api/board-baosec",
"ux-api/bip39entry",
"blitstr2/board-baosec",
"usb-bao1x/board-baosec",
"persistent_store/board-baosec",
@ -75,6 +76,7 @@ board-baosec = [
]
hosted-baosec = [
"bao1x-emu",
"ux-api/bip39entry",
"ux-api/hosted-baosec",
"usb-bao1x/hosted-baosec",
"ctap-crypto/hosted-baosec",

View file

@ -24,6 +24,7 @@ bao1x = [
"utralib/bao1x",
"linked_list_allocator",
"bao1x-hal/loader-baosec",
"bao1x-hal/security",
"bao1x-api",
# "bao1x-hal/debug-print-duart",
]

View file

@ -34,6 +34,7 @@ bao1x = [
"utralib/bao1x",
"linked_list_allocator",
"bao1x-hal/loader-baosec",
"bao1x-hal/security",
# "bao1x-hal/debug-print-duart",
"bao1x-api",
# needed for the boot logo

View file

@ -43,6 +43,7 @@ bao1x = [
"utralib/bao1x",
"linked_list_allocator",
"bao1x-hal/debug-print-uart",
"bao1x-hal/security",
"bao1x-api",
"digest",
"sha2-bao1x",

View file

@ -70,7 +70,6 @@ board-baosec = [
"utralib/bao1x",
"ux-api/board-baosec",
"ux-api/std",
"sigcheck",
] # USB form factor token
loader-baosec = [
"utralib/bao1x",
@ -79,7 +78,6 @@ loader-baosec = [
"axp2101",
"bmp180",
"ux-api/loader-baosec",
"sigcheck",
]
kernel = []
kernel-baosec = ["utralib/bao1x", "kernel"]
@ -93,11 +91,10 @@ board-baosor = [
"axp2101",
"utralib/bao1x",
"ux-api/std",
"sigcheck",
] # Precursor form factor
loader-baosor = []
board-dabao = ["utralib/bao1x", "sigcheck"] # Dev board form factor
loader-dabao = ["sigcheck"]
board-dabao = ["utralib/bao1x"] # Dev board form factor
loader-dabao = []
verilator-only = ["utralib/bao1x"]
mpw = ["utralib/bao1x"]
hdl-test = ["utralib/bao1x"]
@ -107,6 +104,7 @@ debug-print-duart = ["debug-print", "debug-countermeasures"]
debug-print-uart = ["debug-print"]
debug-countermeasures = []
debug-wfi = []
security = ["sigcheck"]
udma-stress-test = [
] # For RTL simulation testing - aggravates a key corner case

View file

@ -36,7 +36,7 @@ pub mod buram;
pub mod clocks;
#[cfg(not(feature = "hosted-baosec"))]
pub mod coreuser;
#[cfg(all(not(feature = "hosted-baosec"), not(feature = "kernel")))]
#[cfg(feature = "security")]
pub mod hardening;
#[cfg(feature = "std")]
pub mod i2c;
@ -48,7 +48,7 @@ pub mod mbox;
pub mod rram;
#[cfg(not(feature = "hosted-baosec"))]
pub mod rtc;
#[cfg(all(not(feature = "hosted-baosec"), not(feature = "kernel")))]
#[cfg(feature = "security")]
pub mod sigcheck;
#[cfg(not(feature = "hosted-baosec"))]
pub mod sram_trim;

View file

@ -106,12 +106,14 @@ board-baosec = [
"digest",
"ux-api/loader-baosec",
"aes/loader-baosec",
"bao1x-hal/security",
]
board-baosor = ["bao1x-hal/loader-baosor"]
board-dabao = [
"bao1x-hal/loader-dabao",
"bao1x-hal/board-dabao",
"aes/loader-dabao",
"bao1x-hal/security",
]
atsama5d27 = ["utralib/atsama5d27", "armv7", "dep:atsama5d27"]

View file

@ -267,6 +267,12 @@ pub fn sign_image(
target,
);
return Err(String::from("Image doesn't fit").into());
} else {
println!(
"=== Kernel is {} bytes: {} bytes free remaining ===",
dest_file.len(),
target - dest_file.len()
);
}
}
Ok(dest_file)

View file

@ -794,6 +794,57 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// builder.add_feature("modal-testing");
}
Some("baosec-lite") => {
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);
// needs a filesystem, which has to be implemented in...128k :-O
let bao_rram_pkgs = [
"xous-ticktimer",
"keystore",
"xous-log",
"xous-names",
"usb-bao1x",
"bao1x-hal-service",
"modals",
"bao-video",
"vault2",
]
.to_vec();
let bao_swap_pkgs = [].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("debug-print");
// the following feature needs to be uncommented if we also enable
builder.add_kernel_feature("v2p");
builder.target_bao1x_soc();
for service in bao_rram_pkgs {
builder.add_service(service, LoaderRegion::Flash);
}
builder.add_services(&get_cratespecs());
for service in bao_swap_pkgs {
builder.add_service(service, LoaderRegion::Swap);
}
for app in get_cratespecs() {
builder.add_service(&app, LoaderRegion::Swap);
}
// builder.add_feature("modal-testing");
}
Some("baosec-improper-keystore") => {
let board = "board-baosec";
let sigblock_size = 0x300;