mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
xtask: add libstd-test routine
This routine takes a list of binaries to include in the resulting image. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
e4d02301ee
commit
b1e949c4c4
1 changed files with 97 additions and 37 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
|
convert::TryInto,
|
||||||
env,
|
env,
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
path::{Path, PathBuf, MAIN_SEPARATOR},
|
path::{Path, PathBuf, MAIN_SEPARATOR},
|
||||||
|
|
@ -77,6 +78,9 @@ fn try_main() -> Result<(), DynError> {
|
||||||
"susres",
|
"susres",
|
||||||
"com",
|
"com",
|
||||||
];
|
];
|
||||||
|
// A base set of packages. This is all you need for a normal
|
||||||
|
// operating system that can run libstd
|
||||||
|
let base_pkgs = ["ticktimer-server", "log-server"];
|
||||||
let cbtest_pkgs = [
|
let cbtest_pkgs = [
|
||||||
"ticktimer-server",
|
"ticktimer-server",
|
||||||
"log-server",
|
"log-server",
|
||||||
|
|
@ -99,15 +103,13 @@ fn try_main() -> Result<(), DynError> {
|
||||||
"com",
|
"com",
|
||||||
"susres",
|
"susres",
|
||||||
];
|
];
|
||||||
let aestest_pkgs = [
|
let aestest_pkgs = ["ticktimer-server", "log-server", "aes-test"];
|
||||||
"ticktimer-server",
|
let mut args = env::args();
|
||||||
"log-server",
|
let task = args.nth(1);
|
||||||
"aes-test",
|
|
||||||
];
|
|
||||||
let task = env::args().nth(1);
|
|
||||||
match task.as_deref() {
|
match task.as_deref() {
|
||||||
Some("renode-image") => renode_image(false, &hw_pkgs)?,
|
Some("renode-image") => renode_image(false, &hw_pkgs)?,
|
||||||
Some("renode-test") => renode_image(false, &cbtest_pkgs)?,
|
Some("renode-test") => renode_image(false, &cbtest_pkgs)?,
|
||||||
|
Some("libstd-test") => renode_image_extra(false, &base_pkgs, args.collect())?,
|
||||||
Some("renode-aes-test") => renode_image(false, &aestest_pkgs)?,
|
Some("renode-aes-test") => renode_image(false, &aestest_pkgs)?,
|
||||||
Some("renode-image-debug") => renode_image(true, &hw_pkgs)?,
|
Some("renode-image-debug") => renode_image(true, &hw_pkgs)?,
|
||||||
Some("run") => run(false, &hw_pkgs)?,
|
Some("run") => run(false, &hw_pkgs)?,
|
||||||
|
|
@ -149,6 +151,8 @@ fn print_help() {
|
||||||
renode-image builds a functional image for renode
|
renode-image builds a functional image for renode
|
||||||
renode-test builds a test image for renode
|
renode-test builds a test image for renode
|
||||||
renode-image-debug builds a test image for renode in debug mode
|
renode-image-debug builds a test image for renode in debug mode
|
||||||
|
libstd-test [pkg1] [..] builds a test image that includes the minimum packages, plus those
|
||||||
|
specified on the command line (e.g. built externally)
|
||||||
hw-image [soc.svd] builds an image for real hardware
|
hw-image [soc.svd] builds an image for real hardware
|
||||||
run runs a release build using a hosted environment
|
run runs a release build using a hosted environment
|
||||||
debug runs a debug build using a hosted environment
|
debug runs a debug build using a hosted environment
|
||||||
|
|
@ -169,56 +173,56 @@ Please refer to tools/README_UPDATE.md for instructions on how to set up `usb_up
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_usb(do_kernel: bool, do_loader: bool, do_soc: bool) -> Result<(), DynError> {
|
fn update_usb(do_kernel: bool, do_loader: bool, do_soc: bool) -> Result<(), DynError> {
|
||||||
use std::process::Stdio;
|
|
||||||
use std::io::{BufRead, BufReader, Error, ErrorKind};
|
use std::io::{BufRead, BufReader, Error, ErrorKind};
|
||||||
|
use std::process::Stdio;
|
||||||
|
|
||||||
if do_kernel {
|
if do_kernel {
|
||||||
println!("Burning kernel");
|
println!("Burning kernel");
|
||||||
let stdout = Command::new("python3")
|
let stdout = Command::new("python3")
|
||||||
.arg("tools/usb_update.py")
|
.arg("tools/usb_update.py")
|
||||||
.arg("-k")
|
.arg("-k")
|
||||||
.arg("target/riscv32imac-unknown-none-elf/release/xous.img")
|
.arg("target/riscv32imac-unknown-none-elf/release/xous.img")
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()?
|
.spawn()?
|
||||||
.stdout
|
.stdout
|
||||||
.ok_or_else(|| Error::new(ErrorKind::Other, "Could not capture output"))?;
|
.ok_or_else(|| Error::new(ErrorKind::Other, "Could not capture output"))?;
|
||||||
|
|
||||||
let reader = BufReader::new(stdout);
|
let reader = BufReader::new(stdout);
|
||||||
reader.lines().for_each(|line|
|
reader
|
||||||
println!("{}", line.unwrap())
|
.lines()
|
||||||
);
|
.for_each(|line| println!("{}", line.unwrap()));
|
||||||
}
|
}
|
||||||
if do_loader {
|
if do_loader {
|
||||||
println!("Burning loader");
|
println!("Burning loader");
|
||||||
let stdout = Command::new("python3")
|
let stdout = Command::new("python3")
|
||||||
.arg("tools/usb_update.py")
|
.arg("tools/usb_update.py")
|
||||||
.arg("-l")
|
.arg("-l")
|
||||||
.arg("target/riscv32imac-unknown-none-elf/release/loader.bin")
|
.arg("target/riscv32imac-unknown-none-elf/release/loader.bin")
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()?
|
.spawn()?
|
||||||
.stdout
|
.stdout
|
||||||
.ok_or_else(|| Error::new(ErrorKind::Other, "Could not capture output"))?;
|
.ok_or_else(|| Error::new(ErrorKind::Other, "Could not capture output"))?;
|
||||||
|
|
||||||
let reader = BufReader::new(stdout);
|
let reader = BufReader::new(stdout);
|
||||||
reader.lines().for_each(|line|
|
reader
|
||||||
println!("{}", line.unwrap())
|
.lines()
|
||||||
);
|
.for_each(|line| println!("{}", line.unwrap()));
|
||||||
}
|
}
|
||||||
if do_soc {
|
if do_soc {
|
||||||
println!("Burning SoC gateware");
|
println!("Burning SoC gateware");
|
||||||
let stdout = Command::new("python3")
|
let stdout = Command::new("python3")
|
||||||
.arg("tools/usb_update.py")
|
.arg("tools/usb_update.py")
|
||||||
.arg("-s")
|
.arg("-s")
|
||||||
.arg("precursors/soc_csr.bin")
|
.arg("precursors/soc_csr.bin")
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()?
|
.spawn()?
|
||||||
.stdout
|
.stdout
|
||||||
.ok_or_else(|| Error::new(ErrorKind::Other, "Could not capture output"))?;
|
.ok_or_else(|| Error::new(ErrorKind::Other, "Could not capture output"))?;
|
||||||
|
|
||||||
let reader = BufReader::new(stdout);
|
let reader = BufReader::new(stdout);
|
||||||
reader.lines().for_each(|line|
|
reader
|
||||||
println!("{}", line.unwrap())
|
.lines()
|
||||||
);
|
.for_each(|line| println!("{}", line.unwrap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -353,6 +357,62 @@ fn renode_image(debug: bool, packages: &[&str]) -> Result<(), DynError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a Renode image, and include the extra init programs specified
|
||||||
|
/// on the command line.
|
||||||
|
fn renode_image_extra(
|
||||||
|
debug: bool,
|
||||||
|
packages: &[&str],
|
||||||
|
extra_init: Vec<String>,
|
||||||
|
) -> Result<(), DynError> {
|
||||||
|
let path = std::path::Path::new("emulation/soc/renode.svd");
|
||||||
|
std::env::set_var("XOUS_SVD_FILE", path.canonicalize().unwrap());
|
||||||
|
let kernel = build_kernel(debug)?;
|
||||||
|
let mut init = vec![];
|
||||||
|
let base_path = build(packages, debug, Some(TARGET), None, None)?;
|
||||||
|
for pkg in packages {
|
||||||
|
let mut pkg_path = base_path.clone();
|
||||||
|
pkg_path.push(pkg);
|
||||||
|
init.push(pkg_path);
|
||||||
|
}
|
||||||
|
for pkg in extra_init {
|
||||||
|
init.push(pkg.try_into().unwrap());
|
||||||
|
}
|
||||||
|
build(
|
||||||
|
&["loader"],
|
||||||
|
debug,
|
||||||
|
Some(TARGET),
|
||||||
|
Some("loader".into()),
|
||||||
|
None,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
create_image(
|
||||||
|
&kernel,
|
||||||
|
&init,
|
||||||
|
debug,
|
||||||
|
MemorySpec::SvdFile("emulation/soc/renode.svd".into()),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
// Regenerate the Platform file
|
||||||
|
let status = Command::new(cargo())
|
||||||
|
.current_dir(project_root())
|
||||||
|
.args(&[
|
||||||
|
"run",
|
||||||
|
"-p",
|
||||||
|
"svd2repl",
|
||||||
|
"--",
|
||||||
|
"-i",
|
||||||
|
"emulation/soc/renode.svd",
|
||||||
|
"-o",
|
||||||
|
"emulation/soc/betrusted-soc.repl",
|
||||||
|
])
|
||||||
|
.status()?;
|
||||||
|
if !status.success() {
|
||||||
|
Err("Unable to regenerate Renode platform file")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn run(debug: bool, init: &[&str]) -> Result<(), DynError> {
|
fn run(debug: bool, init: &[&str]) -> Result<(), DynError> {
|
||||||
let stream = if debug { "debug" } else { "release" };
|
let stream = if debug { "debug" } else { "release" };
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue