mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add signature header to boot/baremetal regions
also make the link.x file update based on changes to that region's length.
This commit is contained in:
parent
198e584369
commit
bd7ca4fa32
2 changed files with 58 additions and 7 deletions
|
|
@ -148,6 +148,7 @@ pub(crate) struct Builder {
|
|||
swap: Option<(u32, u32)>,
|
||||
change_target: bool,
|
||||
baremetal: bool,
|
||||
sigblock_size: usize,
|
||||
}
|
||||
|
||||
impl Builder {
|
||||
|
|
@ -178,9 +179,16 @@ impl Builder {
|
|||
swap: None,
|
||||
change_target: false,
|
||||
baremetal: false,
|
||||
sigblock_size: 4096,
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets up the signature block size
|
||||
pub fn set_sigblock_size<'a>(&'a mut self, size: usize) -> &'a mut Builder {
|
||||
self.sigblock_size = size;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets a flag if the build is just for a baremetal testing target
|
||||
pub fn set_baremetal<'a>(&'a mut self, baremetal: bool) -> &'a mut Builder {
|
||||
self.baremetal = baremetal;
|
||||
|
|
@ -863,7 +871,10 @@ impl Builder {
|
|||
output_file.push("target");
|
||||
output_file.push(self.target_kernel.as_ref().expect("target"));
|
||||
output_file.push(stream);
|
||||
let mut presign_file = output_file.clone();
|
||||
output_file.push(format!("{}.img", self.loader.name().unwrap_or("baremetal".to_string())));
|
||||
presign_file
|
||||
.push(format!("{}-presign.img", self.loader.name().unwrap_or("baremetal".to_string())));
|
||||
|
||||
let status = Command::new(cargo())
|
||||
.current_dir(project_root())
|
||||
|
|
@ -875,13 +886,35 @@ impl Builder {
|
|||
"copy-object",
|
||||
"--",
|
||||
&loader[0],
|
||||
output_file.as_os_str().to_str().unwrap(),
|
||||
presign_file.as_os_str().to_str().unwrap(),
|
||||
is_bao,
|
||||
])
|
||||
.status()?;
|
||||
if !status.success() {
|
||||
return Err("cargo build failed".into());
|
||||
} else {
|
||||
Command::new(cargo())
|
||||
.current_dir(project_root())
|
||||
.args([
|
||||
"run",
|
||||
"--package",
|
||||
"tools",
|
||||
"--bin",
|
||||
"sign-image",
|
||||
"--",
|
||||
"--loader-image",
|
||||
presign_file.to_str().unwrap(),
|
||||
"--loader-key",
|
||||
&self.loader_key,
|
||||
"--loader-output",
|
||||
output_file.to_str().unwrap(),
|
||||
"--min-xous-ver",
|
||||
&self.min_ver,
|
||||
"--sig-length",
|
||||
&self.sigblock_size.to_string(),
|
||||
"--with-jump", // bao1x target has a jump inserted in the loader sig block
|
||||
])
|
||||
.status()?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ pub(crate) const TARGET_TRIPLE_RISCV32_KERNEL: &str = "riscv32imac-unknown-none-
|
|||
pub(crate) const TARGET_TRIPLE_ARM: &str = "armv7a-unknown-xous-elf";
|
||||
pub(crate) const TARGET_TRIPLE_ARM_KERNEL: &str = "armv7a-unknown-none-elf";
|
||||
|
||||
/// Size of the "statics" region used to initialize baremetal targets
|
||||
const STATICS_LEN: usize = 0x100;
|
||||
|
||||
// because I have nowhere else to note this. The commit that contains the rkyv-enum derive
|
||||
// refactor to work around warnings thrown by Rust 1.64.0 is: f815ed85b58b671178fbf53b4cea34186fc406eb
|
||||
// We could undo this if it turns out to be a compiler regression.
|
||||
|
|
@ -599,21 +602,36 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
}
|
||||
|
||||
Some("baremetal-bao1x") => {
|
||||
builder.set_baremetal(true);
|
||||
update_flash_origin("baremetal/src/platform/bao1x/link.x", 0x6000_0100)?;
|
||||
builder.target_baremetal_bao1x("baremetal");
|
||||
let sigblock_size = 0x300;
|
||||
update_flash_origin(
|
||||
"baremetal/src/platform/bao1x/link.x",
|
||||
(0x6000_0000 + sigblock_size + STATICS_LEN) as u32,
|
||||
)?;
|
||||
builder.set_baremetal(true).target_baremetal_bao1x("baremetal").set_sigblock_size(sigblock_size);
|
||||
}
|
||||
|
||||
Some("baremetal-bao1x-evb") => {
|
||||
let sigblock_size = 0x300;
|
||||
update_flash_origin(
|
||||
"baremetal/src/platform/bao1x/link.x",
|
||||
(0x6100_0000 + sigblock_size + STATICS_LEN) as u32,
|
||||
)?;
|
||||
builder.set_baremetal(true);
|
||||
update_flash_origin("baremetal/src/platform/bao1x/link.x", 0x6100_0100)?;
|
||||
builder.add_loader_feature("bao1x-evb");
|
||||
builder.set_sigblock_size(sigblock_size);
|
||||
builder.target_baremetal_bao1x("baremetal");
|
||||
}
|
||||
|
||||
Some("bao1x-boot0") => {
|
||||
builder.set_baremetal(true);
|
||||
builder.target_baremetal_bao1x("bao1x-boot0");
|
||||
let sigblock_size = 0x300;
|
||||
update_flash_origin(
|
||||
"baremetal/src/platform/bao1x/link.x",
|
||||
(0x6000_0000 + sigblock_size + STATICS_LEN) as u32,
|
||||
)?;
|
||||
builder
|
||||
.set_baremetal(true)
|
||||
.target_baremetal_bao1x("bao1x-boot0")
|
||||
.set_sigblock_size(sigblock_size);
|
||||
}
|
||||
|
||||
Some("baosec") => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue