From f8176c79bf49933c7adc446c187a03f935083007 Mon Sep 17 00:00:00 2001 From: Paigack <460852283@qq.com> Date: Thu, 1 Jan 2026 20:46:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(runner):=20=E6=B7=BB=E5=8A=A0=20Window?= =?UTF-8?q?s=20=E6=94=AF=E6=8C=81=E5=B9=B6=E5=A2=9E=E5=BC=BA=20U-Boot=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 Windows 系统添加 PowerShell 命令执行支持 - 添加 fit_load_addr 配置选项用于指定 FIT 镜像加载地址 - 提取地址解析逻辑到公共 addr_int 方法中 - 添加 U-Boot runner 启动日志信息 - 支持通过配置项覆盖 FIT 镜像加载地址 - 添加网络接口名称日志输出 --- ostool/src/ctx.rs | 15 +++++++++++++-- ostool/src/run/uboot.rs | 18 ++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/ostool/src/ctx.rs b/ostool/src/ctx.rs index e427dd7..be7f1cd 100644 --- a/ostool/src/ctx.rs +++ b/ostool/src/ctx.rs @@ -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 { diff --git a/ostool/src/run/uboot.rs b/ostool/src/run/uboot.rs index 6152bd6..24983a4 100644 --- a/ostool/src/run/uboot.rs +++ b/ostool/src/run/uboot.rs @@ -39,6 +39,7 @@ pub struct UbootConfig { /// Kernel load address /// if not specified, use U-Boot env variable 'loadaddr' pub kernel_load_addr: Option, + pub fit_load_addr: Option, /// TFTP boot configuration pub net: Option, /// Board reset command @@ -54,7 +55,15 @@ pub struct UbootConfig { impl UbootConfig { pub fn kernel_load_addr_int(&self) -> Option { - 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 { + self.addr_int(self.fit_load_addr.as_ref()) + } + + fn addr_int(&self, addr_str: Option<&String>) -> Option { + 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 { @@ -398,7 +407,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") { @@ -410,6 +419,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}"); @@ -551,6 +564,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 = interface.addr.to_vec(); for one in addr_list { From 9cd95779610fa0640689f443df958e800122ea37 Mon Sep 17 00:00:00 2001 From: rzhangsan <4iNtJYlBfhr1QT8bkeMawE+rzhangsan@noreply.cnb.cool> Date: Fri, 2 Jan 2026 21:32:17 +0800 Subject: [PATCH 2/2] docs: add comment for fit_load_addr field --- ostool/src/run/uboot.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ostool/src/run/uboot.rs b/ostool/src/run/uboot.rs index 24983a4..a00f32a 100644 --- a/ostool/src/run/uboot.rs +++ b/ostool/src/run/uboot.rs @@ -39,6 +39,8 @@ pub struct UbootConfig { /// Kernel load address /// if not specified, use U-Boot env variable 'loadaddr' pub kernel_load_addr: Option, + /// Fit Image load address + /// if not specified, use automatically calculated address pub fit_load_addr: Option, /// TFTP boot configuration pub net: Option,