a113d (Amlogic AXG/S21 Pro): UBI-file flash module + CLI routing

Add the S21 Pro-class Amlogic A113D/AXG flash module to the toolkit, matching
the Zynq-7010 treatment, plus CLI routing for plan/preflight/install.

- crates/alkane-flash/src/boards/a113d.rs: A113dPlan::from_afw validates the
  verified manifest (a113d, arm64, preserve, no fip/spl/tpl/u-boot member,
  exactly kernel/dtb/rootfs with arm64-image/fdt/uimage formats, per-image
  ceilings and total <= nvdata, plus independent magic checks and a
  defense-in-depth refusal of any non-nvdata partition carrying an image).
  The installer is file-only: it resolves the anthillos/ directory on a
  mounted ubifs volume and copies the three files there with staged + read-back
  md5 verification. The brick guard is structural - there is no flash_erase,
  nandwrite or dd-to-/dev/mtd anywhere in the module, so the FIP (mtd0/1) and
  stock boot (mtd4) and mtd2/3/5 can never be touched; every destination is
  checked to be a bare basename.
- crates/alkane-flash/src/boards/mod.rs: register the module.
- crates/alkane-cli/src/main.rs: route a113d bundles through afw
  plan/preflight/install.
- crates/alkane-artifacts/src/afw.rs: correct the a113d / a113d-s21pro board
  profile from armv7 to arm64 (the A113D/AXG is an arm64 SoC).

8 new a113d unit tests; full suite: 55 alkane-flash, 12 alkane-artifacts, all
pass. End-to-end verified: make-afw.sh -> check-afw.py -> alkane-cli afw plan
on a stub a113d bundle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qHxYpv7yf7Ah57g4rQ
This commit is contained in:
2026-11-06 21:02:06 -06:00
co-authored by Claude Opus 4.8
parent cce24b6880
commit c79ee1315d
4 changed files with 814 additions and 2 deletions
+53
View File
@@ -13,6 +13,7 @@ use alkane_flash::boards::am335x::{
};
use alkane_flash::boards::cv1835::Cv1835Plan;
use alkane_flash::boards::zynq::{self, ZynqInstallOptions, ZynqOutcome, ZynqPlan};
use alkane_flash::boards::a113d::{self, A113dInstallOptions, A113dOutcome, A113dPlan};
use alkane_flash::install::{
install, restore, verify_live, InstallOptions, InstallOutcome, RestoreOptions,
};
@@ -351,6 +352,12 @@ fn run_plan(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
println!("plan is read-only; no write performed (run preflight/install with --host)");
return Ok(());
}
if a113d::owns_board(&verified.manifest.board) {
let plan = A113dPlan::from_afw(&verified)?;
println!("{}", plan.render());
println!("plan is read-only; no write performed (run preflight/install with --host)");
return Ok(());
}
let plan = Cv1835Plan::from_afw(&verified)?;
let (ssh, _secret) = ssh_options(&opts, DEFAULT_USER)?;
let mut transport = SshTransport::connect(ssh, true)?;
@@ -415,6 +422,15 @@ fn run_preflight(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
}
return Ok(());
}
if a113d::owns_board(&verified.manifest.board) {
let plan = A113dPlan::from_afw(&verified)?;
let report = a113d::preflight(&plan, &mut transport, opts.value("host").unwrap_or(""))?;
print!("{}", report.render());
if !report.ok() {
return Err("preflight failed; do not write".into());
}
return Ok(());
}
let plan = Cv1835Plan::from_afw(&verified)?;
let held_backup = opts.value("held-backup").map(PathBuf::from);
let report = preflight(
@@ -544,6 +560,43 @@ fn run_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
}
return Ok(());
}
if a113d::owns_board(&verified.manifest.board) {
let plan = A113dPlan::from_afw(&verified)?;
println!("{}", plan.render());
let install_options = A113dInstallOptions {
dry_run: opts.flag("dry-run"),
confirm: opts.value("confirm").map(str::to_owned),
no_reboot: opts.flag("no-reboot"),
backup_dir,
};
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(", ");
println!("Re-run with --confirm FLASH to stage {targets} into anthillos/ (FIP + mtd0-5 preserved).");
}
A113dOutcome::Installed(receipt) => {
println!("wrote OS files into {}", receipt.anthillos);
for backup in &receipt.backups {
match (&backup.path, &backup.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");
if receipt.rebooted {
println!("reboot issued; an SSH drop here is the success signature");
} else {
println!("reboot skipped (--no-reboot)");
}
}
}
return Ok(());
}
let plan = Cv1835Plan::from_afw(&verified)?;
let install_options = InstallOptions {
dry_run: opts.flag("dry-run"),