Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions ostool/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,19 @@ pub struct AppContext {

impl AppContext {
pub fn shell_run_cmd(&self, cmd: &str) -> anyhow::Result<()> {
let mut command = self.command("sh");
command.arg("-c");
let mut command = match std::env::consts::OS {
"windows" => {
let mut command = self.command("powershell");
command.arg("-Command");
command
}
_ => {
let mut command = self.command("sh");
command.arg("-c");
command
}
};

command.arg(cmd);

if let Some(elf) = &self.paths.artifacts.elf {
Expand Down
20 changes: 18 additions & 2 deletions ostool/src/run/uboot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ pub struct UbootConfig {
/// Kernel load address
/// if not specified, use U-Boot env variable 'loadaddr'
pub kernel_load_addr: Option<String>,
/// Fit Image load address
/// if not specified, use automatically calculated address
pub fit_load_addr: Option<String>,
/// TFTP boot configuration
pub net: Option<Net>,
/// Board reset command
Expand All @@ -54,7 +57,15 @@ pub struct UbootConfig {

impl UbootConfig {
pub fn kernel_load_addr_int(&self) -> Option<u64> {
self.kernel_load_addr.as_ref().and_then(|addr_str| {
self.addr_int(self.kernel_load_addr.as_ref())
}

pub fn fit_load_addr_int(&self) -> Option<u64> {
self.addr_int(self.fit_load_addr.as_ref())
}

fn addr_int(&self, addr_str: Option<&String>) -> Option<u64> {
addr_str.as_ref().and_then(|addr_str| {
if addr_str.starts_with("0x") || addr_str.starts_with("0X") {
u64::from_str_radix(&addr_str[2..], 16).ok()
} else {
Expand Down Expand Up @@ -398,7 +409,7 @@ impl Runner {
return Err(anyhow!("Cannot determine kernel entry address"));
};

let fit_loadaddr = if let Ok(addr) = uboot.env_int("kernel_comp_addr_r") {
let mut fit_loadaddr = if let Ok(addr) = uboot.env_int("kernel_comp_addr_r") {
info!("image load to kernel_comp_addr_r: {addr:#x}");
addr as u64
} else if let Ok(addr) = uboot.env_int("kernel_addr_c") {
Expand All @@ -410,6 +421,10 @@ impl Runner {
addr
};

if let Some(fit_load_addr_int) = self.config.fit_load_addr_int() {
fit_loadaddr = fit_load_addr_int;
}

uboot.set_env("loadaddr", format!("{:#x}", fit_loadaddr))?;

info!("fitimage loadaddr: {fit_loadaddr:#x}");
Expand Down Expand Up @@ -551,6 +566,7 @@ impl Runner {

let interfaces = NetworkInterface::show().unwrap();
for interface in interfaces.iter() {
debug!("net Interface: {}", interface.name);
if interface.name == net.interface {
let addr_list: Vec<Addr> = interface.addr.to_vec();
for one in addr_list {
Expand Down