style: rustfmt the afw/stock work (no behaviour change)
verify / verify (pull_request) Skipped
source / check (pull_request) Successful in 4m17s
verify / verify (pull_request) Skipped
source / check (pull_request) Successful in 4m17s
main's verify gate runs cargo fmt --check on the first-party crates; next's gate does not, so the afw/stock feature work reached next unformatted. Pure cargo fmt output. clippy -D warnings (workspace and GUI) and all tests pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -7,21 +7,21 @@
|
||||
|
||||
use alkane_artifacts::afw::{verify_afw, VerifiedAfw, VerifyOptions};
|
||||
use alkane_artifacts::fetch::{self, ReleaseSource};
|
||||
use alkane_flash::stock;
|
||||
use alkane_artifacts::{seed_manifest, verify_file};
|
||||
use alkane_core::platform;
|
||||
use alkane_flash::boards::a113d::{self, A113dInstallOptions, A113dOutcome, A113dPlan};
|
||||
use alkane_flash::boards::am335x::{
|
||||
self as am335x, Am335xPlan, AmInstallOptions, AmInstallOutcome, AmRestoreOptions,
|
||||
};
|
||||
use alkane_flash::boards::cv1835::Cv1835Plan;
|
||||
use alkane_flash::boards::zynq::{self, ZynqPlan};
|
||||
use alkane_flash::stock::{InPlaceOptions, InPlaceOutcome, RestoreImages};
|
||||
use alkane_flash::stock_firmware;
|
||||
use alkane_flash::boards::a113d::{self, A113dInstallOptions, A113dOutcome, A113dPlan};
|
||||
use alkane_flash::install::{
|
||||
install, restore, verify_live, InstallOptions, InstallOutcome, RestoreOptions,
|
||||
};
|
||||
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::transport::{Remote, RootMethod, SshOptions, SshTransport};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::fs;
|
||||
@@ -148,8 +148,8 @@ fn read_board_password(opts: &Opts) -> Result<Option<String>, Box<dyn std::error
|
||||
let secret = resolve_password(opts)?;
|
||||
match &secret.path {
|
||||
Some(path) => {
|
||||
let raw = fs::read_to_string(path)
|
||||
.map_err(|e| format!("reading board password: {e}"))?;
|
||||
let raw =
|
||||
fs::read_to_string(path).map_err(|e| format!("reading board password: {e}"))?;
|
||||
Ok(Some(raw.trim_end_matches(['\n', '\r']).to_string()))
|
||||
}
|
||||
None => Ok(None),
|
||||
@@ -350,10 +350,9 @@ fn run_plan(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
String::from_utf8_lossy(&transport.root_command("id -u", Duration::from_secs(15))?)
|
||||
.trim()
|
||||
.to_owned();
|
||||
let mtd = String::from_utf8_lossy(&transport.user_command(
|
||||
"cat /proc/mtd 2>/dev/null",
|
||||
Duration::from_secs(15),
|
||||
)?)
|
||||
let mtd = String::from_utf8_lossy(
|
||||
&transport.user_command("cat /proc/mtd 2>/dev/null", Duration::from_secs(15))?,
|
||||
)
|
||||
.into_owned();
|
||||
println!("{}", plan.render());
|
||||
println!("current kernel {kernel} uid {uid}");
|
||||
@@ -513,7 +512,9 @@ fn install_zynq_in_place(
|
||||
InPlaceOutcome::DryRun(report) => {
|
||||
print!("{report}");
|
||||
println!("DRY RUN: no board erase or write was performed.");
|
||||
println!("Re-run with --confirm FLASH to write rootfs, dtb and kernel (BOOT.bin preserved).");
|
||||
println!(
|
||||
"Re-run with --confirm FLASH to write rootfs, dtb and kernel (BOOT.bin preserved)."
|
||||
);
|
||||
}
|
||||
InPlaceOutcome::Updated(receipt) => {
|
||||
for held in &receipt.backups {
|
||||
@@ -588,7 +589,13 @@ fn run_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
args,
|
||||
&[
|
||||
ssh_values(),
|
||||
&["held-backup", "backup-dir", "confirm", "expect-board", "board"],
|
||||
&[
|
||||
"held-backup",
|
||||
"backup-dir",
|
||||
"confirm",
|
||||
"expect-board",
|
||||
"board",
|
||||
],
|
||||
]
|
||||
.concat(),
|
||||
&[
|
||||
@@ -685,25 +692,39 @@ fn run_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
no_reboot: opts.flag("no-reboot"),
|
||||
backup_dir,
|
||||
};
|
||||
match a113d::install(&plan, &mut transport, &install_options, opts.value("host").unwrap_or(""))? {
|
||||
match a113d::install(
|
||||
&plan,
|
||||
&mut transport,
|
||||
&install_options,
|
||||
opts.value("host").unwrap_or(""),
|
||||
)? {
|
||||
A113dOutcome::DryRun(report) => {
|
||||
print!("{}", report.render());
|
||||
println!("DRY RUN: no file was written into the nvdata UBI.");
|
||||
let targets = plan.targets.iter().map(|t| t.image_name.as_str()).collect::<Vec<_>>().join(", ");
|
||||
let targets = plan
|
||||
.targets
|
||||
.iter()
|
||||
.map(|t| t.image_name.as_str())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
println!("Re-run with --confirm FLASH to write {targets} into the alkane/ dir on nvdata (FIP + mtd0-5 are not MTD devices).");
|
||||
}
|
||||
A113dOutcome::Installed(receipt) => {
|
||||
println!("wrote OS files into the alkane/ dir on nvdata volume {}", receipt.volume);
|
||||
println!(
|
||||
"wrote OS files into the alkane/ dir on nvdata volume {}",
|
||||
receipt.volume
|
||||
);
|
||||
for backup in &receipt.backups {
|
||||
match (&backup.path, &backup.md5) {
|
||||
(Some(path), Some(md5)) => println!(
|
||||
"held {} {} md5 {}",
|
||||
backup.image_name, path.display(), md5
|
||||
),
|
||||
(Some(path), Some(md5)) => {
|
||||
println!("held {} {} md5 {}", backup.image_name, path.display(), md5)
|
||||
}
|
||||
_ => println!("held {} (no prior file on board)", backup.image_name),
|
||||
}
|
||||
}
|
||||
println!("all read-backs matched before reboot; no raw NAND write, FIP never touched");
|
||||
println!(
|
||||
"all read-backs matched before reboot; no raw NAND write, FIP never touched"
|
||||
);
|
||||
if receipt.rebooted {
|
||||
println!("reboot issued; an SSH drop here is the success signature");
|
||||
} else {
|
||||
@@ -763,7 +784,13 @@ fn run_verify_live(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
args,
|
||||
&[
|
||||
ssh_values(),
|
||||
&["marker", "kernel-version", "timeout", "expect-board", "board"],
|
||||
&[
|
||||
"marker",
|
||||
"kernel-version",
|
||||
"timeout",
|
||||
"expect-board",
|
||||
"board",
|
||||
],
|
||||
]
|
||||
.concat(),
|
||||
&["allow-unsigned"],
|
||||
@@ -801,7 +828,9 @@ fn run_verify_live(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
)
|
||||
}
|
||||
} else {
|
||||
let board = requested_board.clone().unwrap_or_else(|| "cv1835".to_owned());
|
||||
let board = requested_board
|
||||
.clone()
|
||||
.unwrap_or_else(|| "cv1835".to_owned());
|
||||
let (marker, kernel) = if board == "am335x" {
|
||||
("Alkane".to_owned(), "6.18.48".to_owned())
|
||||
} else if zynq::owns_board(&board) {
|
||||
@@ -839,7 +868,9 @@ fn run_verify_live(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
)?;
|
||||
print!("{}", report.render());
|
||||
if !report.ok() {
|
||||
return Err("live verification failed: HTTP marker and SSH did not both confirm alkane".into());
|
||||
return Err(
|
||||
"live verification failed: HTTP marker and SSH did not both confirm alkane".into(),
|
||||
);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
@@ -879,8 +910,13 @@ fn run_restore(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
&[
|
||||
ssh_values(),
|
||||
&[
|
||||
"held-backup", "backup-dir", "confirm", "board", "held-kernel",
|
||||
"held-dtb", "held-uboot",
|
||||
"held-backup",
|
||||
"backup-dir",
|
||||
"confirm",
|
||||
"board",
|
||||
"held-kernel",
|
||||
"held-dtb",
|
||||
"held-uboot",
|
||||
],
|
||||
]
|
||||
.concat(),
|
||||
@@ -1003,7 +1039,8 @@ fn latest_backup(dir: &Path) -> Option<PathBuf> {
|
||||
/// Boards this toolkit can install alkane onto, with the miner each is the
|
||||
/// control board for. The install/restore gate is the .afw's board matching one
|
||||
/// 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)")];
|
||||
const SUPPORTED: &[(&str, &str)] =
|
||||
&[("zynq-7010", "Antminer S17 (Xilinx Zynq-7010 control board)")];
|
||||
|
||||
fn is_supported(board: &str) -> bool {
|
||||
SUPPORTED.iter().any(|(b, _)| *b == board)
|
||||
@@ -1014,7 +1051,9 @@ fn run_compat(_args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
for (board, miner) in SUPPORTED {
|
||||
println!(" {board:<12} {miner}");
|
||||
}
|
||||
println!("\nInstall a local bundle: alkane-cli afw install <file.afw> --host <ip> --confirm FLASH");
|
||||
println!(
|
||||
"\nInstall a local bundle: alkane-cli afw install <file.afw> --host <ip> --confirm FLASH"
|
||||
);
|
||||
println!("Install the latest build: alkane-cli afw install --latest --board zynq-7010 --host <ip> --confirm FLASH");
|
||||
println!("Remove (back to stock): alkane-cli afw restore-stock --host <ip> --confirm FLASH");
|
||||
Ok(())
|
||||
@@ -1029,9 +1068,15 @@ fn run_fetch_latest(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let opts = parse_args(args, &["board", "output"], &[])?;
|
||||
let board = opts.value("board").unwrap_or("zynq-7010");
|
||||
if !is_supported(board) {
|
||||
return Err(format!("{board} is not a supported install target (see: alkane-cli afw compat)").into());
|
||||
return Err(format!(
|
||||
"{board} is not a supported install target (see: alkane-cli afw compat)"
|
||||
)
|
||||
.into());
|
||||
}
|
||||
let dest = opts.value("output").map(PathBuf::from).unwrap_or_else(download_dir);
|
||||
let dest = opts
|
||||
.value("output")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(download_dir);
|
||||
let path = fetch::fetch_latest_afw(&ReleaseSource::alkane_os(), board, &dest)?;
|
||||
println!("fetched {}", path.display());
|
||||
Ok(())
|
||||
@@ -1043,17 +1088,19 @@ fn resolve_afw_source(opts: &Opts) -> Result<PathBuf, Box<dyn std::error::Error>
|
||||
if opts.flag("latest") {
|
||||
let board = opts.value("board").unwrap_or("zynq-7010");
|
||||
if !is_supported(board) {
|
||||
return Err(format!("{board} is not a supported install target (see: alkane-cli afw compat)").into());
|
||||
return Err(format!(
|
||||
"{board} is not a supported install target (see: alkane-cli afw compat)"
|
||||
)
|
||||
.into());
|
||||
}
|
||||
println!("fetching the latest {board} release from Gitea...");
|
||||
let path = fetch::fetch_latest_afw(&ReleaseSource::alkane_os(), board, &download_dir())?;
|
||||
println!("using {}", path.display());
|
||||
return Ok(path);
|
||||
}
|
||||
opts.positionals
|
||||
.first()
|
||||
.map(PathBuf::from)
|
||||
.ok_or_else(|| "usage: alkane-cli afw install <file>|--latest --host <ip> --confirm FLASH".into())
|
||||
opts.positionals.first().map(PathBuf::from).ok_or_else(|| {
|
||||
"usage: alkane-cli afw install <file>|--latest --host <ip> --confirm FLASH".into()
|
||||
})
|
||||
}
|
||||
|
||||
/// Return an alkane board to genuine Bitmain stock by writing the stock images
|
||||
|
||||
Reference in New Issue
Block a user