Post
Topic
Board Hardware
Merits 1 from 1 user
Re: Open Source Bitcoin ASIC miner project that uses 2x BM1387 (Antminer S9)
by
Skot
on 13/01/2023, 04:47:35 UTC
⭐ Merited by n0nce (1)
Assuming that someone is competent in both C and Rust , IMHO ,  multithreaded/concurrent code that is correct and produces no undefined behavior is better.  Also memory safety is a key feature that Rust brings to the table. In C you are on your own with concurrency and God help you if you are new to C programming. You will get baptism by fire.
C / C++ and Python are my go-to languages but C tends to be a little messy to code sometimes but gets better with age i guess.
Okay, so those are general advantages that come with Rust. I thought there was something specific about MCUs. Do we need a lot of multithreading for this application, though? You request a block candidate over Stratum v2, build a packet for your miner and send it. Then wait for it to respond. As far as I know, that's the rough big picture.

I really like the idea of Rust. I just haven't seen anything convincing about support on the ESP32. Or really any MCU other than the STM32, which is hard AF to source these days.

Concurrency in C isn't too bad if you have a RTOS like FreeRTOS that ESP-IDF uses. I put together a first pass at a (ESP-IDF based) firmware architecture here; l https://github.com/skot/ESP-Miner . I'm sure this will need some refinement, but the basic idea is what n0nce said; get the work over stratum, build a packet and send it to the BM1397. Wait for a response and if you don't get one in time, roll extra nonce and send another!

Braiins has taken down the source to their "community edition" S9 firmware. I'm kicking myself for not cloning it back when they had it up. That would have been a good resource.

Check this out though; Someone did a research paper and posted code for a stratum implementation and CPU mining on ESP32 (and Playstation!) https://www.researchgate.net/publication/360353621_Implementation_of_an_efficient_portable_and_platform-agnostic_cryptocurrency_mining_algorithm_for_Internet_of_Things_devices