From 968173095eed750285332da9b270705906a3a6bb Mon Sep 17 00:00:00 2001 From: Noah <2+noah@noreply.gitea.bluefla.re> Date: Mon, 16 Nov 2026 12:03:07 -0600 Subject: [PATCH 1/4] feat(gui): A113D install support + flag-restore + headless bench driver - stock_ops: add "a113d" to SUPPORTED_BOARDS so the GUI offers A113D install (it was zynq-7010 only); add start_restore_flag() - the A113D restore is the in-band ALAN flag flip (install overwrites no stock partition), which the GUI lacked a clean path for (start_restore needs a firmware file, which the A113D ignores). - bench_sequence (new) + main.rs ALKANE_BENCH_SEQUENCE: a headless driver that drives the real GUI operation layer (start_install(AfwSource::Local) -> verify -> start_restore_flag) through the A113D network-only install<->restore cycle, no wx window. Classifies stock vs alkane by SSH dropbear version / HTTP. Hardware status (bench A113D, 2026-11-16): the install leg is PROVEN on real hardware via the GUI operation layer. The verify/restore legs are NOT yet validated end-to-end because the 0.1.0 a113d alkane image does not fully boot on the bench board (kernel+eth up, no DHCP/SSH) - an alkane-os image bringup issue, tracked separately. Known limitation: the driver assumes the board keeps its IP across reboots; it should re-discover the board (A113D can change/lose its lease under alkane). Not released pending a working image + the discovery fix. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i --- crates/alkane-gui/src/bench_sequence.rs | 237 ++++++++++++++++++++++++ crates/alkane-gui/src/main.rs | 17 +- crates/alkane-gui/src/stock_ops.rs | 68 ++++++- 3 files changed, 318 insertions(+), 4 deletions(-) create mode 100644 crates/alkane-gui/src/bench_sequence.rs diff --git a/crates/alkane-gui/src/bench_sequence.rs b/crates/alkane-gui/src/bench_sequence.rs new file mode 100644 index 00000000..ceb51388 --- /dev/null +++ b/crates/alkane-gui/src/bench_sequence.rs @@ -0,0 +1,237 @@ +//! Headless bench automation (`ALKANE_BENCH_SEQUENCE`): drive the GUI's real +//! install/restore operation layer (`stock_ops`) through the A113D network-only +//! install <-> flag-restore cycle, with no window. This exercises the GUI +//! operator flow end-to-end against real hardware, for bench proofs, without the +//! wx event loop (the worker functions stream progress over a channel, exactly +//! as the UI drains them). +//! +//! Spec: `ALKANE_BENCH_SEQUENCE=" [iterations]"`. +//! The alkane root credential is read from the saved SSH credentials file. +//! +//! On the A113D, "restore to stock" is the one-byte flag flip (the install +//! overwrites no stock partition), so the cycle is: install (stock -> alkane) -> +//! verify alkane -> restore (flag flip -> stock) -> verify stock. + +use std::io::Read; +use std::net::TcpStream; +use std::path::PathBuf; +use std::process::Command; +use std::time::{Duration, Instant}; + +use crate::credentials; +use crate::stock_ops::{self, AfwSource, StockHandle, StockMsg}; + +/// Drain a `StockHandle` to completion, printing progress; returns true iff +/// every board reported ok and at least one `Result` arrived. +fn drive(label: &str, handle: StockHandle) -> bool { + let mut ok = true; + let mut saw = false; + loop { + match handle.rx.recv() { + Ok(StockMsg::Started) => println!(" [{label}] started"), + Ok(StockMsg::Progress(s)) => println!(" [{label}] {s}"), + Ok(StockMsg::Result { ip, ok: r, detail }) => { + saw = true; + ok = ok && r; + println!( + " [{label}] {ip}: {} - {detail}", + if r { "OK" } else { "FAIL" } + ); + } + Ok(StockMsg::Done) => break, + Err(_) => { + println!(" [{label}] channel closed early"); + ok = false; + break; + } + } + } + ok && saw +} + +/// Read the SSH identification banner (no auth), e.g. `SSH-2.0-dropbear_2026.93`. +fn ssh_banner(host: &str) -> Option { + let addr: std::net::SocketAddr = format!("{host}:22").parse().ok()?; + let mut stream = TcpStream::connect_timeout(&addr, Duration::from_secs(5)).ok()?; + stream + .set_read_timeout(Some(Duration::from_secs(5))) + .ok()?; + let mut buf = [0u8; 256]; + let n = stream.read(&mut buf).ok()?; + if n == 0 { + return None; + } + Some( + String::from_utf8_lossy(&buf[..n]) + .lines() + .next() + .unwrap_or("") + .trim() + .to_string(), + ) +} + +/// HTTP server header probe (stock serves lighttpd / an antMiner realm). +fn http_is_stock(host: &str) -> Option { + let out = Command::new("curl") + .args([ + "-sS", + "-m", + "6", + "-o", + "/dev/null", + "-D", + "-", + &format!("http://{host}/"), + ]) + .output() + .ok()?; + let h = String::from_utf8_lossy(&out.stdout).to_lowercase(); + if h.is_empty() { + None + } else if h.contains("lighttpd") || h.contains("antminer configuration") { + Some(true) + } else { + Some(false) + } +} + +/// Classify the board: `Some(true)` = looks like genuine stock, `Some(false)` = +/// looks like alkane, `None` = no decisive answer (e.g. mid-reboot). +/// +/// Primary signal is the SSH banner: stock A113D is `dropbear_2018.76`; alkane +/// ships a much newer dropbear. HTTP (lighttpd) is a stock fallback. +fn classify(host: &str) -> (String, Option) { + let banner = ssh_banner(host); + if let Some(b) = &banner { + let lb = b.to_lowercase(); + if lb.contains("dropbear_2018") || lb.contains("dropbear_2019") { + return (format!("ssh \"{b}\" -> stock"), Some(true)); + } + if lb.contains("dropbear") || lb.contains("openssh") { + return (format!("ssh \"{b}\" -> alkane"), Some(false)); + } + } + match http_is_stock(host) { + Some(true) => ("http lighttpd/antMiner -> stock".to_string(), Some(true)), + Some(false) => ("http non-stock -> alkane".to_string(), Some(false)), + None => ( + banner + .map(|b| format!("ssh \"{b}\" (unclassified), no http")) + .unwrap_or_else(|| "no ssh, no http (mid-reboot?)".to_string()), + None, + ), + } +} + +/// Poll `classify` until it reaches the wanted stock-ness, or `timeout` elapses. +fn wait_for(host: &str, want_stock: bool, timeout: Duration) -> (String, bool) { + let deadline = Instant::now() + timeout; + let mut last; + loop { + let (desc, is_stock) = classify(host); + last = desc; + if is_stock == Some(want_stock) { + return (last, true); + } + if Instant::now() >= deadline { + return (last, false); + } + std::thread::sleep(Duration::from_secs(5)); + } +} + +pub fn run(spec: &str) -> i32 { + let mut it = spec.split_whitespace(); + let host = match it.next() { + Some(h) => h.to_string(), + None => { + eprintln!("ALKANE_BENCH_SEQUENCE=\" [iterations]\""); + return 2; + } + }; + let afw = match it.next() { + Some(a) => PathBuf::from(a), + None => { + eprintln!("missing local .afw path"); + return 2; + } + }; + let iterations: u32 = it.next().and_then(|s| s.parse().ok()).unwrap_or(1); + let board = "a113d".to_string(); + // The A113D flag-restore reaches the running alkane board over SSH as root, + // so use the saved SSH credential (not the web/API one). Install reaches + // stock via the compiled-in method (its own root access); the same password + // is passed through, matching the GUI's single-credential model. + let password = credentials::load_ssh_credentials().map(|(_, p)| p); + + println!("== A113D headless GUI bench sequence (network-only install <-> flag-restore) =="); + println!( + "host={host} afw={} board={board} iterations={iterations} credential={}", + afw.display(), + if password.is_some() { "loaded" } else { "none" } + ); + if !afw.exists() { + eprintln!("afw not found: {}", afw.display()); + return 2; + } + + let boot_timeout = Duration::from_secs(300); + let mut all_ok = true; + + for i in 1..=iterations { + println!("\n-- iteration {i}/{iterations} --"); + + // 1. install (stock -> alkane) through the GUI operation layer + println!("[1/4] install: stock -> alkane"); + let h = stock_ops::start_install( + vec![host.clone()], + board.clone(), + AfwSource::Local(afw.clone()), + true, // allow unsigned (bench image) + password.clone(), + false, // not an in-place update + ); + if !drive("install", h) { + all_ok = false; + println!("[1/4] install FAILED; aborting"); + break; + } + + // 2. verify alkane is live (board reboots into alkane) + println!( + "[2/4] verify alkane (awaiting reboot, up to {}s)...", + boot_timeout.as_secs() + ); + let (desc, ok) = wait_for(&host, false, boot_timeout); + println!(" {desc} => {}", if ok { "ALKANE" } else { "NOT ALKANE (fail)" }); + all_ok = all_ok && ok; + + // 3. restore (alkane -> stock) flag-flip through the GUI operation layer + println!("[3/4] restore: alkane -> stock (flag flip)"); + let h = stock_ops::start_restore_flag(vec![host.clone()], password.clone()); + if !drive("restore", h) { + all_ok = false; + println!("[3/4] restore FAILED"); + } + + // 4. verify stock is back + println!( + "[4/4] verify stock (awaiting reboot, up to {}s)...", + boot_timeout.as_secs() + ); + let (desc, ok) = wait_for(&host, true, boot_timeout); + println!(" {desc} => {}", if ok { "STOCK" } else { "NOT STOCK (fail)" }); + all_ok = all_ok && ok; + } + + println!( + "\n== BENCH RESULT: {} ==", + if all_ok { "PASS" } else { "FAIL" } + ); + if all_ok { + 0 + } else { + 1 + } +} diff --git a/crates/alkane-gui/src/main.rs b/crates/alkane-gui/src/main.rs index 02c53c5f..bbced90d 100644 --- a/crates/alkane-gui/src/main.rs +++ b/crates/alkane-gui/src/main.rs @@ -8,6 +8,7 @@ mod access_probe; mod alkane_detect; mod askpass; +mod bench_sequence; mod bug_report; mod credentials; mod export; @@ -41,6 +42,13 @@ fn main() { std::process::exit(run_selftest()); } + // Headless bench automation: drive the real install/restore operation layer + // (stock_ops) through the A113D network-only install <-> flag-restore cycle + // against real hardware, with no window. See bench_sequence.rs. + if let Some(spec) = std::env::var_os("ALKANE_BENCH_SEQUENCE") { + std::process::exit(bench_sequence::run(&spec.to_string_lossy())); + } + // Headless access-probe check: `ALKANE_ACCESS_PROBE=" "` prints the // lock state the real access probe computes (no GUI, no wx), so the WhatsMiner // :4028 token check and the Antminer digest check can be verified directly. @@ -123,8 +131,13 @@ fn run_selftest() -> i32 { /// True when the process runs one of the headless check modes instead of the GUI. fn headless_mode() -> bool { - ["ALKANE_SELFTEST", "ALKANE_ACCESS_PROBE", "ALKANE_LOG_SCAN"] - .iter() + [ + "ALKANE_SELFTEST", + "ALKANE_ACCESS_PROBE", + "ALKANE_LOG_SCAN", + "ALKANE_BENCH_SEQUENCE", + ] + .iter() .any(|v| std::env::var_os(v).is_some()) } diff --git a/crates/alkane-gui/src/stock_ops.rs b/crates/alkane-gui/src/stock_ops.rs index abb37cd7..1cb88121 100644 --- a/crates/alkane-gui/src/stock_ops.rs +++ b/crates/alkane-gui/src/stock_ops.rs @@ -24,8 +24,10 @@ use crate::scan::fake_scan_enabled; /// Control boards alkane-os can be installed onto from stock (mirrors the CLI's /// `SUPPORTED`). Only these are offered as install targets. -pub const SUPPORTED_BOARDS: &[(&str, &str)] = - &[("zynq-7010", "Antminer S17 (Xilinx Zynq-7010 control board)")]; +pub const SUPPORTED_BOARDS: &[(&str, &str)] = &[ + ("zynq-7010", "Antminer S17 (Xilinx Zynq-7010 control board)"), + ("a113d", "Antminer S19j Pro (Amlogic A113D/AXG control board)"), +]; /// The default install board when the user has not chosen another. pub const DEFAULT_BOARD: &str = "zynq-7010"; @@ -408,3 +410,65 @@ pub fn start_restore_onboard(ips: Vec, password: Option) -> Stoc } StockHandle { rx, cancel } } + +/// Restore the given alkane A113D boards to genuine Bitmain stock, over the +/// network, by clearing the one-byte boot flag in-band from the running alkane +/// OS. The A113D install overwrites no stock partition, so this flag flip is the +/// complete restore: clear `ALAN`, reboot, and stock boots via `storeboot` from +/// the untouched `boot` MTD. No vendor firmware file or on-board backup needed. +/// `password`, if set, is the board's alkane root credential. +pub fn start_restore_flag(ips: Vec, password: Option) -> StockHandle { + let (tx, rx) = channel(); + let cancel = Arc::new(AtomicBool::new(false)); + + if fake_scan_enabled() { + let _ = tx.send(StockMsg::Started); + for ip in ips { + let _ = tx.send(StockMsg::Result { + ip, + ok: true, + detail: "restored to stock (flag flip, demo)".into(), + }); + } + let _ = tx.send(StockMsg::Done); + return StockHandle { rx, cancel }; + } + + let tc = cancel.clone(); + let err_tx = tx.clone(); + let spawned = std::thread::Builder::new() + .name("restore-flag".into()) + .spawn(move || { + let _ = tx.send(StockMsg::Started); + for ip in ips { + if tc.load(Ordering::Relaxed) { + break; + } + let _ = tx.send(StockMsg::Progress(format!( + "restoring {ip} to stock (clearing the alkane boot flag)..." + ))); + let (ok, detail) = match stock::restore_aml_flag(&ip, password.as_deref()) { + Ok(()) => ( + true, + "restored to stock (flag cleared, rebooting; verify over the network)" + .to_string(), + ), + Err(e) => (false, format!("restore failed: {e}")), + }; + if tx.send(StockMsg::Result { ip, ok, detail }).is_err() { + return; + } + } + let _ = tx.send(StockMsg::Done); + }); + + if spawned.is_err() { + let _ = err_tx.send(StockMsg::Result { + ip: String::new(), + ok: false, + detail: "could not start the restore worker thread".into(), + }); + let _ = err_tx.send(StockMsg::Done); + } + StockHandle { rx, cancel } +} -- 2.54.0 From f6c740bc24cb53134a918be21ad2ef542f4ec50b Mon Sep 17 00:00:00 2001 From: Noah <2+noah@noreply.gitea.bluefla.re> Date: Mon, 16 Nov 2026 12:22:40 -0600 Subject: [PATCH 2/4] fix(gui): headless bench driver re-finds the board by MAC across reboots The A113D can take a different DHCP lease (or lose its v4 lease) across the install/restore reboots, so assuming the board keeps its initial IP broke the verify/restore steps. Resolve the board's MAC up front (on stock) and, after each reboot, re-locate it in the neighbour table (sweeping the /24 when it is not cached) so verify and the flag-restore target the board's CURRENT address. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i --- crates/alkane-gui/src/bench_sequence.rs | 101 +++++++++++++++++++++--- 1 file changed, 89 insertions(+), 12 deletions(-) diff --git a/crates/alkane-gui/src/bench_sequence.rs b/crates/alkane-gui/src/bench_sequence.rs index ceb51388..fb089cb3 100644 --- a/crates/alkane-gui/src/bench_sequence.rs +++ b/crates/alkane-gui/src/bench_sequence.rs @@ -124,18 +124,87 @@ fn classify(host: &str) -> (String, Option) { } } -/// Poll `classify` until it reaches the wanted stock-ness, or `timeout` elapses. -fn wait_for(host: &str, want_stock: bool, timeout: Duration) -> (String, bool) { +/// The MAC (lladdr) the kernel has cached for `host` (pings first to populate). +fn mac_of(host: &str) -> Option { + let _ = Command::new("ping") + .args(["-c", "1", "-W", "1", host]) + .output(); + let out = Command::new("ip").args(["neigh", "show", host]).output().ok()?; + let s = String::from_utf8_lossy(&out.stdout); + let mut it = s.split_whitespace(); + while let Some(t) = it.next() { + if t == "lladdr" { + return it.next().map(|m| m.to_lowercase()); + } + } + None +} + +/// Populate the neighbour table by parallel-pinging the /24 of `sample` (a bench +/// board can take a different DHCP lease across a reboot, so we must re-find it). +fn sweep_subnet(sample: &str) { + let base = match sample.rsplit_once('.') { + Some((net, _)) => net.to_string(), + None => return, + }; + let mut kids = Vec::new(); + for h in 2..=254 { + if let Ok(c) = Command::new("ping") + .args(["-c", "1", "-W", "1", &format!("{base}.{h}")]) + .stdout(std::process::Stdio::null()) + .stderr(std::process::Stdio::null()) + .spawn() + { + kids.push(c); + } + } + for mut c in kids { + let _ = c.wait(); + } +} + +/// Current IPv4 for `mac` from the neighbour table, if present. +fn ip_for_mac(mac: &str) -> Option { + let out = Command::new("ip").args(["neigh"]).output().ok()?; + let s = String::from_utf8_lossy(&out.stdout); + let mac = mac.to_lowercase(); + for line in s.lines() { + if line.to_lowercase().contains(&mac) { + if let Some(ip) = line.split_whitespace().next() { + if ip.contains('.') { + return Some(ip.to_string()); + } + } + } + } + None +} + +/// Poll until the board (located by MAC, so a changed DHCP lease is followed) +/// reaches the wanted stock-ness, or `timeout` elapses. Returns the board's +/// current IP, a description, and whether the target state was reached. +fn wait_for(mac: Option<&str>, fallback: &str, want_stock: bool, timeout: Duration) -> (String, String, bool) { let deadline = Instant::now() + timeout; - let mut last; + let mut ip = fallback.to_string(); + let mut swept = Instant::now() - Duration::from_secs(60); loop { - let (desc, is_stock) = classify(host); - last = desc; + // Re-locate by MAC; sweep the subnet at most every ~25s to catch a new lease. + if let Some(m) = mac { + if ip_for_mac(m).is_none() && swept.elapsed() >= Duration::from_secs(25) { + sweep_subnet(fallback); + swept = Instant::now(); + } + if let Some(found) = ip_for_mac(m) { + ip = found; + } + } + let (desc, is_stock) = classify(&ip); + let line = format!("[{ip}] {desc}"); if is_stock == Some(want_stock) { - return (last, true); + return (ip, line, true); } if Instant::now() >= deadline { - return (last, false); + return (ip, line, false); } std::thread::sleep(Duration::from_secs(5)); } @@ -176,6 +245,14 @@ pub fn run(spec: &str) -> i32 { return 2; } + // Resolve the board's MAC now (on stock) so we can re-find it after each + // reboot even if its DHCP lease changes under alkane. + let mac = mac_of(&host); + println!( + "board MAC: {}", + mac.as_deref().unwrap_or("unknown (will use the fixed host)") + ); + let boot_timeout = Duration::from_secs(300); let mut all_ok = true; @@ -203,13 +280,13 @@ pub fn run(spec: &str) -> i32 { "[2/4] verify alkane (awaiting reboot, up to {}s)...", boot_timeout.as_secs() ); - let (desc, ok) = wait_for(&host, false, boot_timeout); + let (alkane_ip, desc, ok) = wait_for(mac.as_deref(), &host, false, boot_timeout); println!(" {desc} => {}", if ok { "ALKANE" } else { "NOT ALKANE (fail)" }); all_ok = all_ok && ok; - // 3. restore (alkane -> stock) flag-flip through the GUI operation layer - println!("[3/4] restore: alkane -> stock (flag flip)"); - let h = stock_ops::start_restore_flag(vec![host.clone()], password.clone()); + // 3. restore (alkane -> stock) flag-flip at the board's CURRENT address + println!("[3/4] restore: alkane -> stock (flag flip) at {alkane_ip}"); + let h = stock_ops::start_restore_flag(vec![alkane_ip.clone()], password.clone()); if !drive("restore", h) { all_ok = false; println!("[3/4] restore FAILED"); @@ -220,7 +297,7 @@ pub fn run(spec: &str) -> i32 { "[4/4] verify stock (awaiting reboot, up to {}s)...", boot_timeout.as_secs() ); - let (desc, ok) = wait_for(&host, true, boot_timeout); + let (_stock_ip, desc, ok) = wait_for(mac.as_deref(), &host, true, boot_timeout); println!(" {desc} => {}", if ok { "STOCK" } else { "NOT STOCK (fail)" }); all_ok = all_ok && ok; } -- 2.54.0 From 71ab5a957c35d50f27fc66e9e3910a6596142c43 Mon Sep 17 00:00:00 2001 From: Noah <2+noah@noreply.gitea.bluefla.re> Date: Mon, 16 Nov 2026 13:22:48 -0600 Subject: [PATCH 3/4] fix(gui): bench driver uses the alkane root credential for the restore leg The flag-restore reaches the running alkane board over SSH as root, which is a different credential from the stock login used for install. Alkane bench images bake root/alkane; pass that (overridable via ALKANE_ROOT_PASSWORD) to the restore, and keep the saved board SSH credential for the install. The previous single-credential handoff sent the stock login to the alkane root restore and hit "Permission denied". Hardware note (2026-11-16): the PHY-fixed afw installs and comes up REACHABLE on alkane (both the image PHY fix and the driver's MAC rediscovery proven); the in-band flag-restore still needs the alkane DTB to expose the `misc` MTD (it currently exposes only nvdata), tracked separately. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i --- crates/alkane-gui/src/bench_sequence.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/crates/alkane-gui/src/bench_sequence.rs b/crates/alkane-gui/src/bench_sequence.rs index fb089cb3..d345ac9d 100644 --- a/crates/alkane-gui/src/bench_sequence.rs +++ b/crates/alkane-gui/src/bench_sequence.rs @@ -228,17 +228,22 @@ pub fn run(spec: &str) -> i32 { }; let iterations: u32 = it.next().and_then(|s| s.parse().ok()).unwrap_or(1); let board = "a113d".to_string(); - // The A113D flag-restore reaches the running alkane board over SSH as root, - // so use the saved SSH credential (not the web/API one). Install reaches - // stock via the compiled-in method (its own root access); the same password - // is passed through, matching the GUI's single-credential model. - let password = credentials::load_ssh_credentials().map(|(_, p)| p); + // Install reaches STOCK via the compiled-in from-stock method; pass the saved + // board SSH credential through to it. + let stock_password = credentials::load_ssh_credentials().map(|(_, p)| p); + // The flag-restore reaches the running ALKANE board over SSH as `root` - a + // DIFFERENT credential from the stock login. Alkane bench images bake + // root/alkane; allow an override via ALKANE_ROOT_PASSWORD. + let alkane_password = std::env::var("ALKANE_ROOT_PASSWORD") + .ok() + .or_else(|| Some("alkane".to_string())); println!("== A113D headless GUI bench sequence (network-only install <-> flag-restore) =="); println!( - "host={host} afw={} board={board} iterations={iterations} credential={}", + "host={host} afw={} board={board} iterations={iterations} stock_cred={} alkane_cred={}", afw.display(), - if password.is_some() { "loaded" } else { "none" } + if stock_password.is_some() { "loaded" } else { "none" }, + if alkane_password.is_some() { "set" } else { "none" } ); if !afw.exists() { eprintln!("afw not found: {}", afw.display()); @@ -266,7 +271,7 @@ pub fn run(spec: &str) -> i32 { board.clone(), AfwSource::Local(afw.clone()), true, // allow unsigned (bench image) - password.clone(), + stock_password.clone(), false, // not an in-place update ); if !drive("install", h) { @@ -286,7 +291,7 @@ pub fn run(spec: &str) -> i32 { // 3. restore (alkane -> stock) flag-flip at the board's CURRENT address println!("[3/4] restore: alkane -> stock (flag flip) at {alkane_ip}"); - let h = stock_ops::start_restore_flag(vec![alkane_ip.clone()], password.clone()); + let h = stock_ops::start_restore_flag(vec![alkane_ip.clone()], alkane_password.clone()); if !drive("restore", h) { all_ok = false; println!("[3/4] restore FAILED"); -- 2.54.0 From 12a11edfd7d999bf387522e3bd7abfe39745e696 Mon Sep 17 00:00:00 2001 From: Noah <2+noah@noreply.gitea.bluefla.re> Date: Mon, 16 Nov 2026 22:46:43 -0600 Subject: [PATCH 4/4] style: rustfmt the A113D GUI install + headless bench driver cargo fmt -p alkane-gui; no logic change. This branch's CI never ran before (its verify was skipped), so the formatting was never enforced. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i --- crates/alkane-gui/src/bench_sequence.rs | 31 ++++++++++++++++++------- crates/alkane-gui/src/main.rs | 2 +- crates/alkane-gui/src/stock_ops.rs | 5 +++- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/crates/alkane-gui/src/bench_sequence.rs b/crates/alkane-gui/src/bench_sequence.rs index d345ac9d..d251d8e9 100644 --- a/crates/alkane-gui/src/bench_sequence.rs +++ b/crates/alkane-gui/src/bench_sequence.rs @@ -53,9 +53,7 @@ fn drive(label: &str, handle: StockHandle) -> bool { fn ssh_banner(host: &str) -> Option { let addr: std::net::SocketAddr = format!("{host}:22").parse().ok()?; let mut stream = TcpStream::connect_timeout(&addr, Duration::from_secs(5)).ok()?; - stream - .set_read_timeout(Some(Duration::from_secs(5))) - .ok()?; + stream.set_read_timeout(Some(Duration::from_secs(5))).ok()?; let mut buf = [0u8; 256]; let n = stream.read(&mut buf).ok()?; if n == 0 { @@ -129,7 +127,10 @@ fn mac_of(host: &str) -> Option { let _ = Command::new("ping") .args(["-c", "1", "-W", "1", host]) .output(); - let out = Command::new("ip").args(["neigh", "show", host]).output().ok()?; + let out = Command::new("ip") + .args(["neigh", "show", host]) + .output() + .ok()?; let s = String::from_utf8_lossy(&out.stdout); let mut it = s.split_whitespace(); while let Some(t) = it.next() { @@ -183,7 +184,12 @@ fn ip_for_mac(mac: &str) -> Option { /// Poll until the board (located by MAC, so a changed DHCP lease is followed) /// reaches the wanted stock-ness, or `timeout` elapses. Returns the board's /// current IP, a description, and whether the target state was reached. -fn wait_for(mac: Option<&str>, fallback: &str, want_stock: bool, timeout: Duration) -> (String, String, bool) { +fn wait_for( + mac: Option<&str>, + fallback: &str, + want_stock: bool, + timeout: Duration, +) -> (String, String, bool) { let deadline = Instant::now() + timeout; let mut ip = fallback.to_string(); let mut swept = Instant::now() - Duration::from_secs(60); @@ -255,7 +261,8 @@ pub fn run(spec: &str) -> i32 { let mac = mac_of(&host); println!( "board MAC: {}", - mac.as_deref().unwrap_or("unknown (will use the fixed host)") + mac.as_deref() + .unwrap_or("unknown (will use the fixed host)") ); let boot_timeout = Duration::from_secs(300); @@ -270,7 +277,7 @@ pub fn run(spec: &str) -> i32 { vec![host.clone()], board.clone(), AfwSource::Local(afw.clone()), - true, // allow unsigned (bench image) + true, // allow unsigned (bench image) stock_password.clone(), false, // not an in-place update ); @@ -286,7 +293,10 @@ pub fn run(spec: &str) -> i32 { boot_timeout.as_secs() ); let (alkane_ip, desc, ok) = wait_for(mac.as_deref(), &host, false, boot_timeout); - println!(" {desc} => {}", if ok { "ALKANE" } else { "NOT ALKANE (fail)" }); + println!( + " {desc} => {}", + if ok { "ALKANE" } else { "NOT ALKANE (fail)" } + ); all_ok = all_ok && ok; // 3. restore (alkane -> stock) flag-flip at the board's CURRENT address @@ -303,7 +313,10 @@ pub fn run(spec: &str) -> i32 { boot_timeout.as_secs() ); let (_stock_ip, desc, ok) = wait_for(mac.as_deref(), &host, true, boot_timeout); - println!(" {desc} => {}", if ok { "STOCK" } else { "NOT STOCK (fail)" }); + println!( + " {desc} => {}", + if ok { "STOCK" } else { "NOT STOCK (fail)" } + ); all_ok = all_ok && ok; } diff --git a/crates/alkane-gui/src/main.rs b/crates/alkane-gui/src/main.rs index bbced90d..092ffcf1 100644 --- a/crates/alkane-gui/src/main.rs +++ b/crates/alkane-gui/src/main.rs @@ -138,7 +138,7 @@ fn headless_mode() -> bool { "ALKANE_BENCH_SEQUENCE", ] .iter() - .any(|v| std::env::var_os(v).is_some()) + .any(|v| std::env::var_os(v).is_some()) } /// A Windows GUI-subsystem process has no console, so output from the headless diff --git a/crates/alkane-gui/src/stock_ops.rs b/crates/alkane-gui/src/stock_ops.rs index 1cb88121..b09b685a 100644 --- a/crates/alkane-gui/src/stock_ops.rs +++ b/crates/alkane-gui/src/stock_ops.rs @@ -26,7 +26,10 @@ use crate::scan::fake_scan_enabled; /// `SUPPORTED`). Only these are offered as install targets. pub const SUPPORTED_BOARDS: &[(&str, &str)] = &[ ("zynq-7010", "Antminer S17 (Xilinx Zynq-7010 control board)"), - ("a113d", "Antminer S19j Pro (Amlogic A113D/AXG control board)"), + ( + "a113d", + "Antminer S19j Pro (Amlogic A113D/AXG control board)", + ), ]; /// The default install board when the user has not chosen another. -- 2.54.0