Skip to content

Add BZM ASIC and Bonanza board support - #1986

Draft
johnny9 wants to merge 27 commits into
bitaxeorg:masterfrom
johnny9:port/pr1972-bzm-bonanza-drivers
Draft

johnny9 wants to merge 27 commits into
bitaxeorg:masterfrom
johnny9:port/pr1972-bzm-bonanza-drivers

Conversation

@johnny9

@johnny9 johnny9 commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator

Adds BZM ASIC and Bonanza 1002 support for mining, power, cooling, and live frequency control. Depends on #1972.

QEMU validation: 143 tests passed, with 0 failures and 0 ignored.
Port the relevant fixes from UBSan PR bitaxeorg#1976 (a3e5540), retaining the existing byte-safe target conversion. Validate alignment at compile time and overlapping buffers in the ordinary QEMU suite.

Validation: 144 QEMU tests passed; full ESP-IDF firmware build passed.
Retain asic_job_t in active slots and build final Bitmain packets immediately before sending. Share the newer-chip encoder and keep BM1397 midstate generation in its packet builder, removing bm_job and reverse conversion.

Preserve packet bytes, snapshot ownership, and result version mapping with regression tests. Fix masked version increment carry and wraparound exposed by the BM1397 sparse-mask fixture.

Validation: 145 QEMU tests pass; ESP32-S3 firmware builds with ESP-IDF 6.0.2.
Capture the retained common job while decoding each nonce response and derive its rolled version from that same snapshot. Validation and pool submission consume the result context directly, removing the public job getter and the second slot lookup.

Keep hardware job IDs internal and reject response IDs outside the active slots. Exercise snapshot lifetime across slot replacement for every Bitmain driver and job protocol, and run result-task tests without an active-job store.

Validation: 145 QEMU tests pass; ESP32-S3 firmware builds with ESP-IDF 6.0.2.
Unity runs production job building and SHA-256 below large test fixtures on its main task. The default 3584-byte stack can overflow into heap metadata, causing a later cJSON allocation to assert in remove_free_block.

Use the same 8192-byte stack budget as the firmware job and result tasks, and enable the stack-end watchpoint. Diagnostic runs with comprehensive heap poisoning and integrity checks before and after each test pass at 8192 bytes and show approximately 6 KB peak usage.

Validation: a fresh ESP32-S3 QEMU configuration passes all 145 tests.
Add BZM work encoding, generation-aware assignments, result adaptation, and staged safety primitives. Keep job/result ownership compatible with PR1972 and limit the driver surface to the mining and board integration.
Bind Bonanza power, clocks, cooling, bridge leases and verified shutdown to a single board owner. Integrate pause/resume, self-test, ESP firmware OTA and restart using the existing application interfaces.

Use the existing headless mode for Bonanza startup.
Document the scoped driver port, excluded display and support/update APIs, firmware build and 400 passing QEMU tests.
Preserve the production defaults in their owning driver and board modules. Derive local nonce difficulty from the ASIC filter and share only the telemetry freshness limit. Remove the menu and use explicit protocol values in the existing tests.
Replace validation stages, duplicate supervision and nonce-proof qualification
with ordered production startup and the existing board owner. Remove parser
qualification, unused diagnostics and obsolete driver APIs while retaining
electrical shutdown, bridge leases, thermal protection, result validation and
synchronization of live clock changes with engine work.

Use the Bonanza regulator profile directly and restrict periodic snapshots
to live operating data. Keep hard-protection readback and fault decoding.

Consolidate ASIC startup into one driver transaction with fixed sensor/800 MHz
settings. Remove stage readiness flags, duplicate activation accounting,
progress reports, the unused single-midstate mode and legacy topology APIs.
Preserve register values, sequencing, receive windows and engine acknowledgements.

Add production board, driver and regulator regression tests, including a
pre-refactor startup trace and failure injection through startup and rollback.
Shared changes remain limited to ASIC build/test CMake entries.

Validation: ESP-IDF 6.0.2 firmware build; 334 QEMU tests, zero failures;
git diff --check. Clean source 96e3a5d passed HTTP OTA, startup, safe-off
pause, resume and restart on bonanza.local at its saved 1200 MHz target.
All four ASICs mined; each active phase produced fresh accepted shares
with zero rejects. Settings and the previous OTA image were preserved.
The validation-note amendment changes no firmware source.
@github-actions

github-actions Bot commented Sep 19, 2026

Copy link
Copy Markdown

Test Results

  2 files  ±  0    2 suites  ±0   2s ⏱️ ±0s
428 tests +207  428 ✅ +207  0 💤 ±0  0 ❌ ±0 
430 runs  +207  430 ✅ +207  0 💤 ±0  0 ❌ ±0 

Results for commit c37e508. ± Comparison against base commit 0c798de.

This pull request removes 7 and adds 214 tests. Note that renamed tests count towards both.
test_asic_result_task ‑ result task keeps owned snapshots through submission for every protocol
test_asic_result_task ‑ result task separates registers and rejects unavailable job slots
test_job_building ‑ Bitmain job defaults and explicit values preserve metadata precedence
test_job_building ‑ Bitmain software midstate count honors zero mask and the buffer limit
test_mining ‑ Validate midstate generation
test_mining_pipeline ‑ SV1 notify reaches the ASIC job boundary byte exact
test_mining_pipeline ‑ SV2 standard messages reach the ASIC job boundary byte exact
test_asic_job ‑ Bitcoin header encodes hash bytes and little-endian integers
test_asic_result_job ‑ ASIC results preserve complete matched jobs across slot reuse for every driver
test_asic_result_job ‑ BM1366 and BM1397 reject response job IDs outside the active slots
test_asic_result_task ‑ result task separates registers and empty ASIC responses
test_asic_result_task ‑ result task submits embedded job snapshots without a job store for every protocol
test_asic_submit ‑ job submission owns metadata and recovers from allocation failures
test_asic_submit ‑ job submission rejects unterminated metadata before allocation
test_bitmain_job_packet_building ‑ BM1397 packet limits midstates and clears unused entries
test_bitmain_job_packet_building ‑ Bitmain packet builders support unaligned outputs without overwriting guards
test_bitmain_job_packet_building ‑ Validate midstate generation
…

♻️ This comment has been updated with latest results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant