fix(c3/s2): correct HW SHA full double-hash instead of software (#34) - #39
Conversation
) ESP32-C3/S2 builds were mining in pure software (~1 KH/s) because setupTasks() spawned the software miner_task_core0 on single-core SoCs; the hardware HAL mining task (miner_task_core1) was never instantiated and was effectively dead code. The reporter's "Software (Optimized)" banner and low hashrate were the symptom. Simply routing C3 to the old HAL task would NOT have worked: its sha256_ll_double_hash() restores a midstate into SHA_H and issues SHA_CONTINUE, which the S2/S3/C3 SHA engine ignores (the same root cause as the S3 zero-shares bug, #28). So this: - Implements sha256_ll_double_hash_full() for S2/S3/C3 (previously a stub returning false). It hashes block 1 + block 2 with the legitimate START -> CONTINUE flow and the second SHA with a fresh START -- no external midstate injection -- which is correct on every variant. It re-hashes block 1 each nonce (no midstate cache), trading a little speed for correctness; still far faster than software. - Rewrites the C3/S2 miner_task_core1 to mine with that HW path and re-verify every candidate in software (miner_sha256_header) before submitting, so a wrong HW hash can never become a bad share. Enable -D DEBUG_SHARE_VALIDATION to log PASS/FAIL per candidate. - Routes single-core builds to miner_task_core1 at low priority with frequent yields, so WiFi/Stratum/Monitor stay responsive on the one core. - Fixes the boot banner: C3 envs now define USE_HARDWARE_SHA (was the dead USE_SOFTWARE_SHA), so the reported SHA implementation is honest. Needs on-device confirmation on an ESP32-C3 (watch for [HW-DBG] SW verify=PASS lines and shares landing at the pool). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
c07ca91 to
3ecc694
Compare
…-C3/S2 # Conflicts: # platformio.ini
…-C3/S2 # Conflicts: # platformio.ini
…fallback The raw-register HW path has never run on real C3/S2 silicon. If the register sequence disagrees with the chip, the failure mode is silent: fast hashrate counter, zero shares, no logs (#34). Adds a boot-time known-vector check (all-zero header, nonce 0x0000C4E6, true double-SHA starts 0x000025EE so both 16-bit early-reject gates pass) comparing sha256_ll_double_hash_full against the software reference; on mismatch the miner task falls back to the software path (pre-#39 behavior). Also corrects the root-cause comments: S2/S3/C3 SHA_H digest-state registers expect big-endian state words (espressif/esp-idf#12440) -- the midstate path seeded little-endian -- rather than 'ignores SHA_H writes on CONTINUE'. Co-Authored-By: Claude <noreply@anthropic.com>
|
Full review done against What holds up
The change that unblocked merging Also corrected the root-cause comments while in here: the S2/S3/C3 #34 — @bwhiteman21-commits the flash test is still worth running on real C3 silicon; with this merged a stock build reports at boot whether the HW path passed its self-test, which makes your report a one-liner. Hashrate should jump from ~1 KH/s by a couple of orders of magnitude; if the self-test FAILs on your board, that log line is exactly what I need. |
…se automation - Bump AUTO_VERSION to v2.9.6-pre across all envs - README: honest S3 (~50-55 KH/s, software-verified) and C3 (pending validation) numbers; old 280-400 KH/s figures were invalid shares - CHANGELOG entry for everything in this batch (SneezeGUI#36 SneezeGUI#37 SneezeGUI#38 SneezeGUI#39 SneezeGUI#44 SneezeGUI#45) - build.yml: upload factory-bin test builds on every PR - release.yml: tag-triggered build of all 17 targets + GitHub Release with factory/firmware bins (uses post_build_merge.py output) Co-Authored-By: Claude <noreply@anthropic.com>
Draft — contains new hardware register sequencing that has not been tested on a physical C3 yet.
Problem
ESP32-C3 mines in software at ~1 KH/s (#34). Cause: single-core SoCs only spawned the software miner task; the HAL HW path was dead code — and it used the same unsupported
SHA_H+SHA_CONTINUEmidstate restore as the S3 bug (#28), so routing C3 to it would also yield 0 shares.Fix
sha256_ll_double_hash_full()for S2/S3/C3 using the legitimateSTART → CONTINUEflow (no midstate injection), reusing this file's proven helpers.[HW-DBG]output, never a bad submission.-D DEBUG_SHARE_VALIDATION; confirm[HW-DBG] ... SW verify=PASSand shares at the pool, hashrate well above 1 KH/s.Closes #34.