Merge pull request #798 from betrusted-io/out-of-tree

add the ability to specify regions for apps; eliminate default apps
This commit is contained in:
bunnie 2026-01-31 03:08:17 +08:00 committed by GitHub
commit ea8c68c654
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 10 deletions

2
.gitignore vendored
View file

@ -33,6 +33,8 @@ buildpush.ps1
tools/test-backup-analyze.sh
todo.md
notes/
# no uf2 files in the root directory
/*.uf2
# SSH id file for convenience
/id_pi

View file

@ -84,17 +84,41 @@ impl CrateSpec {
}
}
}
/// Detects a pattern of "crate~region", as in "vault2~swap" to specify where
/// a crate should go. The region is case-insensitive. This feature is added to help
/// give more control for bao1x builds, but as of yet no configurations need to
/// use anything other than the default locations, so this is only lightly tested.
pub fn region_from_name(name_spec: &str, default_region: LoaderRegion) -> (&str, LoaderRegion) {
if name_spec.contains('~') {
let (name, spec) = name_spec.split_once('~').unwrap();
let region = match spec.to_ascii_lowercase().as_str() {
"swap" => LoaderRegion::Swap,
"flash" => LoaderRegion::Flash,
"ram" => LoaderRegion::Ram,
_ => LoaderRegion::Invalid,
};
(name, region)
} else {
(name_spec, default_region)
}
}
impl From<&str> for CrateSpec {
fn from(spec: &str) -> CrateSpec {
// remote crates are specified as "name^version", i.e. "xous-names^0.9.9"
if spec.contains('^') {
let (name, version) = spec.split_once('^').expect("couldn't parse crate specifier");
CrateSpec::CratesIo(name.to_string(), version.to_string(), LoaderRegion::Ram)
let (name, region) = region_from_name(name, LoaderRegion::Ram);
CrateSpec::CratesIo(name.to_string(), version.to_string(), region)
// prebuilt crates are specified as "name#url"
// i.e. "espeak-embedded#https://ci.betrusted.io/job/espeak-embedded/lastSuccessfulBuild/artifact/target/riscv32imac-unknown-xous-elf/release/"
} else if spec.contains('#') {
let (name, url) = spec.split_once('#').expect("couldn't parse crate specifier");
CrateSpec::Prebuilt(name.to_string(), url.to_string(), LoaderRegion::Ram)
let (name, region) = region_from_name(name, LoaderRegion::Ram);
CrateSpec::Prebuilt(name.to_string(), url.to_string(), region)
// local files are specified as paths, which, at a minimum include one directory separator "/" or "\"
// i.e. "./local_file"
// Note that this is after a test for the '#' character, so that disambiguates URL slashes
@ -104,12 +128,15 @@ impl From<&str> for CrateSpec {
//optionally a BinaryFile can have a name associated with it as "name:path"
if spec.find(':').is_some() {
let (name, path) = spec.split_once(':').unwrap();
CrateSpec::BinaryFile(Some(name.to_string()), path.to_string(), LoaderRegion::Ram)
let (name, region) = region_from_name(name, LoaderRegion::Ram);
CrateSpec::BinaryFile(Some(name.to_string()), path.to_string(), region)
} else {
CrateSpec::BinaryFile(None, spec.to_string(), LoaderRegion::Ram)
let (name, region) = region_from_name(spec, LoaderRegion::Ram);
CrateSpec::BinaryFile(None, name.to_string(), region)
}
} else {
CrateSpec::Local(spec.to_string(), LoaderRegion::Ram)
let (name, region) = region_from_name(spec, LoaderRegion::Ram);
CrateSpec::Local(name.to_string(), region)
}
}
}

View file

@ -814,7 +814,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let bao_rram_pkgs =
["xous-ticktimer", "keystore", "xous-log", "xous-names", "usb-bao1x", "bao1x-hal-service"]
.to_vec();
let bao_app_pkgs: Vec<&'static str> = ["dabao-console"].to_vec();
let bao_app_pkgs: Vec<&'static str> = [].to_vec();
builder.add_loader_feature("debug-print");
builder.add_kernel_feature("v2p");
@ -829,7 +829,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
builder.add_service(service, LoaderRegion::Flash);
}
builder.add_apps(&bao_app_pkgs);
builder.add_apps(&get_cratespecs());
for app in get_cratespecs() {
let (name, region) = crate::builder::region_from_name(&app, LoaderRegion::Flash);
builder.add_service(name, region);
}
}
// ------ ARM hardware image configs ------
@ -1177,7 +1181,7 @@ fn baosec_common(builder: &mut Builder) -> std::io::Result<()> {
"bao-video",
]
.to_vec();
let bao_swap_pkgs = ["bao-console", "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 _);
@ -1213,12 +1217,13 @@ fn baosec_common(builder: &mut Builder) -> std::io::Result<()> {
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);
let (name, region) = crate::builder::region_from_name(&app, LoaderRegion::Swap);
builder.add_service(name, region);
}
// builder.add_feature("modal-testing");
Ok(())