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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -53,9 +53,7 @@ fn drive(label: &str, handle: StockHandle) -> bool {
|
|||||||
fn ssh_banner(host: &str) -> Option<String> {
|
fn ssh_banner(host: &str) -> Option<String> {
|
||||||
let addr: std::net::SocketAddr = format!("{host}:22").parse().ok()?;
|
let addr: std::net::SocketAddr = format!("{host}:22").parse().ok()?;
|
||||||
let mut stream = TcpStream::connect_timeout(&addr, Duration::from_secs(5)).ok()?;
|
let mut stream = TcpStream::connect_timeout(&addr, Duration::from_secs(5)).ok()?;
|
||||||
stream
|
stream.set_read_timeout(Some(Duration::from_secs(5))).ok()?;
|
||||||
.set_read_timeout(Some(Duration::from_secs(5)))
|
|
||||||
.ok()?;
|
|
||||||
let mut buf = [0u8; 256];
|
let mut buf = [0u8; 256];
|
||||||
let n = stream.read(&mut buf).ok()?;
|
let n = stream.read(&mut buf).ok()?;
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
@@ -129,7 +127,10 @@ fn mac_of(host: &str) -> Option<String> {
|
|||||||
let _ = Command::new("ping")
|
let _ = Command::new("ping")
|
||||||
.args(["-c", "1", "-W", "1", host])
|
.args(["-c", "1", "-W", "1", host])
|
||||||
.output();
|
.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 s = String::from_utf8_lossy(&out.stdout);
|
||||||
let mut it = s.split_whitespace();
|
let mut it = s.split_whitespace();
|
||||||
while let Some(t) = it.next() {
|
while let Some(t) = it.next() {
|
||||||
@@ -183,7 +184,12 @@ fn ip_for_mac(mac: &str) -> Option<String> {
|
|||||||
/// Poll until the board (located by MAC, so a changed DHCP lease is followed)
|
/// 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
|
/// reaches the wanted stock-ness, or `timeout` elapses. Returns the board's
|
||||||
/// current IP, a description, and whether the target state was reached.
|
/// 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 deadline = Instant::now() + timeout;
|
||||||
let mut ip = fallback.to_string();
|
let mut ip = fallback.to_string();
|
||||||
let mut swept = Instant::now() - Duration::from_secs(60);
|
let mut swept = Instant::now() - Duration::from_secs(60);
|
||||||
@@ -255,7 +261,8 @@ pub fn run(spec: &str) -> i32 {
|
|||||||
let mac = mac_of(&host);
|
let mac = mac_of(&host);
|
||||||
println!(
|
println!(
|
||||||
"board MAC: {}",
|
"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);
|
let boot_timeout = Duration::from_secs(300);
|
||||||
@@ -270,7 +277,7 @@ pub fn run(spec: &str) -> i32 {
|
|||||||
vec![host.clone()],
|
vec![host.clone()],
|
||||||
board.clone(),
|
board.clone(),
|
||||||
AfwSource::Local(afw.clone()),
|
AfwSource::Local(afw.clone()),
|
||||||
true, // allow unsigned (bench image)
|
true, // allow unsigned (bench image)
|
||||||
stock_password.clone(),
|
stock_password.clone(),
|
||||||
false, // not an in-place update
|
false, // not an in-place update
|
||||||
);
|
);
|
||||||
@@ -286,7 +293,10 @@ pub fn run(spec: &str) -> i32 {
|
|||||||
boot_timeout.as_secs()
|
boot_timeout.as_secs()
|
||||||
);
|
);
|
||||||
let (alkane_ip, desc, ok) = wait_for(mac.as_deref(), &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)" });
|
println!(
|
||||||
|
" {desc} => {}",
|
||||||
|
if ok { "ALKANE" } else { "NOT ALKANE (fail)" }
|
||||||
|
);
|
||||||
all_ok = all_ok && ok;
|
all_ok = all_ok && ok;
|
||||||
|
|
||||||
// 3. restore (alkane -> stock) flag-flip at the board's CURRENT address
|
// 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()
|
boot_timeout.as_secs()
|
||||||
);
|
);
|
||||||
let (_stock_ip, desc, ok) = wait_for(mac.as_deref(), &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)" });
|
println!(
|
||||||
|
" {desc} => {}",
|
||||||
|
if ok { "STOCK" } else { "NOT STOCK (fail)" }
|
||||||
|
);
|
||||||
all_ok = all_ok && ok;
|
all_ok = all_ok && ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ fn headless_mode() -> bool {
|
|||||||
"ALKANE_BENCH_SEQUENCE",
|
"ALKANE_BENCH_SEQUENCE",
|
||||||
]
|
]
|
||||||
.iter()
|
.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
|
/// A Windows GUI-subsystem process has no console, so output from the headless
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ use crate::scan::fake_scan_enabled;
|
|||||||
/// `SUPPORTED`). Only these are offered as install targets.
|
/// `SUPPORTED`). Only these are offered as install targets.
|
||||||
pub const SUPPORTED_BOARDS: &[(&str, &str)] = &[
|
pub const SUPPORTED_BOARDS: &[(&str, &str)] = &[
|
||||||
("zynq-7010", "Antminer S17 (Xilinx Zynq-7010 control board)"),
|
("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.
|
/// The default install board when the user has not chosen another.
|
||||||
|
|||||||
Reference in New Issue
Block a user