mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
work around broken AES accelerator in MPW silicon
Haven't dug into it, but the AES instruction is not working correctly in MPW cramium target silicon. There isn't a great way to selectively disable hardware acceleration for sub-targets of patched crates. So, as a work-around, we use xtask to patch the default arguments of the AES crate, just for cramium-soc targets, to use software emulated AES. This allows us to move on with bring-up. To wit, there is another AES accelerator on-chip that could be much faster than RV32 AES acceleration (and with better DPA characteristics), and to use that option, we might have to use a patch like this anyways, because Rust doesn't have a good way to pass feature flags through patched crates like this.
This commit is contained in:
parent
bb4b01b04b
commit
70ec91d917
2 changed files with 44 additions and 8 deletions
|
|
@ -323,6 +323,8 @@ impl Builder {
|
|||
self.run_svd2repl = false;
|
||||
self.loader = CrateSpec::Local("loader".to_string(), LoaderRegion::Ram);
|
||||
self.kernel = CrateSpec::Local("xous-kernel".to_string(), LoaderRegion::Ram);
|
||||
search_and_replace_in_file("services/aes/Cargo.toml", "default = []", "default = [\"cramium-soc\"]")
|
||||
.expect("couldn't patch AES");
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -1122,3 +1124,26 @@ pub fn cargo() -> String { env::var("CARGO").unwrap_or_else(|_| "cargo".to_strin
|
|||
pub fn project_root() -> PathBuf {
|
||||
Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(1).unwrap().to_path_buf()
|
||||
}
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{self, BufRead, BufReader};
|
||||
pub fn search_and_replace_in_file(filename: &str, search: &str, replace: &str) -> io::Result<()> {
|
||||
// Open the file for reading
|
||||
let file = File::open(filename)?;
|
||||
let reader = BufReader::new(file);
|
||||
|
||||
// Read lines from the file and perform replacement
|
||||
let mut modified_content = String::new();
|
||||
for line in reader.lines() {
|
||||
let line = line?;
|
||||
let modified_line = line.replace(search, replace);
|
||||
modified_content.push_str(&modified_line);
|
||||
modified_content.push('\n');
|
||||
}
|
||||
|
||||
// Write the modified content back to the file
|
||||
let mut file = File::create(filename)?;
|
||||
file.write_all(modified_content.as_bytes())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
// ---- now process the verb plus position dependent arguments ----
|
||||
let mut args = env::args();
|
||||
let task = args.nth(1);
|
||||
let mut broken_aes_cleanup = false;
|
||||
match task.as_deref() {
|
||||
Some("install-toolkit") | Some("install-toolchain") => {
|
||||
let arg = env::args().nth(2);
|
||||
|
|
@ -447,8 +448,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
if !builder.is_swap_set() {
|
||||
builder.set_swap(0, 4 * 1024 * 1024);
|
||||
}
|
||||
builder.add_loader_feature("debug-print");
|
||||
builder.add_loader_feature("board-bringup");
|
||||
builder.add_loader_feature("debug-print");
|
||||
builder.add_loader_feature("swap");
|
||||
builder.add_kernel_feature("debug-print");
|
||||
builder.add_kernel_feature("debug-swap");
|
||||
builder.add_kernel_feature("swap");
|
||||
builder.add_feature("swap");
|
||||
builder.add_feature("quantum-timer");
|
||||
// builder.add_loader_feature("spim-test");
|
||||
// builder.add_loader_feature("spi-alt-channel"); // this flag, when asserted, uses the J_QSPI
|
||||
// header. By default, we use JPC7_13 (J_QSPI does not work, for some reason; bit 3 is stuck
|
||||
|
|
@ -459,12 +466,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
Some("cramium-soc") => builder.target_cramium_soc(),
|
||||
_ => panic!("should be unreachable"),
|
||||
};
|
||||
broken_aes_cleanup = true;
|
||||
|
||||
// It is important that this is the first service added, because the swapper *must* be in PID 2
|
||||
builder.add_service("xous-swapper", LoaderRegion::Flash);
|
||||
builder.add_loader_feature("swap");
|
||||
builder.add_kernel_feature("swap");
|
||||
builder.add_feature("swap");
|
||||
|
||||
builder.add_services(&get_cratespecs());
|
||||
for service in cramium_flash_pkgs {
|
||||
|
|
@ -474,10 +479,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
for service in cramium_swap_pkgs {
|
||||
builder.add_service(service, LoaderRegion::Swap);
|
||||
}
|
||||
builder.add_feature("quantum-timer");
|
||||
|
||||
builder.add_kernel_feature("debug-swap");
|
||||
builder.add_kernel_feature("debug-print");
|
||||
}
|
||||
|
||||
// ------ ARM hardware image configs ------
|
||||
|
|
@ -505,6 +506,16 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
}
|
||||
builder.build()?;
|
||||
|
||||
// AES is broken in the current rev of the Cramium SoC. This unpatches the crate so other builds can
|
||||
// work properly.
|
||||
if broken_aes_cleanup {
|
||||
builder::search_and_replace_in_file(
|
||||
"services/aes/Cargo.toml",
|
||||
"default = [\"cramium-soc\"]",
|
||||
"default = []",
|
||||
)
|
||||
.expect("couldn't patch AES");
|
||||
}
|
||||
// the intent of this call is to check that crates we are sourcing from crates.io
|
||||
// match the crates in our local source. The usual cause of an inconsistency is
|
||||
// a maintainer forgot to publish a change to crates.io.
|
||||
|
|
|
|||
Loading…
Reference in a new issue