flash: restore uses the correct per-board device tree, not the package's
The kernel device tree is never in Bitmain's distributable firmware: all OTA packages ship none, and the SD recovery image preserves the factory dtb rather than writing one. The device tree I was taking from the SD recovery package was its SD-boot dtb (a different partition layout), which does not match the genuine rootfs and reboot-loops the board. Fix: restore now takes only the genuine kernel + rootfs from the vendor package (RestoreImages drops the dtb field), and the method supplies the correct per-board device tree itself (fetched + verified from the public assets repo, the same way the NAND-exposing helper is fetched). This pairs genuine kernel/rootfs with the factory dtb that matches their partition layout. Any genuine package now works (an OTA .tar.gz as well as an SD .zip), since the package's own dtb is no longer needed. cli/gui: --stock-firmware / the uninstall dialog no longer require a package with a device tree. docs updated. NOTE: not yet hardware-verified - the bench S17 is mid-recovery (serial-link hardware issue) and must be brought back before this can be proven on the board. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -989,23 +989,22 @@ fn run_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>>
|
||||
let host = opts.value("host").ok_or("--host is required")?.to_owned();
|
||||
let firmware = opts.value("stock-firmware").ok_or(
|
||||
"--stock-firmware <genuine Bitmain firmware file> is required \
|
||||
(SD recovery image SD_Antminer-*.zip, which includes the device tree)",
|
||||
(an OTA update .tar.gz or an SD recovery .zip for this board)",
|
||||
)?;
|
||||
// Restore reaches the alkane board over SSH as root; the board credential is
|
||||
// supplied via --password-file / ALKANE_BOARD_PASSWORD(_FILE).
|
||||
let password = read_board_password(&opts)?;
|
||||
|
||||
// Parse the genuine vendor package into the stock images to write back.
|
||||
// Parse the genuine vendor package for the stock kernel + rootfs. The kernel
|
||||
// device tree is not in distributable Bitmain firmware; the toolkit supplies
|
||||
// the correct per-board dtb, so any genuine package (OTA or SD) works here.
|
||||
let fw = stock_firmware::parse(Path::new(firmware))?;
|
||||
let dtb = fw.dtb.as_deref().ok_or(
|
||||
"this firmware package has no device tree; use the Bitmain SD recovery \
|
||||
image (SD_Antminer-S17-*.zip), which includes devicetree.dtb",
|
||||
)?;
|
||||
println!("stock firmware: {}", fw.summary());
|
||||
|
||||
if opts.flag("dry-run") {
|
||||
println!("DRY RUN: would restore {host} to stock by writing the stock dtb, kernel and");
|
||||
println!("rootfs back to NAND (BOOT.bin preserved). Re-run with --confirm FLASH.");
|
||||
println!("DRY RUN: would restore {host} to stock by writing the genuine stock kernel");
|
||||
println!("and rootfs plus the per-board device tree back to NAND (BOOT.bin preserved).");
|
||||
println!("Re-run with --confirm FLASH.");
|
||||
return Ok(());
|
||||
}
|
||||
if opts.value("confirm") != Some("FLASH") {
|
||||
@@ -1013,7 +1012,6 @@ fn run_restore_stock(args: &[String]) -> Result<(), Box<dyn std::error::Error>>
|
||||
}
|
||||
println!("restoring {host} to genuine stock from {firmware} (network-only)...");
|
||||
let images = RestoreImages {
|
||||
dtb,
|
||||
kernel: &fw.kernel,
|
||||
rootfs: &fw.rootfs,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user