next: Zynq restore uses the factory device tree; tier-2 in-place update and verify-live for Zynq #30

Merged
noah merged 2 commits from feature/afw-os-bundle into next 2026-11-12 11:04:02 -07:00
Owner

Two fixes for the Zynq-7010 (Antminer S17/S19 class) paths, both proven on bench hardware (S17, 2026-11-12).

Restore-to-stock writes the correct device tree (f63127d63)

Restore now writes the genuine Bitmain kernel and rootfs from the vendor package plus the board's factory device tree (fetched and SHA-256 verified), instead of the device tree inside the SD recovery image. The SD image's tree defines 5 NAND partitions; the stock rootfs attaches mtd5 (reserve1, 0x8000000) and reboot-looped without it.

Hardware result: after afw restore-stock --stock-firmware SD_S17.zip, the stock kernel created 6 MTD partitions, ubiattach -m 5 attached reserve1, init reached runlevel 5, the board took its DHCP lease and answered 401 lighttpd/1.4.32 antMiner Configuration, with no reboot loop.

Zynq tier-2 update in place; verify-live for Zynq (dc787f1f3)

The old Zynq tier-2 install wrote raw images device-relative on /dev/mtd0//dev/mtd1. On the current alkane image those are stock-cfg/alkane-cfg, so it would have erased alkane-cfg first, and its raw zImage/cpio are not bootable by the stock U-Boot. Its preflight only checked that mtd0/mtd1 existed.

  • StockMethod::update_in_place: refuses a board not running alkane, re-registers the boot regions, saves every slot locally before any erase, writes rootfs/dtb/kernel as the stock U-Boot's legacy uImages through the shared target builder (BOOT.bin guard, md5 readback), reboots and waits. --dry-run reports the live storage map and plan.
  • boards::zynq keeps the manifest gate, now in absolute NAND slots with ceilings that leave room for the uImage header.
  • verify-live gains a Zynq check (HTTP marker, case-insensitive; root SSH reporting alkane and the installed kernel; prints the kernel cmdline).
  • New tests for the protected alkane map, registered/split boot maps, slot overrun and the BOOT.bin guard.

Hardware result: from a RAM-booted alkane, afw install --confirm FLASH backed up and wrote all three slots; the serial console showed the stock U-Boot booting alkane from NAND; verify-live PASS.

Checks

  • cargo test -p alkane-flash -p alkane-cli: 71 passed; clippy clean.
  • Full cycle on the S17: restore-stock -> healthy stock -> install --from-stock -> verify-live (see the bench record in miner-bench-wiki, status-log 2026-11-12).

Generated with Claude Code

https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i

Two fixes for the Zynq-7010 (Antminer S17/S19 class) paths, both proven on bench hardware (S17, 2026-11-12). ## Restore-to-stock writes the correct device tree (f63127d63) Restore now writes the genuine Bitmain kernel and rootfs from the vendor package plus the board's factory device tree (fetched and SHA-256 verified), instead of the device tree inside the SD recovery image. The SD image's tree defines 5 NAND partitions; the stock rootfs attaches `mtd5` (`reserve1`, 0x8000000) and reboot-looped without it. Hardware result: after `afw restore-stock --stock-firmware SD_S17.zip`, the stock kernel created 6 MTD partitions, `ubiattach -m 5` attached `reserve1`, init reached runlevel 5, the board took its DHCP lease and answered `401 lighttpd/1.4.32 antMiner Configuration`, with no reboot loop. ## Zynq tier-2 update in place; verify-live for Zynq (dc787f1f3) The old Zynq tier-2 install wrote raw images device-relative on `/dev/mtd0`/`/dev/mtd1`. On the current alkane image those are `stock-cfg`/`alkane-cfg`, so it would have erased `alkane-cfg` first, and its raw zImage/cpio are not bootable by the stock U-Boot. Its preflight only checked that mtd0/mtd1 existed. - `StockMethod::update_in_place`: refuses a board not running alkane, re-registers the boot regions, saves every slot locally before any erase, writes rootfs/dtb/kernel as the stock U-Boot's legacy uImages through the shared target builder (BOOT.bin guard, md5 readback), reboots and waits. `--dry-run` reports the live storage map and plan. - `boards::zynq` keeps the manifest gate, now in absolute NAND slots with ceilings that leave room for the uImage header. - `verify-live` gains a Zynq check (HTTP marker, case-insensitive; root SSH reporting alkane and the installed kernel; prints the kernel cmdline). - New tests for the protected alkane map, registered/split boot maps, slot overrun and the BOOT.bin guard. Hardware result: from a RAM-booted alkane, `afw install --confirm FLASH` backed up and wrote all three slots; the serial console showed the stock U-Boot booting alkane from NAND; `verify-live` PASS. ## Checks - `cargo test -p alkane-flash -p alkane-cli`: 71 passed; clippy clean. - Full cycle on the S17: restore-stock -> healthy stock -> install --from-stock -> verify-live (see the bench record in miner-bench-wiki, status-log 2026-11-12). Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
noah added 2 commits 2026-11-12 10:58:35 -07:00
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
flash: Zynq tier-2 update in place through the verified writer; verify-live for Zynq
verify / verify (pull_request) Skipped
source / check (pull_request) Successful in 4m24s
dc787f1f3b
The Zynq tier-2 install wrote raw images at device-relative offsets on
/dev/mtd0 and /dev/mtd1. On the current alkane image those are stock-cfg and
alkane-cfg, not the boot regions, so it would have erased alkane-cfg first, and
its raw zImage/cpio are not bootable by the stock U-Boot. Its preflight only
checked that mtd0 and mtd1 existed.

- Add StockMethod::update_in_place: refuses a board not running alkane,
  re-registers the boot regions (as restore does), saves every slot locally
  before any erase, writes rootfs/dtb/kernel as the uImages the stock U-Boot
  boots via the shared target builder (BOOT.bin guard, md5 readback), reboots
  and waits for alkane. --dry-run reports the live storage map and the plan.
- boards::zynq keeps the manifest gate; the plan is now in absolute NAND slots
  with ceilings that leave room for the uImage header. The stale writer and
  preflight are removed.
- CLI: Zynq preflight/install use the new path before the generic user
  transport connects.
- verify-live gains a Zynq check (HTTP marker, case-insensitive, plus root SSH
  reporting alkane and the installed kernel; prints the kernel cmdline). It
  previously fell through to the CV1835 check.
- Tests for the protected alkane map, registered and split boot maps, slot
  overrun, and the BOOT.bin guard.

Verified on an S17 (Zynq-7010): dry run, install from a RAM-booted alkane,
NAND boot confirmed on the serial console, verify-live PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
noah added 1 commit 2026-11-12 10:58:36 -07:00
flash: Zynq tier-2 update in place through the verified writer; verify-live for Zynq
verify / verify (pull_request) Skipped
source / check (pull_request) Successful in 4m24s
dc787f1f3b
The Zynq tier-2 install wrote raw images at device-relative offsets on
/dev/mtd0 and /dev/mtd1. On the current alkane image those are stock-cfg and
alkane-cfg, not the boot regions, so it would have erased alkane-cfg first, and
its raw zImage/cpio are not bootable by the stock U-Boot. Its preflight only
checked that mtd0 and mtd1 existed.

- Add StockMethod::update_in_place: refuses a board not running alkane,
  re-registers the boot regions (as restore does), saves every slot locally
  before any erase, writes rootfs/dtb/kernel as the uImages the stock U-Boot
  boots via the shared target builder (BOOT.bin guard, md5 readback), reboots
  and waits for alkane. --dry-run reports the live storage map and the plan.
- boards::zynq keeps the manifest gate; the plan is now in absolute NAND slots
  with ceilings that leave room for the uImage header. The stale writer and
  preflight are removed.
- CLI: Zynq preflight/install use the new path before the generic user
  transport connects.
- verify-live gains a Zynq check (HTTP marker, case-insensitive, plus root SSH
  reporting alkane and the installed kernel; prints the kernel cmdline). It
  previously fell through to the CV1835 check.
- Tests for the protected alkane map, registered and split boot maps, slot
  overrun, and the BOOT.bin guard.

Verified on an S17 (Zynq-7010): dry run, install from a RAM-booted alkane,
NAND boot confirmed on the serial console, verify-live PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
noah merged commit 4305da5e57 into next 2026-11-12 11:04:02 -07:00
Sign in to join this conversation.