add altboot support to bao1x targets

specify cargo xtask baot1x-alt-boot1 and dragging this UF2
file onto the disk boots into an alternat boot1 loader that
allows updating of boot1.
This commit is contained in:
bunnie 2025-10-28 21:38:44 +08:00
parent 09309eb3ae
commit 90c46c65c3
No known key found for this signature in database
2 changed files with 26 additions and 2 deletions

View file

@ -874,8 +874,19 @@ impl Builder {
if self.loader_disable_defaults {
loader_extra.push("--no-default-features".to_string());
}
// substitute bao1x-alt-boot1 for bao1x-boot1
let adjusted_loader = match &self.loader {
CrateSpec::Local(name, region) => {
if name == "bao1x-alt-boot1" {
CrateSpec::Local("bao1x-boot1".to_string(), *region)
} else {
self.loader.clone()
}
}
_ => self.loader.clone(),
};
let loader = self.builder(
&[self.loader.clone()],
&[adjusted_loader],
&self.loader_features,
&self.target_kernel.as_deref(),
BuildStream::Release, // loader doesn't fit if you build with Debug
@ -926,7 +937,7 @@ impl Builder {
"boot0"
} else if name == "bao1x-boot1" {
"boot1"
} else if name == "baremetal" {
} else if name == "baremetal" || name == "bao1x-alt-boot1" {
"baremetal"
} else {
return Err(String::from("Target subtype not supported").into());

View file

@ -651,6 +651,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.set_sigblock_size(sigblock_size);
}
Some("bao1x-alt-boot1") => {
let sigblock_size = 0x300;
update_flash_origin(
"bao1x-boot/boot1/src/platform/bao1x/link.x",
(bao1x_api::LOADER_START + sigblock_size + STATICS_LEN) as u32,
)?;
builder.add_loader_feature("alt-boot1");
builder
.set_baremetal(true)
.target_baremetal_bao1x("bao1x-alt-boot1")
.set_sigblock_size(sigblock_size);
}
Some("baosec") => {
let board = "board-baosec";
let sigblock_size = 0x300;