mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
tools: rename from xous-tools
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
b9effd701b
commit
6959b4ef77
5 changed files with 55 additions and 33 deletions
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "xous-tools"
|
||||
name = "tools"
|
||||
version = "0.1.0"
|
||||
authors = ["Sean Cross <sean@xobs.io>"]
|
||||
edition = "2018"
|
||||
|
|
|
|||
|
|
@ -1,29 +1,35 @@
|
|||
// extern crate bootloader;
|
||||
// extern crate xmas_elf;
|
||||
extern crate xous_tools;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::env;
|
||||
use xous_tools::elf;
|
||||
use std::path::Path;
|
||||
use std::process;
|
||||
use tools::elf;
|
||||
|
||||
fn main() {
|
||||
env_logger::init();
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() < 2 {
|
||||
println!("Usage: {} input.elf [output.bin]", args.get(0).unwrap_or(&"copy-object".to_owned()));
|
||||
println!(
|
||||
"Usage: {} input.elf [output.bin]",
|
||||
args.get(0).unwrap_or(&"copy-object".to_owned())
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let input_filename = Path::new(args.get(1).unwrap()).to_path_buf();
|
||||
let output_filename = args.get(2).map(|x| Path::new(x).to_path_buf()).unwrap_or_else(|| {
|
||||
let mut output_filename = input_filename.clone();
|
||||
output_filename.set_extension("bin");
|
||||
output_filename
|
||||
});
|
||||
let output_filename = args
|
||||
.get(2)
|
||||
.map(|x| Path::new(x).to_path_buf())
|
||||
.unwrap_or_else(|| {
|
||||
let mut output_filename = input_filename.clone();
|
||||
output_filename.set_extension("bin");
|
||||
output_filename
|
||||
});
|
||||
if output_filename == input_filename {
|
||||
eprintln!("Input and output filename are the same: {}", output_filename.display());
|
||||
eprintln!(
|
||||
"Input and output filename are the same: {}",
|
||||
output_filename.display()
|
||||
);
|
||||
eprintln!("Specify an output path, or change the suffix of your input file from \".bin\"");
|
||||
process::exit(1);
|
||||
}
|
||||
|
|
@ -32,11 +38,19 @@ fn main() {
|
|||
process::exit(1);
|
||||
});
|
||||
let mut f = File::create(&output_filename).unwrap_or_else(|e| {
|
||||
eprintln!("Couldn't create output file {}: {}", output_filename.display(), e);
|
||||
eprintln!(
|
||||
"Couldn't create output file {}: {}",
|
||||
output_filename.display(),
|
||||
e
|
||||
);
|
||||
process::exit(1);
|
||||
});
|
||||
f.write_all(&pd.program).unwrap_or_else(|e| {
|
||||
eprintln!("Couldn't write data to {}: {}", output_filename.display(), e);
|
||||
eprintln!(
|
||||
"Couldn't write data to {}: {}",
|
||||
output_filename.display(),
|
||||
e
|
||||
);
|
||||
process::exit(1);
|
||||
});
|
||||
|
||||
|
|
@ -44,5 +58,9 @@ fn main() {
|
|||
println!("Data size: {}", pd.data_size);
|
||||
println!("Text offset: {:08x}", pd.text_offset);
|
||||
println!("Entrypoint: {:08x}", pd.entry_point);
|
||||
println!("Copied {} bytes of data to {}", pd.program.len(), output_filename.display());
|
||||
println!(
|
||||
"Copied {} bytes of data to {}",
|
||||
pd.program.len(),
|
||||
output_filename.display()
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ extern crate crc;
|
|||
|
||||
use std::fs::File;
|
||||
|
||||
use xous_tools::elf::{read_minielf, read_program};
|
||||
use xous_tools::tags::bflg::Bflg;
|
||||
use xous_tools::tags::inie::IniE;
|
||||
use xous_tools::tags::memory::{MemoryRegion, MemoryRegions};
|
||||
use xous_tools::tags::xkrn::XousKernel;
|
||||
use xous_tools::utils::{parse_csr_csv, parse_u32};
|
||||
use xous_tools::xous_arguments::XousArguments;
|
||||
use tools::elf::{read_minielf, read_program};
|
||||
use tools::tags::bflg::Bflg;
|
||||
use tools::tags::inie::IniE;
|
||||
use tools::tags::memory::{MemoryRegion, MemoryRegions};
|
||||
use tools::tags::xkrn::XousKernel;
|
||||
use tools::utils::{parse_csr_csv, parse_u32};
|
||||
use tools::xous_arguments::XousArguments;
|
||||
|
||||
use clap::{App, Arg};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
extern crate xous_tools;
|
||||
|
||||
use std::fs::File;
|
||||
|
||||
use xous_tools::make_type;
|
||||
// use xous_tools::tags::init::Init;
|
||||
use xous_tools::tags::memory::{MemoryRegion, MemoryRegions};
|
||||
use xous_tools::tags::xkrn::XousKernel;
|
||||
use xous_tools::xous_arguments::{XousArguments, XousSize};
|
||||
use tools::make_type;
|
||||
use tools::tags::memory::{MemoryRegion, MemoryRegions};
|
||||
use tools::tags::xkrn::XousKernel;
|
||||
use tools::xous_arguments::{XousArguments, XousSize};
|
||||
|
||||
const RAM_START: XousSize = 0x40000000;
|
||||
const RAM_SIZE: XousSize = 4 * 1024 * 1024;
|
||||
|
|
@ -36,7 +33,13 @@ fn main() {
|
|||
// args.add(init);
|
||||
|
||||
let xkrn = XousKernel::new(
|
||||
0x20500000, 65536, 0x02000000, 0x04000000, 32768, 5678, vec![],
|
||||
0x20500000,
|
||||
65536,
|
||||
0x02000000,
|
||||
0x04000000,
|
||||
32768,
|
||||
5678,
|
||||
vec![],
|
||||
);
|
||||
args.add(xkrn);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::io::prelude::*;
|
|||
use std::path::Path;
|
||||
use std::process;
|
||||
use std::slice;
|
||||
use xous_tools::make_type;
|
||||
use tools::make_type;
|
||||
|
||||
fn read_next_tag(b8: *mut u8, byte_offset: &mut usize) -> Result<(u32, u16, u32), ()> {
|
||||
let tag_name = u32::from_le(unsafe { (b8 as *mut u32).add(*byte_offset / 4).read() }) as u32;
|
||||
|
|
@ -20,7 +20,8 @@ fn read_next_tag(b8: *mut u8, byte_offset: &mut usize) -> Result<(u32, u16, u32)
|
|||
|
||||
fn print_tag(b8: *mut u8, size: u32, crc: u16, byte_offset: &mut usize) -> Result<(), ()> {
|
||||
let data = unsafe { slice::from_raw_parts(b8.add(*byte_offset) as *const u8, size as usize) };
|
||||
let data_32 = unsafe { slice::from_raw_parts(b8.add(*byte_offset) as *const u32, size as usize / 4) };
|
||||
let data_32 =
|
||||
unsafe { slice::from_raw_parts(b8.add(*byte_offset) as *const u32, size as usize / 4) };
|
||||
*byte_offset += size as usize;
|
||||
|
||||
let mut digest = crc16::Digest::new(crc16::X25);
|
||||
|
|
|
|||
Loading…
Reference in a new issue