style: rustfmt the a113d flash engine + CLI (cargo fmt)
#52's verify never actually ran before (the alkane-verify runner was offline), so cargo fmt --check was never enforced on this branch. Apply rustfmt to the three flagged files (alkane-cli main.rs, alkane-flash aml_ubi.rs and zynq_nand.rs) to match the toolkit's CI fmt gate. No behavioural change; vendored thirdparty/ is untouched (CI only formats the named crates). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -22,8 +22,8 @@ use alkane_flash::preflight::{preflight, PreflightOptions};
|
||||
use alkane_flash::stock;
|
||||
use alkane_flash::stock::{InPlaceOptions, InPlaceOutcome, RestoreImages};
|
||||
use alkane_flash::stock_firmware;
|
||||
use alkane_flash::zynq_nand;
|
||||
use alkane_flash::transport::{Remote, RootMethod, SshOptions, SshTransport};
|
||||
use alkane_flash::zynq_nand;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -1042,7 +1042,10 @@ fn latest_backup(dir: &Path) -> Option<PathBuf> {
|
||||
/// of these; `compat` lists them so an operator knows what is supported.
|
||||
const SUPPORTED: &[(&str, &str)] = &[
|
||||
("zynq-7010", "Antminer S17 (Xilinx Zynq-7010 control board)"),
|
||||
("a113d", "Antminer BHB42XXX / S19k Pro (Amlogic A113D/AXG control board)"),
|
||||
(
|
||||
"a113d",
|
||||
"Antminer BHB42XXX / S19k Pro (Amlogic A113D/AXG control board)",
|
||||
),
|
||||
];
|
||||
|
||||
fn is_supported(board: &str) -> bool {
|
||||
@@ -1128,7 +1131,9 @@ fn run_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>>
|
||||
None => {
|
||||
if opts.flag("dry-run") {
|
||||
println!("DRY RUN: would restore {host} to stock by flipping the A113D boot flag");
|
||||
println!("(no stock firmware needed; the untouched stock boot partition is booted).");
|
||||
println!(
|
||||
"(no stock firmware needed; the untouched stock boot partition is booted)."
|
||||
);
|
||||
println!("Re-run with --confirm FLASH.");
|
||||
return Ok(());
|
||||
}
|
||||
@@ -1138,7 +1143,9 @@ fn run_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>>
|
||||
println!("restoring {host} to genuine stock (A113D flag flip, network-only)...");
|
||||
match stock::restore_aml_flag(&host, password.as_deref()) {
|
||||
Ok(()) => {
|
||||
println!("restore reported success (boot flag cleared; stock boots via storeboot).");
|
||||
println!(
|
||||
"restore reported success (boot flag cleared; stock boots via storeboot)."
|
||||
);
|
||||
println!("verify independently: the board should present genuine stock");
|
||||
println!("(cgminer API on :4028, lighttpd 401 on :80, dropbear 2018.x).");
|
||||
return Ok(());
|
||||
@@ -1186,9 +1193,7 @@ fn run_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>>
|
||||
fn run_root_run(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let opts = parse_args(args, ssh_values(), &[])?;
|
||||
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
||||
let cmd = opts
|
||||
.positionals
|
||||
.join(" ");
|
||||
let cmd = opts.positionals.join(" ");
|
||||
if cmd.trim().is_empty() {
|
||||
return Err("usage: alkane-cli afw root-run --host <ip> <command...>".into());
|
||||
}
|
||||
@@ -1203,7 +1208,11 @@ fn run_root_run(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
/// backup, write the boot slots and reboot. Drives the DSH root-on-stock
|
||||
/// primitive; board must be on stock (credential root/root).
|
||||
fn run_nand_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let opts = parse_args(args, &[ssh_values(), &["confirm"]].concat(), &["allow-unsigned"])?;
|
||||
let opts = parse_args(
|
||||
args,
|
||||
&[ssh_values(), &["confirm"]].concat(),
|
||||
&["allow-unsigned"],
|
||||
)?;
|
||||
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
||||
let afw_path = opts
|
||||
.positionals
|
||||
@@ -1211,18 +1220,33 @@ fn run_nand_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
.ok_or("usage: alkane-cli afw nand-install <afw> --host <ip> --confirm FLASH")?;
|
||||
let verified = load_afw(afw_path, &opts)?;
|
||||
if !zynq::owns_board(&verified.manifest.board) {
|
||||
return Err(format!("nand-install is zynq-7010 only, not {}", verified.manifest.board).into());
|
||||
return Err(format!(
|
||||
"nand-install is zynq-7010 only, not {}",
|
||||
verified.manifest.board
|
||||
)
|
||||
.into());
|
||||
}
|
||||
if opts.value("confirm") != Some("FLASH") {
|
||||
return Err("refusing to install without --confirm FLASH".into());
|
||||
}
|
||||
let kernel = verified.image("kernel").ok_or("afw missing kernel image")?.1;
|
||||
let kernel = verified
|
||||
.image("kernel")
|
||||
.ok_or("afw missing kernel image")?
|
||||
.1;
|
||||
let dtb = verified.image("dtb").ok_or("afw missing dtb image")?.1;
|
||||
let rootfs = verified.image("rootfs").ok_or("afw missing rootfs image")?.1;
|
||||
let rootfs = verified
|
||||
.image("rootfs")
|
||||
.ok_or("afw missing rootfs image")?
|
||||
.1;
|
||||
let password = read_board_password(&opts)?;
|
||||
println!("installing {} onto stock board {host} (readable NAND path)...", verified.manifest.board);
|
||||
println!(
|
||||
"installing {} onto stock board {host} (readable NAND path)...",
|
||||
verified.manifest.board
|
||||
);
|
||||
zynq_nand::install_from_stock(&host, kernel, dtb, rootfs, password.as_deref())?;
|
||||
println!("install reported success (on-board stock backup carved; boot slots written; rebooting).");
|
||||
println!(
|
||||
"install reported success (on-board stock backup carved; boot slots written; rebooting)."
|
||||
);
|
||||
print!("{}", zynq_verify_hint(&host));
|
||||
Ok(())
|
||||
}
|
||||
@@ -1231,9 +1255,15 @@ fn run_nand_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
/// back to the boot slots over SSH (board on alkane). Needs the alkane image
|
||||
/// that exposes the boot partitions.
|
||||
fn run_nand_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let opts = parse_args(args, &[ssh_values(), &["confirm", "stock-firmware"]].concat(), &["dry-run"])?;
|
||||
let opts = parse_args(
|
||||
args,
|
||||
&[ssh_values(), &["confirm", "stock-firmware"]].concat(),
|
||||
&["dry-run"],
|
||||
)?;
|
||||
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
||||
let firmware = opts.value("stock-firmware").ok_or("--stock-firmware <file> is required")?;
|
||||
let firmware = opts
|
||||
.value("stock-firmware")
|
||||
.ok_or("--stock-firmware <file> is required")?;
|
||||
let fw = stock_firmware::parse(Path::new(firmware))?;
|
||||
println!("stock firmware: {}", fw.summary());
|
||||
if opts.value("confirm") != Some("FLASH") {
|
||||
@@ -1241,8 +1271,16 @@ fn run_nand_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Err
|
||||
}
|
||||
let password = read_board_password(&opts)?;
|
||||
println!("restoring {host} to genuine stock (readable NAND path)...");
|
||||
zynq_nand::restore_to_stock(&host, &fw.kernel, &fw.rootfs, fw.dtb.as_deref(), password.as_deref())?;
|
||||
println!("restore-to-stock reported success (stock kernel/dtb/rootfs written, BOOT.bin preserved).");
|
||||
zynq_nand::restore_to_stock(
|
||||
&host,
|
||||
&fw.kernel,
|
||||
&fw.rootfs,
|
||||
fw.dtb.as_deref(),
|
||||
password.as_deref(),
|
||||
)?;
|
||||
println!(
|
||||
"restore-to-stock reported success (stock kernel/dtb/rootfs written, BOOT.bin preserved)."
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1344,7 +1382,9 @@ fn run_restore_onboard(args: &[String]) -> Result<(), Box<dyn std::error::Error>
|
||||
password.as_deref(),
|
||||
std::time::Duration::from_secs(300),
|
||||
)?;
|
||||
println!("restore-from-onboard reported success. Verify independently the board answers as stock.");
|
||||
println!(
|
||||
"restore-from-onboard reported success. Verify independently the board answers as stock."
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user