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:
bunnie 2026-01-30 02:16:17 +08:00
parent d2a320b9c6
commit fc6a4179bd
9 changed files with 71 additions and 71 deletions

View file

@ -1,8 +1,8 @@
[package]
authors = ["Sean Cross <sean@xobs.io>"]
default-run = "create-image"
default-run = "xous-create-image"
edition = "2018"
name = "tools"
name = "xous-tools"
version = "0.1.0"
# 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"
[[bin]]
name = "copy-object"
name = "xous-copy-object"
[[bin]]
name = "create-image"
name = "xous-create-image"
[[bin]]
name = "make-renode-boot"
name = "xous-make-renode-boot"
[[bin]]
name = "make-tags"
name = "xous-make-tags"
[[bin]]
name = "read-tags"
name = "xous-read-tags"
[[bin]]
name = "sign-image"
name = "xous-sign-image"
[[bin]]
name = "create-detached-app"
name = "xous-create-detached-app"
[features]
precursor = []

View file

@ -4,7 +4,7 @@ use std::io::Write;
use std::path::{Path, PathBuf};
use std::process;
use tools::elf;
use xous_tools::elf;
fn main() {
env_logger::init();

View file

@ -6,11 +6,11 @@ extern crate crc;
use std::fs::File;
use clap::{App, Arg};
use tools::elf::read_minielf;
use tools::tags::inif::IniF;
use tools::tags::pnam::ProcessNames;
use tools::utils::parse_u32;
use tools::xous_arguments::XousArguments;
use xous_tools::elf::read_minielf;
use xous_tools::tags::inif::IniF;
use xous_tools::tags::pnam::ProcessNames;
use xous_tools::utils::parse_u32;
use xous_tools::xous_arguments::XousArguments;
fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();

View file

@ -8,19 +8,19 @@ use std::fs::File;
use std::io::Read;
use clap::{App, Arg};
use tools::elf::{read_minielf, read_program};
use tools::sign_image::convert_to_uf2;
use tools::swap_writer::SwapWriter;
use tools::tags::bflg::Bflg;
use tools::tags::inie::IniE;
use tools::tags::inif::IniF;
use tools::tags::inis::IniS;
use tools::tags::memory::{MemoryRegion, MemoryRegions};
use tools::tags::pnam::ProcessNames;
use tools::tags::swap::Swap;
use tools::tags::xkrn::XousKernel;
use tools::utils::{parse_csr_csv, parse_u32};
use tools::xous_arguments::XousArguments;
use xous_tools::elf::{read_minielf, read_program};
use xous_tools::sign_image::convert_to_uf2;
use xous_tools::swap_writer::SwapWriter;
use xous_tools::tags::bflg::Bflg;
use xous_tools::tags::inie::IniE;
use xous_tools::tags::inif::IniF;
use xous_tools::tags::inis::IniS;
use xous_tools::tags::memory::{MemoryRegion, MemoryRegions};
use xous_tools::tags::pnam::ProcessNames;
use xous_tools::tags::swap::Swap;
use xous_tools::tags::xkrn::XousKernel;
use xous_tools::utils::{parse_csr_csv, parse_u32};
use xous_tools::xous_arguments::XousArguments;
const DEVKEY_PATH: &str = "devkey/dev.key";
@ -32,7 +32,7 @@ struct RamConfig {
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;
fn round_mem(src: u32) -> u32 { (src + 4095) & !4095 }
// 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;
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
xous_tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: length.try_into().unwrap(),
},
@ -291,7 +291,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} else {
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
xous_tools::utils::CsrMemoryRegion {
start: region.base.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);
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
xous_tools::utils::CsrMemoryRegion {
start: region.base.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.
@ -525,7 +525,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut sf =
File::create(sf_dbg).unwrap_or_else(|_| panic!("Couldn't create debug file {}", sf_dbg));
// 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()?)?;
// directly write our unencrypted data from sargs into file sf. It's an exact copy of
// what ended up in swap_buffer.

View file

@ -5,13 +5,13 @@ use std::convert::TryInto;
use std::fs::File;
use std::io::Write;
use tools::elf::{process_minielf, process_program, read_minielf};
use tools::sign_image::sign_image;
use tools::tags::inie::IniE;
use tools::tags::memory::{MemoryRegion, MemoryRegions};
use tools::tags::pnam::ProcessNames;
use tools::tags::xkrn::XousKernel;
use tools::xous_arguments::XousArguments;
use xous_tools::elf::{process_minielf, process_program, read_minielf};
use xous_tools::sign_image::sign_image;
use xous_tools::tags::inie::IniE;
use xous_tools::tags::memory::{MemoryRegion, MemoryRegions};
use xous_tools::tags::pnam::ProcessNames;
use xous_tools::tags::xkrn::XousKernel;
use xous_tools::xous_arguments::XousArguments;
struct RamConfig {
offset: u32,
@ -21,7 +21,7 @@ struct RamConfig {
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;
fn round_mem(src: u32) -> u32 { (src + 4095) & !4095 }
// 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;
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
xous_tools::utils::CsrMemoryRegion {
start: region.base.try_into().unwrap(),
length: length.try_into().unwrap(),
},
@ -100,14 +100,14 @@ fn create_image(init_programs: &[String]) -> std::io::Result<Vec<u8>> {
} else {
map.insert(
region.name.to_lowercase(),
tools::utils::CsrMemoryRegion {
xous_tools::utils::CsrMemoryRegion {
start: region.base.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);

View file

@ -1,8 +1,8 @@
use std::fs::File;
use tools::tags::memory::{MemoryRegion, MemoryRegions};
use tools::tags::xkrn::XousKernel;
use tools::xous_arguments::{XousArguments, XousSize};
use xous_tools::tags::memory::{MemoryRegion, MemoryRegions};
use xous_tools::tags::xkrn::XousKernel;
use xous_tools::xous_arguments::{XousArguments, XousSize};
const RAM_START: XousSize = 0x4000_0000;
const RAM_SIZE: XousSize = 4 * 1024 * 1024;

View file

@ -1,7 +1,7 @@
use std::io::{Error, ErrorKind};
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";
@ -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
// bricking.
let version = if matches.is_present("bao1x") {
tools::sign_image::Version::Bao1xV1
xous_tools::sign_image::Version::Bao1xV1
} else {
tools::sign_image::Version::Loader
xous_tools::sign_image::Version::Loader
};
sign_file(
&loader_image,
@ -167,9 +167,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
println!("Signing kernel");
let version = if matches.is_present("bao1x") {
tools::sign_image::Version::Bao1xV1
xous_tools::sign_image::Version::Bao1xV1
} else {
tools::sign_image::Version::LoaderPrehash
xous_tools::sign_image::Version::LoaderPrehash
};
sign_file(
&kernel_image,

View file

@ -949,9 +949,9 @@ impl Builder {
.args([
"run",
"--package",
"tools",
"xous-tools",
"--bin",
"copy-object",
"xous-copy-object",
"--",
&loader[0],
presign_file.as_os_str().to_str().unwrap(),
@ -981,9 +981,9 @@ impl Builder {
.args([
"run",
"--package",
"tools",
"xous-tools",
"--bin",
"sign-image",
"xous-sign-image",
"--",
"--loader-image",
presign_file.to_str().unwrap(),
@ -1075,9 +1075,9 @@ impl Builder {
.args([
"run",
"--package",
"tools",
"xous-tools",
"--bin",
"copy-object",
"xous-copy-object",
"--",
&loader[0],
loader_presign.as_os_str().to_str().unwrap(),
@ -1094,9 +1094,9 @@ impl Builder {
.args([
"run",
"--package",
"tools",
"xous-tools",
"--bin",
"sign-image",
"xous-sign-image",
"--",
"--loader-image",
loader_presign.to_str().unwrap(),
@ -1120,9 +1120,9 @@ impl Builder {
.args([
"run",
"--package",
"tools",
"xous-tools",
"--bin",
"sign-image",
"xous-sign-image",
"--",
"--loader-image",
loader_presign.to_str().unwrap(),
@ -1148,9 +1148,9 @@ impl Builder {
.args([
"run",
"--package",
"tools",
"xous-tools",
"--bin",
"sign-image",
"xous-sign-image",
"--",
"--kernel-image",
output_bundle.to_str().unwrap(),
@ -1175,9 +1175,9 @@ impl Builder {
.args([
"run",
"--package",
"tools",
"xous-tools",
"--bin",
"sign-image",
"xous-sign-image",
"--",
"--kernel-image",
output_bundle.to_str().unwrap(),
@ -1213,7 +1213,7 @@ impl Builder {
memory_spec: Vec<String>,
) -> Result<PathBuf, DynError> {
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");
if self.utra_target.contains("renode") {
args.push("renode");
@ -1304,7 +1304,7 @@ impl Builder {
fn create_detached_image(&self, inif: &[String]) -> Result<PathBuf, DynError> {
assert!(self.board == "board-dabao", "Detached app images are only supported on dabao target");
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("bao1x");
args.push("--");
@ -1341,9 +1341,9 @@ impl Builder {
.args([
"run",
"--package",
"tools",
"xous-tools",
"--bin",
"sign-image",
"xous-sign-image",
"--",
"--kernel-image",
output_file.to_str().unwrap(),