Hi everyone! Over the last few weeks I've been contributing to NerdMiner Modded by HenrysCat. Seven of my pull requests are now merged in main. Here's what's new.
M5StickC Plus2 support (#6)
Build environment: M5Stick-C-Plus2 (pio run -e M5Stick-C-Plus2 -t upload)
- ~1 MH/s (995 to 1015 KH/s on mine): pipelined hardware SHA loop on core 1, software miner on core 0
- Battery level in the top bar, and a clean power off when the battery is flat (no brown-out reboot loop)
- Buttons: screen off/on, rotate, next screen, power off (deep sleep on USB)
- Screen brightness, screen timeout and night dimming from the web settings page
- On-board RTC: the clock is right at power-on, even without Wi-Fi
- Red LED flash + beep when a share is found
- Optional automatic EU summer/winter time
Assembly software miner on ESP32 (#7)
On classic ESP32 boards, the software miner on core 0 is now written in Xtensa assembly. On my Plus2, it went from 28.9 to 34.7 KH/s (+20%). The Plus2 also skips screen redraws while its screen is off.
Bug fixes for every board (#6, #8, #9)
I went through the whole firmware looking for bugs. Most of these were already in the original NerdMiner code:
- A pool password of 20+ characters overflowed a buffer and corrupted memory
- After 49.7 days of uptime, the screen stats, stats saves and settings changes froze for another 49.7 days (the
millis() counter wraps around) - A coinbase longer than 256 bytes was silently cut, so every share was rejected on some pools
checkValid() could report a block that was never found- Refused shares were counted as accepted, and
"error": false from some pools wasn't understood - Mining stats are saved in two CRC'd slots, so a power cut during a save no longer resets your counters, and they're saved at least every 10 min instead of up to every 12 h
- Malformed jobs from a pool are refused instead of overflowing buffers, and a difficulty of 0 is ignored
" and \ in worker names / passwords are escaped- The "total hashes" counter no longer wraps after ~50 days, and a few smaller overflows are fixed
Wrong wallet? Now you'll know (#9, #11)
Before, if the pool refused your BTC address, the miner kept mining and every share was rejected, with no explanation. Now the refusal is detected, and you get a red WALLET REFUSED box on the screen (Plus2, T-Display, S3-GEEK, Cardputer) and on the web monitor.
Live web monitor, now in 6 languages (#6, #12)
Open http://<miner IP>/ on any phone or PC on your network: hashrate with a 1-hour graph, shares, best difficulty, pool, BTC price, Wi-Fi, and the battery on the Plus2. No login, no wallet address shown. It now follows your browser's language: English, French, Spanish, German, Italian, Portuguese.
Unit tests (#13)
pio test -e native runs 15 tests on your PC in a few seconds, no board needed: stratum parsing, the block header built from a job (checked against Python's hashlib), share checks on a real block, and the SHA-256d code. They would have caught the coinbase bug above.
Tech: C++ (Arduino / PlatformIO, ESP-IDF), hand-tuned Xtensa assembly for the SW miner (generated and checked by a Python script against hashlib), HTML/JS for the web monitor.
Still in review: a web flasher (install from Chrome, no PlatformIO), MQTT / Home Assistant support, and the assembly miner on ESP32-S3.
Feedback and testing on other boards are very welcome!
Big thanks to HenrysCat for the reviews and for testing on the CYD and the T-Display.
GitHub: NerdMiner Modded · my fork: bdlglua/NerdMiner-Modded-rewrite