diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 9944789b5..5f39187a3 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -20,3 +20,4 @@ ureq = { version = "2.9.0", features = ["json"] } svd2utra = "0.1.23" lazy_static = "1.4.0" # toml_edit = "0.14.4" # would be used to verify Cargo.toml files, but it's too hard to do this right now. +bao1x-api = { path = "../libs/bao1x-api" } diff --git a/xtask/src/builder.rs b/xtask/src/builder.rs index bd163b93c..d6fc39797 100644 --- a/xtask/src/builder.rs +++ b/xtask/src/builder.rs @@ -1023,7 +1023,12 @@ impl Builder { loader_bin.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 + "--bao1x", + "--function-code", + "loader", ]) .status()? } else { @@ -1054,26 +1059,55 @@ impl Builder { let mut xous_img_path = output_bundle.parent().unwrap().to_owned(); xous_img_path.push("xous.img"); - let status = Command::new(cargo()) - .current_dir(project_root()) - .args([ - "run", - "--package", - "tools", - "--bin", - "sign-image", - "--", - "--kernel-image", - output_bundle.to_str().unwrap(), - "--kernel-key", - &self.kernel_key, - "--kernel-output", - xous_img_path.to_str().unwrap(), - "--min-xous-ver", - &self.min_ver, - // "--defile", - ]) - .status()?; + let status = if self.utra_target.contains("bao1x") { + Command::new(cargo()) + .current_dir(project_root()) + .args([ + "run", + "--package", + "tools", + "--bin", + "sign-image", + "--", + "--kernel-image", + output_bundle.to_str().unwrap(), + "--kernel-key", + &self.kernel_key, + "--kernel-output", + xous_img_path.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 sig block + "--bao1x", + "--function-code", + "kernel", + // "--defile", + ]) + .status()? + } else { + Command::new(cargo()) + .current_dir(project_root()) + .args([ + "run", + "--package", + "tools", + "--bin", + "sign-image", + "--", + "--kernel-image", + output_bundle.to_str().unwrap(), + "--kernel-key", + &self.kernel_key, + "--kernel-output", + xous_img_path.to_str().unwrap(), + "--min-xous-ver", + &self.min_ver, + // "--defile", + ]) + .status()? + }; if !status.success() { return Err("kernel image sign failed".into()); } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index d7d67ed19..b1b1c8394 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -605,7 +605,7 @@ fn main() -> Result<(), Box> { let sigblock_size = 0x300; update_flash_origin( "baremetal/src/platform/bao1x/link.x", - (0x6000_0000 + sigblock_size + STATICS_LEN) as u32, + (bao1x_api::BAREMETAL_START + sigblock_size + STATICS_LEN) as u32, )?; builder.set_baremetal(true).target_baremetal_bao1x("baremetal").set_sigblock_size(sigblock_size); } @@ -625,8 +625,8 @@ fn main() -> Result<(), Box> { Some("bao1x-boot0") => { let sigblock_size = 0x300; update_flash_origin( - "baremetal/src/platform/bao1x/link.x", - (0x6000_0000 + sigblock_size + STATICS_LEN) as u32, + "bao1x-boot/boot0/link.x", + (bao1x_api::BOOT0_START + sigblock_size + STATICS_LEN) as u32, )?; builder .set_baremetal(true) @@ -634,12 +634,30 @@ fn main() -> Result<(), Box> { .set_sigblock_size(sigblock_size); } + Some("bao1x-boot1") => { + let sigblock_size = 0x300; + update_flash_origin( + "bao1x-boot/boot1/src/platform/bao1x/link.x", + (bao1x_api::BOOT1_START + sigblock_size + STATICS_LEN) as u32, + )?; + builder + .set_baremetal(true) + .target_baremetal_bao1x("bao1x-boot1") + .set_sigblock_size(sigblock_size); + } + Some("baosec") => { 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.add_feature(board); builder.add_loader_feature(board); builder.add_kernel_feature(board); + builder.set_sigblock_size(sigblock_size); // placement in flash is a tension between dev convenience and RAM usage. Things in flash // are resident, non-swapable, but end up making the slow kernel burn process take longer.