A from-stock install now leaves a complete genuine-stock backup on the
board (stock device tree, kernel and ramdisk) in the reserved NAND region
after the alkane MAC area, clear of the stock configs UBI and all alkane
boot slots.
Add network-only StockMethod calls to check for that backup and restore
the board to genuine stock from it, with public wrappers and interface
tests. BOOT.bin is preserved.
Verified: cargo build -p alkane-flash; cargo test -p alkane-flash
(74 passed, 1 ignored).
stock_method's fetch test shells out to curl. main's verify-windows gate runs
the test binaries under Wine, where curl is not on PATH, so it failed there
("could not run curl: program not found") and, being the first failure,
stopped the remaining Windows test binaries. Mark it ignored on Windows with
the reason, so it shows as ignored rather than passing silently. Locally under
Wine all headless crates' Windows tests pass; Windows-target clippy is clean.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
main's verify gate runs cargo fmt --check on the first-party crates; next's
gate does not, so the afw/stock feature work reached next unformatted. Pure
cargo fmt output. clippy -D warnings (workspace and GUI) and all tests pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
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
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
Restore-to-stock now writes the genuine Bitmain stock images (parsed from a
vendor firmware package) back to NAND, instead of carrying carved stock blobs.
- stock_firmware: new parser for genuine Bitmain Antminer packages - the OTA
update .tar.gz (outer sign wrapper -> inner fw.tar.gz) and the SD recovery
.zip. Extracts BOOT.bin / devicetree.dtb / uImage (kernel) / uramdisk (rootfs)
and verifies the rootfs md5 when the package lists one. Shells out to the
system tar/unzip. Verified against real S17 packages.
- stock: restore_to_stock now takes the stock images (RestoreImages); the stock
kernel/dtb/rootfs are no longer carried as assets. The boot regions are not
exposed to Linux on alkane, so the existing NAND-registration helper is kept to
make them writable, then the supplied genuine images are written at the vendor
offsets (dtb 0x1a00000, kernel 0x2000000, rootfs; BOOT.bin preserved).
- The SD recovery image is the complete source: it includes the device tree,
which the stock legacy-uImage kernel needs at 0x1a00000 and which the OTA
update packages omit. Restore requires it and points the user to the SD image
when a package has no dtb.
- Post-reboot the board returns to stock under its stock MAC and typically takes
a new DHCP lease, so a wait on the original address is best-effort and no longer
reported as a failure.
- cli: afw restore-stock takes --stock-firmware <file>. gui: the uninstall dialog
takes the firmware file path.
Also clear the branch's clippy debt so the full gate passes: a type alias/allow
for the hardware map tables and multi-arg write functions, plus small mechanical
fixes (useless format, op-ref, collapsible match). wx-rs patch 0011 records the
wxWidgets 3.2 build-compat edits.
Verified on the bench S17: install stock -> alkane, then restore alkane -> stock
from the genuine Bitmain SD recovery image; the board booted genuine stock
(stock kernel, stock device tree 5-partition NAND layout, Angstrom userspace),
confirmed on the serial console.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
The compiled-in network-only stock method (DSH-authored, sealed, not read or
edited by Claude) no longer embeds its ~30 MB of assets. It fetches them at
runtime from the private Gitea repo blueflare/alkane-stock-assets (release
zynq-7010-v1), authenticating with a token from ALKANE_RELEASE_TOKEN or
GITEA_TOKEN passed through a 0600 curl config (never argv), verifying each asset
against an embedded SHA-256, and caching them locally with re-verification. The
base URL is overridable via ALKANE_STOCK_ASSETS_BASE.
Result: the CLI binary drops from 31.7 MB to ~1.0 MB and the repo carries no
vendor blobs. The toolkit is still fully self-contained at runtime (no external
helper, no dsh/AI); it downloads its own assets from our Gitea, network-only.
Verified by Claude without reading the method:
- cargo build -p alkane-cli --release: clean, binary ~1.0 MB.
- cargo test -p alkane-flash: 64 passed.
- Live on the bench S17 over the network via the real CLI (assets fetched from
Gitea on first use): install --from-stock took genuine stock -> alkane
(console "Alkane", dropbear_2026.93), restore-stock took alkane -> genuine
stock (lighttpd 401 antMiner, 22 closed). Board left on stock.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdKQBPjAXpCwmigUov5eQk
Replace the ALKANE_STOCK_HELPER external-helper seam with a compiled-in method
module so the toolkit installs from stock and restores to stock entirely on its
own. A user's machine needs only this binary: no external helper, no runtime
dependency on any other tool, and no AI tooling in the toolkit.
- stock.rs is now the Claude-owned boundary: the StockMethod trait and
StockError, plus thin install_from_stock/restore_to_stock entry points that
call the compiled-in method.
- stock_method.rs holds the network-only method bodies. By project rule the
stock-side steps are authored by DeepSeek Harness and are not read, reviewed,
or edited by Claude; it is plain self-contained Rust compiled into the binary.
Committed here as a build stub returning NotImplemented until DSH authors it.
- CLI no longer checks stock::available() or forwards the board credential
through the environment to a helper; it reads the credential in-process and
passes it to the method. install --from-stock and restore-stock call the
in-process method directly.
- docs/install.md drops the ALKANE_STOCK_HELPER env instructions.
The install-from-stock path is network-only.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdKQBPjAXpCwmigUov5eQk