mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
modify tools to xous-tools
also add `xous-` prefix to binaries like copy-object this allows us to publish the tools as a package and allow people to `cargo install` them with less chance of name space conflicts.
This commit is contained in:
parent
d2a320b9c6
commit
fc6a4179bd
9 changed files with 71 additions and 71 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
[package]
|
[package]
|
||||||
authors = ["Sean Cross <sean@xobs.io>"]
|
authors = ["Sean Cross <sean@xobs.io>"]
|
||||||
default-run = "create-image"
|
default-run = "xous-create-image"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
name = "tools"
|
name = "xous-tools"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
@ -33,25 +33,25 @@ serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "copy-object"
|
name = "xous-copy-object"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "create-image"
|
name = "xous-create-image"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "make-renode-boot"
|
name = "xous-make-renode-boot"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "make-tags"
|
name = "xous-make-tags"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "read-tags"
|
name = "xous-read-tags"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "sign-image"
|
name = "xous-sign-image"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "create-detached-app"
|
name = "xous-create-detached-app"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
precursor = []
|
precursor = []
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::io::Write;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use tools::elf;
|
use xous_tools::elf;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
@ -6,11 +6,11 @@ extern crate crc;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use tools::elf::read_minielf;
|
use xous_tools::elf::read_minielf;
|
||||||
use tools::tags::inif::IniF;
|
use xous_tools::tags::inif::IniF;
|
||||||
use tools::tags::pnam::ProcessNames;
|
use xous_tools::tags::pnam::ProcessNames;
|
||||||
use tools::utils::parse_u32;
|
use xous_tools::utils::parse_u32;
|
||||||
use tools::xous_arguments::XousArguments;
|
use xous_tools::xous_arguments::XousArguments;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
@ -8,19 +8,19 @@ use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use tools::elf::{read_minielf, read_program};
|
use xous_tools::elf::{read_minielf, read_program};
|
||||||
use tools::sign_image::convert_to_uf2;
|
use xous_tools::sign_image::convert_to_uf2;
|
||||||
use tools::swap_writer::SwapWriter;
|
use xous_tools::swap_writer::SwapWriter;
|
||||||
use tools::tags::bflg::Bflg;
|
use xous_tools::tags::bflg::Bflg;
|
||||||
use tools::tags::inie::IniE;
|
use xous_tools::tags::inie::IniE;
|
||||||
use tools::tags::inif::IniF;
|
use xous_tools::tags::inif::IniF;
|
||||||
use tools::tags::inis::IniS;
|
use xous_tools::tags::inis::IniS;
|
||||||
use tools::tags::memory::{MemoryRegion, MemoryRegions};
|
use xous_tools::tags::memory::{MemoryRegion, MemoryRegions};
|
||||||
use tools::tags::pnam::ProcessNames;
|
use xous_tools::tags::pnam::ProcessNames;
|
||||||
use tools::tags::swap::Swap;
|
use xous_tools::tags::swap::Swap;
|
||||||
use tools::tags::xkrn::XousKernel;
|
use xous_tools::tags::xkrn::XousKernel;
|
||||||
use tools::utils::{parse_csr_csv, parse_u32};
|
use xous_tools::utils::{parse_csr_csv, parse_u32};
|
||||||
use tools::xous_arguments::XousArguments;
|
use xous_tools::xous_arguments::XousArguments;
|
||||||
|
|
||||||
const DEVKEY_PATH: &str = "devkey/dev.key";
|
const DEVKEY_PATH: &str = "devkey/dev.key";
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ struct RamConfig {
|
||||||
memory_required: u32,
|
memory_required: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn csr_to_config(hv: tools::utils::CsrConfig, ram_config: &mut RamConfig) {
|
fn csr_to_config(hv: xous_tools::utils::CsrConfig, ram_config: &mut RamConfig) {
|
||||||
let mut found_ram_name = None;
|
let mut found_ram_name = None;
|
||||||
fn round_mem(src: u32) -> u32 { (src + 4095) & !4095 }
|
fn round_mem(src: u32) -> u32 { (src + 4095) & !4095 }
|
||||||
// Look for the largest memory block, which we'll treat as main memory
|
// Look for the largest memory block, which we'll treat as main memory
|
||||||
|
|
@ -283,7 +283,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
} + PAGE_SIZE;
|
} + PAGE_SIZE;
|
||||||
map.insert(
|
map.insert(
|
||||||
region.name.to_lowercase(),
|
region.name.to_lowercase(),
|
||||||
tools::utils::CsrMemoryRegion {
|
xous_tools::utils::CsrMemoryRegion {
|
||||||
start: region.base.try_into().unwrap(),
|
start: region.base.try_into().unwrap(),
|
||||||
length: length.try_into().unwrap(),
|
length: length.try_into().unwrap(),
|
||||||
},
|
},
|
||||||
|
|
@ -291,7 +291,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
} else {
|
} else {
|
||||||
map.insert(
|
map.insert(
|
||||||
region.name.to_lowercase(),
|
region.name.to_lowercase(),
|
||||||
tools::utils::CsrMemoryRegion {
|
xous_tools::utils::CsrMemoryRegion {
|
||||||
start: region.base.try_into().unwrap(),
|
start: region.base.try_into().unwrap(),
|
||||||
length: region.size.try_into().unwrap(),
|
length: region.size.try_into().unwrap(),
|
||||||
},
|
},
|
||||||
|
|
@ -325,7 +325,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
println!("{:10}: {:x} - {:x}", region.name, region.base, region.base + region.size);
|
println!("{:10}: {:x} - {:x}", region.name, region.base, region.base + region.size);
|
||||||
map.insert(
|
map.insert(
|
||||||
region.name.to_lowercase(),
|
region.name.to_lowercase(),
|
||||||
tools::utils::CsrMemoryRegion {
|
xous_tools::utils::CsrMemoryRegion {
|
||||||
start: region.base.try_into().unwrap(),
|
start: region.base.try_into().unwrap(),
|
||||||
length: region.size.try_into().unwrap(),
|
length: region.size.try_into().unwrap(),
|
||||||
},
|
},
|
||||||
|
|
@ -334,7 +334,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
csr_to_config(tools::utils::CsrConfig { regions: map }, &mut ram_config);
|
csr_to_config(xous_tools::utils::CsrConfig { regions: map }, &mut ram_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swap has an architecture-dependent meaning.
|
// Swap has an architecture-dependent meaning.
|
||||||
|
|
@ -525,7 +525,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut sf =
|
let mut sf =
|
||||||
File::create(sf_dbg).unwrap_or_else(|_| panic!("Couldn't create debug file {}", sf_dbg));
|
File::create(sf_dbg).unwrap_or_else(|_| panic!("Couldn't create debug file {}", sf_dbg));
|
||||||
// serialize the unencrypted header into the debug image
|
// serialize the unencrypted header into the debug image
|
||||||
let header = tools::swap_writer::SwapHeader::new(buf_len);
|
let header = xous_tools::swap_writer::SwapHeader::new(buf_len);
|
||||||
sf.write(&header.serialize()?)?;
|
sf.write(&header.serialize()?)?;
|
||||||
// directly write our unencrypted data from sargs into file sf. It's an exact copy of
|
// directly write our unencrypted data from sargs into file sf. It's an exact copy of
|
||||||
// what ended up in swap_buffer.
|
// what ended up in swap_buffer.
|
||||||
|
|
@ -5,13 +5,13 @@ use std::convert::TryInto;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use tools::elf::{process_minielf, process_program, read_minielf};
|
use xous_tools::elf::{process_minielf, process_program, read_minielf};
|
||||||
use tools::sign_image::sign_image;
|
use xous_tools::sign_image::sign_image;
|
||||||
use tools::tags::inie::IniE;
|
use xous_tools::tags::inie::IniE;
|
||||||
use tools::tags::memory::{MemoryRegion, MemoryRegions};
|
use xous_tools::tags::memory::{MemoryRegion, MemoryRegions};
|
||||||
use tools::tags::pnam::ProcessNames;
|
use xous_tools::tags::pnam::ProcessNames;
|
||||||
use tools::tags::xkrn::XousKernel;
|
use xous_tools::tags::xkrn::XousKernel;
|
||||||
use tools::xous_arguments::XousArguments;
|
use xous_tools::xous_arguments::XousArguments;
|
||||||
|
|
||||||
struct RamConfig {
|
struct RamConfig {
|
||||||
offset: u32,
|
offset: u32,
|
||||||
|
|
@ -21,7 +21,7 @@ struct RamConfig {
|
||||||
memory_required: u32,
|
memory_required: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn csr_to_config(hv: tools::utils::CsrConfig, ram_config: &mut RamConfig) {
|
fn csr_to_config(hv: xous_tools::utils::CsrConfig, ram_config: &mut RamConfig) {
|
||||||
let mut found_ram_name = None;
|
let mut found_ram_name = None;
|
||||||
fn round_mem(src: u32) -> u32 { (src + 4095) & !4095 }
|
fn round_mem(src: u32) -> u32 { (src + 4095) & !4095 }
|
||||||
// Look for the largest "ram" block, which we'll treat as main memory
|
// Look for the largest "ram" block, which we'll treat as main memory
|
||||||
|
|
@ -92,7 +92,7 @@ fn create_image(init_programs: &[String]) -> std::io::Result<Vec<u8>> {
|
||||||
} + PAGE_SIZE;
|
} + PAGE_SIZE;
|
||||||
map.insert(
|
map.insert(
|
||||||
region.name.to_lowercase(),
|
region.name.to_lowercase(),
|
||||||
tools::utils::CsrMemoryRegion {
|
xous_tools::utils::CsrMemoryRegion {
|
||||||
start: region.base.try_into().unwrap(),
|
start: region.base.try_into().unwrap(),
|
||||||
length: length.try_into().unwrap(),
|
length: length.try_into().unwrap(),
|
||||||
},
|
},
|
||||||
|
|
@ -100,14 +100,14 @@ fn create_image(init_programs: &[String]) -> std::io::Result<Vec<u8>> {
|
||||||
} else {
|
} else {
|
||||||
map.insert(
|
map.insert(
|
||||||
region.name.to_lowercase(),
|
region.name.to_lowercase(),
|
||||||
tools::utils::CsrMemoryRegion {
|
xous_tools::utils::CsrMemoryRegion {
|
||||||
start: region.base.try_into().unwrap(),
|
start: region.base.try_into().unwrap(),
|
||||||
length: region.size.try_into().unwrap(),
|
length: region.size.try_into().unwrap(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
csr_to_config(tools::utils::CsrConfig { regions: map }, &mut ram_config);
|
csr_to_config(xous_tools::utils::CsrConfig { regions: map }, &mut ram_config);
|
||||||
|
|
||||||
let mut args = XousArguments::new(ram_config.offset, ram_config.size, ram_config.name);
|
let mut args = XousArguments::new(ram_config.offset, ram_config.size, ram_config.name);
|
||||||
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
use tools::tags::memory::{MemoryRegion, MemoryRegions};
|
use xous_tools::tags::memory::{MemoryRegion, MemoryRegions};
|
||||||
use tools::tags::xkrn::XousKernel;
|
use xous_tools::tags::xkrn::XousKernel;
|
||||||
use tools::xous_arguments::{XousArguments, XousSize};
|
use xous_tools::xous_arguments::{XousArguments, XousSize};
|
||||||
|
|
||||||
const RAM_START: XousSize = 0x4000_0000;
|
const RAM_START: XousSize = 0x4000_0000;
|
||||||
const RAM_SIZE: XousSize = 4 * 1024 * 1024;
|
const RAM_SIZE: XousSize = 4 * 1024 * 1024;
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::io::{Error, ErrorKind};
|
use std::io::{Error, ErrorKind};
|
||||||
|
|
||||||
use clap::{App, Arg, crate_version};
|
use clap::{App, Arg, crate_version};
|
||||||
use tools::sign_image::{convert_to_uf2, load_pem, sign_file};
|
use xous_tools::sign_image::{convert_to_uf2, load_pem, sign_file};
|
||||||
|
|
||||||
const DEVKEY_PATH: &str = "devkey/dev.key";
|
const DEVKEY_PATH: &str = "devkey/dev.key";
|
||||||
|
|
||||||
|
|
@ -126,9 +126,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
// precursor uses the older style because we are avoiding updating the boot ROM in the SoC to avoid
|
// precursor uses the older style because we are avoiding updating the boot ROM in the SoC to avoid
|
||||||
// bricking.
|
// bricking.
|
||||||
let version = if matches.is_present("bao1x") {
|
let version = if matches.is_present("bao1x") {
|
||||||
tools::sign_image::Version::Bao1xV1
|
xous_tools::sign_image::Version::Bao1xV1
|
||||||
} else {
|
} else {
|
||||||
tools::sign_image::Version::Loader
|
xous_tools::sign_image::Version::Loader
|
||||||
};
|
};
|
||||||
sign_file(
|
sign_file(
|
||||||
&loader_image,
|
&loader_image,
|
||||||
|
|
@ -167,9 +167,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
}
|
||||||
println!("Signing kernel");
|
println!("Signing kernel");
|
||||||
let version = if matches.is_present("bao1x") {
|
let version = if matches.is_present("bao1x") {
|
||||||
tools::sign_image::Version::Bao1xV1
|
xous_tools::sign_image::Version::Bao1xV1
|
||||||
} else {
|
} else {
|
||||||
tools::sign_image::Version::LoaderPrehash
|
xous_tools::sign_image::Version::LoaderPrehash
|
||||||
};
|
};
|
||||||
sign_file(
|
sign_file(
|
||||||
&kernel_image,
|
&kernel_image,
|
||||||
|
|
@ -949,9 +949,9 @@ impl Builder {
|
||||||
.args([
|
.args([
|
||||||
"run",
|
"run",
|
||||||
"--package",
|
"--package",
|
||||||
"tools",
|
"xous-tools",
|
||||||
"--bin",
|
"--bin",
|
||||||
"copy-object",
|
"xous-copy-object",
|
||||||
"--",
|
"--",
|
||||||
&loader[0],
|
&loader[0],
|
||||||
presign_file.as_os_str().to_str().unwrap(),
|
presign_file.as_os_str().to_str().unwrap(),
|
||||||
|
|
@ -981,9 +981,9 @@ impl Builder {
|
||||||
.args([
|
.args([
|
||||||
"run",
|
"run",
|
||||||
"--package",
|
"--package",
|
||||||
"tools",
|
"xous-tools",
|
||||||
"--bin",
|
"--bin",
|
||||||
"sign-image",
|
"xous-sign-image",
|
||||||
"--",
|
"--",
|
||||||
"--loader-image",
|
"--loader-image",
|
||||||
presign_file.to_str().unwrap(),
|
presign_file.to_str().unwrap(),
|
||||||
|
|
@ -1075,9 +1075,9 @@ impl Builder {
|
||||||
.args([
|
.args([
|
||||||
"run",
|
"run",
|
||||||
"--package",
|
"--package",
|
||||||
"tools",
|
"xous-tools",
|
||||||
"--bin",
|
"--bin",
|
||||||
"copy-object",
|
"xous-copy-object",
|
||||||
"--",
|
"--",
|
||||||
&loader[0],
|
&loader[0],
|
||||||
loader_presign.as_os_str().to_str().unwrap(),
|
loader_presign.as_os_str().to_str().unwrap(),
|
||||||
|
|
@ -1094,9 +1094,9 @@ impl Builder {
|
||||||
.args([
|
.args([
|
||||||
"run",
|
"run",
|
||||||
"--package",
|
"--package",
|
||||||
"tools",
|
"xous-tools",
|
||||||
"--bin",
|
"--bin",
|
||||||
"sign-image",
|
"xous-sign-image",
|
||||||
"--",
|
"--",
|
||||||
"--loader-image",
|
"--loader-image",
|
||||||
loader_presign.to_str().unwrap(),
|
loader_presign.to_str().unwrap(),
|
||||||
|
|
@ -1120,9 +1120,9 @@ impl Builder {
|
||||||
.args([
|
.args([
|
||||||
"run",
|
"run",
|
||||||
"--package",
|
"--package",
|
||||||
"tools",
|
"xous-tools",
|
||||||
"--bin",
|
"--bin",
|
||||||
"sign-image",
|
"xous-sign-image",
|
||||||
"--",
|
"--",
|
||||||
"--loader-image",
|
"--loader-image",
|
||||||
loader_presign.to_str().unwrap(),
|
loader_presign.to_str().unwrap(),
|
||||||
|
|
@ -1148,9 +1148,9 @@ impl Builder {
|
||||||
.args([
|
.args([
|
||||||
"run",
|
"run",
|
||||||
"--package",
|
"--package",
|
||||||
"tools",
|
"xous-tools",
|
||||||
"--bin",
|
"--bin",
|
||||||
"sign-image",
|
"xous-sign-image",
|
||||||
"--",
|
"--",
|
||||||
"--kernel-image",
|
"--kernel-image",
|
||||||
output_bundle.to_str().unwrap(),
|
output_bundle.to_str().unwrap(),
|
||||||
|
|
@ -1175,9 +1175,9 @@ impl Builder {
|
||||||
.args([
|
.args([
|
||||||
"run",
|
"run",
|
||||||
"--package",
|
"--package",
|
||||||
"tools",
|
"xous-tools",
|
||||||
"--bin",
|
"--bin",
|
||||||
"sign-image",
|
"xous-sign-image",
|
||||||
"--",
|
"--",
|
||||||
"--kernel-image",
|
"--kernel-image",
|
||||||
output_bundle.to_str().unwrap(),
|
output_bundle.to_str().unwrap(),
|
||||||
|
|
@ -1213,7 +1213,7 @@ impl Builder {
|
||||||
memory_spec: Vec<String>,
|
memory_spec: Vec<String>,
|
||||||
) -> Result<PathBuf, DynError> {
|
) -> Result<PathBuf, DynError> {
|
||||||
let stream = self.stream.as_str();
|
let stream = self.stream.as_str();
|
||||||
let mut args = vec!["run", "--package", "tools", "--bin", "create-image"];
|
let mut args = vec!["run", "--package", "xous-tools", "--bin", "xous-create-image"];
|
||||||
args.push("--features");
|
args.push("--features");
|
||||||
if self.utra_target.contains("renode") {
|
if self.utra_target.contains("renode") {
|
||||||
args.push("renode");
|
args.push("renode");
|
||||||
|
|
@ -1304,7 +1304,7 @@ impl Builder {
|
||||||
fn create_detached_image(&self, inif: &[String]) -> Result<PathBuf, DynError> {
|
fn create_detached_image(&self, inif: &[String]) -> Result<PathBuf, DynError> {
|
||||||
assert!(self.board == "board-dabao", "Detached app images are only supported on dabao target");
|
assert!(self.board == "board-dabao", "Detached app images are only supported on dabao target");
|
||||||
let stream = self.stream.as_str();
|
let stream = self.stream.as_str();
|
||||||
let mut args = vec!["run", "--package", "tools", "--bin", "create-detached-app"];
|
let mut args = vec!["run", "--package", "xous-tools", "--bin", "xous-create-detached-app"];
|
||||||
args.push("--features");
|
args.push("--features");
|
||||||
args.push("bao1x");
|
args.push("bao1x");
|
||||||
args.push("--");
|
args.push("--");
|
||||||
|
|
@ -1341,9 +1341,9 @@ impl Builder {
|
||||||
.args([
|
.args([
|
||||||
"run",
|
"run",
|
||||||
"--package",
|
"--package",
|
||||||
"tools",
|
"xous-tools",
|
||||||
"--bin",
|
"--bin",
|
||||||
"sign-image",
|
"xous-sign-image",
|
||||||
"--",
|
"--",
|
||||||
"--kernel-image",
|
"--kernel-image",
|
||||||
output_file.to_str().unwrap(),
|
output_file.to_str().unwrap(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue