diff --git a/crates/alkane-artifacts/data/manifest-seed.csv b/crates/alkane-artifacts/data/manifest-seed.csv new file mode 100644 index 00000000..e9b63b8f --- /dev/null +++ b/crates/alkane-artifacts/data/manifest-seed.csv @@ -0,0 +1,15 @@ +sha256,size_bytes,path,family,format,applicability +e56393cbc26a5a97f677b22b8fe9abed705afd91854d4c59831777da8b529bd6,71586875,H3 SD card Program-20220422.zip,whatsminer-h3,IMAGEWTY-SD,SD install source; edit_wm_imagewty_h3.py input +12a2367327396c04c14cb2976855f7d98005b63cdce2fcc555c6d7a051ef9e1c,73633572,H6 SD Card Program-20210121.zip,whatsminer-h6,IMAGEWTY-SD,SD install source +be9728390c36698006751761275abfd47d5b1dd435b946b77afc61ca4f24e670,77956225,H6os SD Card Program-20220422.zip,whatsminer-h6os,IMAGEWTY-SD,SD install source +651f70ff184cbf4387066a6edbbc44e36b571f21911aeb1ed02f975ae65ccf27,120146097,Antminer_s21-t21-s19-t19-l7_ANT_Global_0_0.9.9.4.zip,bitmain-stock,update-zip,S21/T21/S19/T19/L7 stock source +f4e7ffb19f2e8917c1323848b8b5716018ddf429e750eeeb9db2410ae88ce1d1,60821504,powerplay-amlogic-epic-antminer-update-v1.22.0-28830069.ubifs,epic-umc-a113d,ubifs,ePIC install source; root:letmein vector +2dfb99bbbf977b9874af547c89fb7f5005e94449050ed43679578fd7f42a6fb3,45143628,Whatsminer-all-20260729.11_1786698699016.bin.bak,whatsminer-ota,bin-AES-container,network-update input only +6f26295b31db31d4c33c07e3c4f746d3d9c4d9c6a2e812e81d6386be98d8f361,64457212,luxos-installer_1.19.0.zip,luxos,zip-installer,bb/xil/aml source-OS route; no cvitek asset +b2e5b64c24808402ecd421ead6d05a3b7319acfc26b8c36a5172f5cc77125073,20679718,firmware-analysis/bixbit-antminer/bixbit-BB-universal.bmu,bixbit-bb,bmu,am335x-bb source/carve +3f8e519fddd8c5f50fe11f1ab3c3efa551b7ade2caf69e4bf61ca39ee1abae7e,22529209,firmware-analysis/bixbit-antminer/bixbit-CV-universal.bmu,bixbit-cv,bmu,cv1835 source/carve +7294c8a3e1be42670ca55bf9bd42fbfa894ffb52d1773f3e1faceaf9090c2ec0,29887071,firmware-analysis/bixbit-antminer/bixbit-XLNX-universal.bmu,bixbit-xlnx,bmu,zynq-7010 source/carve +670980107a0125e16fe01d271c9a6b9ebeee5d82835474d7ac741d1840307484,43838976,firmware-analysis/epic/powerplay-antminer-update-v1.20.4-297ddfd7.swu,epic-umc-am335x,swu,am335x-bb install source +f1ec045497570e794b920c45c5121fb834eae5a2803118d3f0c4a89ef7a4233b,12686696,scratch/wm-install-build/pkgs/20251209_embed0_alg1_t8c790afe.bin,whatsminer-h616-pkg,wm-package-0x9a5ba57c,h616 update-endpoint install (forged) +eaf26b9cf19cce872ea53f39c4d38796df4221f9cee7d0822cd2ec827ad60952,12905720,scratch/wm-install-build/pkgs-h3/m2x_1.6.0.2_alg1_chip0.bin,whatsminer-h3-pkg,wm-package-0x9a5ba57c,h3 update-endpoint install (forged) +628bf53e582e2b31756f7e3ff522d4e8ad9c99b17e4eda4d24045988a2ac25f3,24857600,firmware-analysis/bixbit-antminer/bixbit-AML-universal.bmu,bixbit-aml,bmu,a113d source/carve diff --git a/docs/IMPLEMENTATION-PLAN.md b/docs/IMPLEMENTATION-PLAN.md index dee0f50d..c17ccec5 100644 --- a/docs/IMPLEMENTATION-PLAN.md +++ b/docs/IMPLEMENTATION-PLAN.md @@ -68,7 +68,7 @@ discover -> classify(board, soc, running-fw, chip) -> foothold(root) ## 3. Architecture -Cargo workspace, core in Rust, GUI per section 5. +Cargo workspace, core in Rust, GUI per section 6. ``` crates/ @@ -80,26 +80,43 @@ crates/ alkane-access/ foothold: SSH (russh) with legacy algo support (diffie-hellman-group1-sha1, ssh-rsa, aes128-cbc for old stock), credential table, Bitmain :4028 API client, - WhatsMiner API + remote-daemon :8889 client (AES-256 + - token auth md5_crypt, cmd 0x7 install, cmd 0xd ssh toggle) - alkane-flash/ transfer + write engines: SFTP/SSH-pipe dd, mtd writers, + WhatsMiner :4028 update_firmware client (md5crypt token + + SHA256(pwd_md5) AES-ECB, u32-LE chunk framing, live- + verified; the 8889 binary daemon stays out: key unknown), + update-daemon loopback RCE driver, serial-transport mode + (a113d ethernet RX broken on bench units; serial + base64/bzip2 push ~10 KiB/s is proven) + alkane-flash/ transfer + write engines: SSH exec-channel `cat >` pipes + (stock busyboxes have no SFTP server and no wget/tftp/nc; + use SFTP only where the OS provides it), mtd writers, eMMC raw, per-board packers (FIT/uImage/UBI), env-rewrite discipline (stage -> size-gate -> single-block dd -> - byte-compare readback), readback verification + byte-compare readback), readback verification, LuxOS = + official installer as subprocess + ed25519 inject + watcher port, IMAGEWTY patching = debugfs subprocess + first (Rust ext4 writer later) alkane-artifacts/ artifact registry: manifest (sha256, board applicability, - source provenance), verify-image port (magic/min-size/ - integrity), stock-package library from the bench corpus + source provenance; seed committed at + crates/alkane-artifacts/data/manifest-seed.csv), + verify-image port (magic/min-size/integrity), + stock-package library from the bench corpus alkane-cli/ headless driver for bench + scripting (`alkane-toolkit-cli`) -gui/ native GUI (decision in section 5) +gui/ native GUI (decision in section 6) docs/ this plan, ADRs, safety-model ``` Key design decisions: -- **D1 — Recipes as data.** Each `{board, source-OS}` recipe is a declarative - pipeline (stage list + parameters) interpreted by the engine, mirroring the - SDK's five-facts format (foothold, transfer, write target, verify, revert). - Adding a board/OS pair is data + tests, not new control flow. +- **D1 — Recipes and board knowledge as data, consumed from alkane-sdk.** + Each `{board, source-OS}` recipe is a declarative pipeline (stage list + + parameters) interpreted by the engine. The SDK already publishes the + machine-readable half: `boards/*/board.yml` (SoC, arch, boot.partitions, + install capabilities, firmware-install sources) and + `install/from-firmware//README.md` (foothold, transfer, write, + verify, revert). The toolkit parses these rather than duplicating them; + `persistence/` MTD tables (empty placeholders today) get materialized + from `board.yml` + `wiki/40-boot-os-and-build/board-os-matrix.md` into + the same machine-readable store. - **D2 — Every stage is idempotent-or-resumable** and produces an audit log entry (what, where, checksum before/after) so a failed install can be resumed or rolled back from the same state the log describes. @@ -110,16 +127,39 @@ Key design decisions: - **D4 — CLI first.** Every GUI action maps 1:1 to a CLI verb; the GUI is a view. This keeps the bench (headless) and the operator (GUI) on one engine. -## 4. Discovery + classification (M1 scope) +## 4. Bench-validated pathway matrix (what the engine must express) -Port of `tools/net-scan.py` plus the two already-agreed upgrades: +From `bench-wiki/boards/` + `MEMORY-SNAPSHOT/` — each row is proven on our +bench, so the recipe data format must carry all of this without special +cases: + +| Board (SoC) | Proven installs | Foothold on stock | Transfer | Hard rules | +|---|---|---|---|---| +| am335x-bb (S19j Pro) | 5/5 network-only (stock, LuxOS, ePIC, Braiins, Vnish → OurOS), round-tripped | `miner:miner` + update-daemon loopback RCE | SSH/SFTP | autoboot abort = ESC with 1 s window (catcher first, then power); mtd0-3 never written; bootloader written last; no SD boot proven — NAND is the only net | +| zynq-7010 (S19) | stock→OurOS, Vnish→OurOS network-only | `miner:miner` + loopback RCE | SSH/SFTP | PS RSA eFuse is per-unit — read 0xF800D010 before planning; FIT unverified branch is the entry; autoboot 0 s (keys must pre-flood); stock console echoes but no getty | +| zynq-7010 (S17) | stock NAND restore verified by CRC through U-Boot (2026-09-14) | stock `root` with EMPTY password; legacy SSH algos (dh-group1-sha1, ssh-rsa, aes128-cbc) | ymodem over serial for NAND writes; SSH for userspace | board mtd char/block reads return EIO — verify only via U-Boot `nand read`+`crc32`; ymodem splits at ≤2047 blocks; `reboot -f` no-ops from RAM-boot (sysrq `b`) | +| a113d (BHB42XXX) | 5/5 | `miner:miner` + loopback RCE; `amlenv.py` edits env in-band over SSH (`/dev/nand_env`) | SSH (net), U-Boot env is the boot switch | UBI volume name is order-dependent (`nvdada_log`/`umc_os_rootfs`/`overlay`) — detect live, never hardcode; per-OS DHCP lease differs (false DARK trap — a failed self-report downgrades to WARNING, SSH fingerprint decides) | +| a113d hardened (S21 Pro) | stock restore via env swap; two root paths | `miner:miner`; daemon injection char-whitelisted (dead) — use `eclipse`/`updatem` forged `{type:root}` package → sudoers → root | SSH or serial-only (base64/bzip2, ~10 KiB/s, ~11 min install) | stock busybox has no wget/nc/tftp/curl/gzip/xz; console arg must be `ttyAML0`+`meson` earlycon or the board boots blind and the install looks failed | +| cv1835 (S19k Pro) | 3/3 buildable (LuxOS no asset, ePIC wrong silicon excluded) | `miner:miner` + `/nvdata/rroot` (non-permanent — p7 reformat destroys it; gate on `rroot -c id`) or loopback RCE | SSH pipe (`cat >`, busybox has no wget/tftp/nc) | Vnish/Braiins are RAM overlays on stock kernel — exit while overlay is live; eMMC boot0 eFuse-hook units cannot SD-recover; golden copy at raw LBA 0x300000 is the only net; serial catch needs 3 ms flood | +| allwinner H3/H6/H616 (WhatsMiner) | rooted `/data` overlay survives genuine reinstall (proven on H616); genuine network update executed on H3 + H616 | `admin:admin` uid-300 shell; root via `/data/rootshell` overlay (persists) or rooted SD image | 4028 API `update_firmware` (AES-ECB + md5crypt token, ≤1 MB chunks); IMAGEWTY SD-burn for rooted card | package format 0x9A5BA57C forgeable (MD5+CRC only); 8889 binary daemon AES key unknown — not implementable, use 4028; H616 payload key eFuse/OP-TEE-bound; H3 rootfs.fex LUKS (only /data slices editable); random MAC → DHCP moves | + +Fleet classification fingerprints: Antminer-family 4028 speaks +`{"command":...}`; WhatsMiner speaks `{"cmd":"get_version"}` and rejects the +other dialect — the cheapest reliable family split. SSH banner + KEX +offering narrows OS generation (old stock = legacy-only algos). + +## 5. Discovery + classification (M1 scope) + +Port of `tools/net-scan.py` (probe/classify logic is the spec: 4028 +NUL-terminated cgminer JSON, HTTP title+Server, SSH banner; per-host error +isolation) plus the two already-agreed upgrades: - Multi-subnet / CIDR-list targeting. - ARP/ICMP pre-pass so link-up-but-silent boards surface as a distinct row (a board we can identify but not log into is a restore candidate, not invisible). - Probes: TCP 4028 (cgminer API), 80/8080 (vendor http), 8889 (WhatsMiner - remote-daemon), 22 (SSH banner grab: dropbear/OpenSSH + algo fingerprint + remote-daemon; binary protocol, AES key unknown — reference only), 22 (SSH banner grab: dropbear/OpenSSH + algo fingerprint narrows the OS), plus WhatsMiner binary API cmd 0 read for model/firmware. - Output: machine inventory (ip, model, current fw family + version, board family guess, access level) feeding the install wizard. @@ -127,7 +167,7 @@ Port of `tools/net-scan.py` plus the two already-agreed upgrades: Respect `live-fleet-ops` rules: rate-limited, no auth bursts, production ranges excluded by default. -## 5. GUI: the wxWidgets decision +## 6. GUI: the wxWidgets decision Requirement: native cross-platform GUI, wxWidgets. Rust binding reality (checked crates.io 2026-09-14): @@ -151,33 +191,44 @@ Neither is production-grade. Two ways to honor the requirement: The plan proceeds on A as the default with the B spike as a gate in M0; the call is reversible until M3 (first GUI milestone). -## 6. Milestones +## 7. Milestones -- **M0 — Scaffold + GUI decision.** Workspace compiles, CI on gitea, ADRs - for D1-D4, wx spike (Option B) executed, binding decision recorded. +- **M0 — Scaffold + GUI decision.** Workspace compiles (done), CI on gitea, + ADRs for D1-D4 (drafted), wx spike (Option B) executed, binding decision + recorded. - **M1 — Discovery + classification.** Inventory table over a real bench subnet; the 9-board bench identifies correctly (S17 stock, S19 xil, S19j Pro bb, S19k Pro cv, S21 Pro aml, H3, H616, M50, WardenOS dev). -- **M2 — Artifact registry + verify-image.** Manifest of the stock packages - already on the bench (Antminer stock S17 package, WhatsMiner SD programs, - powerplay .ubifs, vendor zips) with sha256; magic/size/integrity checks. + Includes the dialect split (`command` vs `cmd` on :4028) and the + per-OS-DHCP-lease false-DARK rule. +- **M2 — Artifact registry + verify-image.** Seed manifest committed (14 + artifacts with sha256: WhatsMiner SD programs, Bitmain stock zip, ePIC + powerplay, BixBit .bmu set, forged WM packages, LuxOS installer); + remaining: bulk archives (3.7 GB / 624 MB), `firmware-analysis/downloads/` + per-model corpus, and the verify-image magic/size/integrity checks. - **M3 — First full pathway: zynq-7010.** stock -> stock restore (proven on C49, the S17) and any-supported-source -> alkaneOS once the SDK's zynq - artifacts exist. Foothold, SFTP transfer, mtd write with readback verify, - boot-switch, liveness + persist gates. This milestone exercises every - invariant for real. + artifacts exist. Foothold, exec-channel transfer, mtd write with readback + verify, boot-switch, liveness + persist gates. This milestone exercises + every invariant for real. - **M4 — SD recovery builders.** Port `make-sd-*.sh` + guided SD flow (generate image, verify, burn, boot instructions). -- **M5 — Remaining families.** WhatsMiner (remote-daemon install + package - builder port + `/data` overlay), a113d (serial transfer + env discipline), - cv1835 (SSH pipe + p1 FIT), am335x-bb. +- **M5 — Remaining families.** WhatsMiner (4028 update_firmware client + + package builder port + `/data` overlay), a113d (serial transport + env + discipline + hardened-S21 `updatem` vector), cv1835 (SSH pipe + p1 FIT), + am335x-bb. - **M6 — GUI completeness.** Fleet view, install wizard with per-stage progress/abort, audit log viewer, cross-platform packaging. Each milestone ends with a bench validation run against the 9-board fleet (none of which are live earners without explicit authorization). -## 7. Safety model (non-negotiables encoded at M0) +**v0 scope note:** no alkaneOS build exists yet (SDK boards are in `bake` +status; no rootfs/fit/uImage outputs). v0 therefore ships discovery + +classification + stock<->stock installs + SD recovery; the alkaneOS target +activates the same pipeline with different artifact references. + +## 8. Safety model (non-negotiables encoded at M0) - `secure` partition writes are refused by the engine, not gated by the UI. - Console-attached requirement: any stage that touches kernel/boot-adjacent @@ -191,7 +242,7 @@ Each milestone ends with a bench validation run against the 9-board fleet - Every artifact is verified (sha256 + format magic) before any byte is written; verify-write on an independent channel after. -## 8. Open questions (for the operator) +## 9. Open questions (for the operator) 1. GUI binding: proceed with Option A default, or run the Option B spike first? (Plan assumes A with the spike as a cheap gate.) @@ -202,10 +253,15 @@ Each milestone ends with a bench validation run against the 9-board fleet 4. alkaneOS artifact source: install waits on SDK board builds leaving `bake` status — v0 ships stock-restore + discovery until then? -## 9. References +## 10. References -- `../alkane-sdk/main/docs/install-methods.md` -- `../alkane-sdk/main/install/from-firmware/README.md` -- `../alkane-sdk/main/boards/` (per-board metadata) +- `../alkane-sdk/main/docs/install-methods.md` (invariants) +- `../alkane-sdk/main/install/from-firmware/README.md` (pattern + root vectors) +- `../alkane-sdk/main/boards/` (board.yml: partitions, install capabilities) - Bench wiki: `bench-wiki/boards/` (per-board install/restore evidence) -- Memory notes: `MEMORY-SNAPSHOT/` (firmware-flows-captured, whatsminer-*) +- Memory notes: `MEMORY-SNAPSHOT/` (firmware-flows-captured, whatsminer-*, + cb4-sd-boot-bixbit-ssh, aml-stock-live-capture) +- Tooling to port: `tools/net-scan.py`, `scratch/cb6-api-re/wm_package_builder.py`, + `scratch/wm-install-build/wm_install_client.py`, `scratch/wm-install-build/` + IMAGEWTY editors, `tools/luxos-inject-install.sh` +- Artifact seed manifest: `crates/alkane-artifacts/data/manifest-seed.csv`