Fix from-stock preflight: recognize AM335x stock, size-only mtd-map, honest dry-run targets
Three fixes found running the real tier-3 preflight against the stock .64 board: - preflight fingerprint ended in 'ls <our release files>' which exits 1 on a stock board (none exist), failing the whole command; append '|| true'. - classify() only knew the Amlogic stock kernel (4.9.38); the AM335x stock is 3.8.13+ with an Antminer model line - recognize both so source-os matches the plan's stock-bitmain. - the mtd-map check compared the vendor label (spl/u-boot/...) to the mtdN device name and so always failed on real hardware; validate live geometry by index+size against the plan's partitions instead (labels are board-specific, not in our map). - dry-run message now lists the real write targets from the plan (was a hard-coded 'mtd8, mtd6 and mtd7' that omitted mtd4 on tier 3). Preflight + dry-run now PASS against the live stock board (all 10 checks). Unit suite still 41 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qHxYpv7yf7Ah57g4rQ
This commit is contained in:
@@ -463,7 +463,13 @@ fn run_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
AmInstallOutcome::DryRun(report) => {
|
||||
print!("{}", report.render());
|
||||
println!("DRY RUN: no board erase or write was performed.");
|
||||
println!("Re-run with --confirm FLASH to write mtd8, mtd6 and mtd7.");
|
||||
let targets = plan
|
||||
.targets
|
||||
.iter()
|
||||
.map(|t| t.partition.name.as_str())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
println!("Re-run with --confirm FLASH to write {targets}.");
|
||||
}
|
||||
AmInstallOutcome::Installed(receipt) => {
|
||||
for backup in &receipt.backups {
|
||||
|
||||
@@ -580,7 +580,8 @@ pub fn preflight(
|
||||
let fingerprint = remote.user_command(
|
||||
"uname -r; echo __MODEL__; cat /proc/device-tree/model 2>/dev/null; echo; \
|
||||
echo __RELEASE__; cat /etc/os-release 2>/dev/null; \
|
||||
ls /etc/alkane-release /etc/ouros-release /etc/bos_version /etc/fw-info 2>/dev/null",
|
||||
ls /etc/alkane-release /etc/ouros-release /etc/bos_version /etc/fw-info 2>/dev/null \
|
||||
|| true",
|
||||
Duration::from_secs(20),
|
||||
)?;
|
||||
let text = String::from_utf8_lossy(&fingerprint).into_owned();
|
||||
@@ -622,16 +623,20 @@ pub fn preflight(
|
||||
)?)
|
||||
.into_owned();
|
||||
let mtd = parse_proc_mtd(&mtd_text);
|
||||
let map_ok = MTD_MAP.iter().all(|(name, _, size, ..)| {
|
||||
mtd.get(*name)
|
||||
.map(|entry: &(u64, String)| entry.0 == *size && entry.1 == *name)
|
||||
.unwrap_or(false)
|
||||
});
|
||||
// Validate the live geometry against the plan's partitions by index+size.
|
||||
// The vendor labels (spl, u-boot, kernel, ...) are board-specific and are
|
||||
// not part of our map, so only the mtdN index and its size are checked.
|
||||
let map_ok = plan.partitions.len() == mtd.len()
|
||||
&& plan.partitions.iter().all(|part| {
|
||||
mtd.get(&part.name)
|
||||
.map(|entry: &(u64, String)| entry.0 == part.size)
|
||||
.unwrap_or(false)
|
||||
});
|
||||
checks.push(AmCheck {
|
||||
name: "mtd-map".to_owned(),
|
||||
ok: map_ok,
|
||||
detail: if map_ok {
|
||||
"12 partitions match the captured map".to_owned()
|
||||
format!("{} partitions match the plan geometry by size", plan.partitions.len())
|
||||
} else {
|
||||
format!("partition table differs: {mtd_text}")
|
||||
},
|
||||
|
||||
@@ -354,7 +354,14 @@ pub(crate) fn classify(kernel: &str, release: &str, all: &str) -> String {
|
||||
if all.contains("/etc/fw-info") || release.contains("Vnish") || release.contains("AnthillOS") {
|
||||
return "vnish".to_owned();
|
||||
}
|
||||
if kernel.contains("4.9.38") || all.contains("update-daemon") || all.contains("rroot") {
|
||||
// Stock Bitmain control boards: Amlogic stock is kernel 4.9.38; the AM335x
|
||||
// (BeagleBone-class) stock is kernel 3.8.13+ with an "Antminer" model line.
|
||||
if kernel.contains("4.9.38")
|
||||
|| kernel.starts_with("3.8.13")
|
||||
|| all.contains("update-daemon")
|
||||
|| all.contains("rroot")
|
||||
|| all.to_lowercase().contains("antminer")
|
||||
{
|
||||
return "stock-bitmain".to_owned();
|
||||
}
|
||||
"unknown".to_owned()
|
||||
|
||||
Reference in New Issue
Block a user