Add am335x-stock (tier-3) from-stock flash support to the toolkit
The am335x flash module now selects a per-tier Profile from the bundle's board: tier 2 (am335x, preserve) or tier 3 (am335x-stock, include). The byte-write engine, preflight and readback are shared; only the policy, preserved set, 12-partition map (mtd4 becomes a write target) and image list differ. - boards/am335x.rs: Profile/profile_for/owns_board; MTD_MAP_STOCK (mtd4 writable, kernel at write_order 4 so U-Boot lands first); from_afw accepts am335x-stock, permits exactly the u-boot bootloader member, still rejects any SPL member and a u-boot member on tier 2; check_uimage expects firmware type 5 for u-boot; the plan carries its board + preserved set; render is tier-aware. - restore() takes the preserved set per profile; SPL copies (mtd0-3) are never a restore target on any tier; mtd4 is restorable on tier 3. - alkane-cli: route am335x-stock to the module (plan/preflight/install); restore is profile-driven and adds --held-uboot (mtd4) for the from-stock set. - alkane-artifacts: board_profile knows am335x-stock (arm, include). - tests: tier-3 from_afw acceptance (4 targets, U-Boot before kernel, mtd4 not preserved), wrong-U-Boot-type and SPL-write-target rejection, and a tier-3 restore test (mtd4 allowed, SPL refused). Full flash suite 41 green; tier-2 and cv1835 unchanged. The real bundle parses and verifies through the CLI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qHxYpv7yf7Ah57g4rQ
This commit is contained in:
@@ -316,7 +316,7 @@ fn run_plan(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
.first()
|
||||
.ok_or("usage: alkane-cli afw plan <file> --host <ip>")?;
|
||||
let verified = load_afw(path, &opts)?;
|
||||
if verified.manifest.board == "am335x" {
|
||||
if am335x::owns_board(&verified.manifest.board) {
|
||||
let plan = Am335xPlan::from_afw(&verified)?;
|
||||
let (ssh, _secret) = ssh_options(&opts, DEFAULT_USER)?;
|
||||
let mut transport = SshTransport::connect(ssh, true)?;
|
||||
@@ -390,7 +390,7 @@ fn run_preflight(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let verified = load_afw(path, &opts)?;
|
||||
let (ssh, _secret) = ssh_options(&opts, DEFAULT_USER)?;
|
||||
let mut transport = SshTransport::connect(ssh, true)?;
|
||||
if verified.manifest.board == "am335x" {
|
||||
if am335x::owns_board(&verified.manifest.board) {
|
||||
let plan = Am335xPlan::from_afw(&verified)?;
|
||||
let report = am335x::preflight(&plan, &mut transport, opts.value("host").unwrap_or(""))?;
|
||||
print!("{}", report.render());
|
||||
@@ -445,7 +445,7 @@ fn run_install(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
.value("backup-dir")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| platform::config_path("backups"));
|
||||
if verified.manifest.board == "am335x" {
|
||||
if am335x::owns_board(&verified.manifest.board) {
|
||||
let plan = Am335xPlan::from_afw(&verified)?;
|
||||
let install_options = AmInstallOptions {
|
||||
dry_run: opts.flag("dry-run"),
|
||||
@@ -626,24 +626,33 @@ fn run_restore(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
args,
|
||||
&[
|
||||
ssh_values(),
|
||||
&["held-backup", "backup-dir", "confirm", "board", "held-kernel", "held-dtb"],
|
||||
&[
|
||||
"held-backup", "backup-dir", "confirm", "board", "held-kernel",
|
||||
"held-dtb", "held-uboot",
|
||||
],
|
||||
]
|
||||
.concat(),
|
||||
&["no-reboot"],
|
||||
)?;
|
||||
let (ssh, _secret) = ssh_options(&opts, DEFAULT_USER)?;
|
||||
let mut transport = SshTransport::connect(ssh, true)?;
|
||||
if opts.value("board") == Some("am335x") {
|
||||
if let Some(profile) = opts.value("board").and_then(am335x::profile_for) {
|
||||
let dir = opts
|
||||
.value("backup-dir")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| platform::config_path("backups"));
|
||||
let mut backups: Vec<(String, PathBuf)> = Vec::new();
|
||||
for (name, value, prefix) in [
|
||||
// The held set is the profile's write targets: mtd8/mtd7/mtd6 on both
|
||||
// tiers, plus mtd4 (our U-Boot) on the tier-3 from-stock profile.
|
||||
let mut table: Vec<(&str, Option<&str>, &str)> = vec![
|
||||
("mtd8", opts.value("held-backup"), "mtd8-"),
|
||||
("mtd7", opts.value("held-kernel"), "mtd7-"),
|
||||
("mtd6", opts.value("held-dtb"), "mtd6-"),
|
||||
] {
|
||||
];
|
||||
if profile.targets.iter().any(|(part, ..)| *part == "mtd4") {
|
||||
table.push(("mtd4", opts.value("held-uboot"), "mtd4-"));
|
||||
}
|
||||
let mut backups: Vec<(String, PathBuf)> = Vec::new();
|
||||
for (name, value, prefix) in table {
|
||||
let path = match value {
|
||||
Some(path) => PathBuf::from(path),
|
||||
None => latest_backup_for(&dir, prefix).ok_or_else(|| {
|
||||
@@ -655,6 +664,7 @@ fn run_restore(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
};
|
||||
backups.push((name.to_owned(), path));
|
||||
}
|
||||
let preserve: Vec<String> = profile.preserve.iter().map(|s| (*s).to_owned()).collect();
|
||||
let receipt = am335x::restore(
|
||||
&backups,
|
||||
&mut transport,
|
||||
@@ -662,6 +672,7 @@ fn run_restore(args: &[String]) -> Result<(), Box<dyn std::error::Error>> {
|
||||
confirm: opts.value("confirm").map(str::to_owned),
|
||||
no_reboot: opts.flag("no-reboot"),
|
||||
},
|
||||
&preserve,
|
||||
)?;
|
||||
for (name, path) in &receipt.restored {
|
||||
println!("restored {name} from {}", path.display());
|
||||
|
||||
Reference in New Issue
Block a user