/BM1387-miner-snippets

Code snippets for BM1387 miner

Primary LanguageC

BM1387-miner-snippets

Code snippets for BM1387 miner
OBSOLETE, all routines (updated and bug checked) can be found in my basic-BM1387-miner

(I'm using as little as possible libraries, and try to avoid any dynamic memory allocations, so no String type variables, classes etc. This to prevent memory leaks and code bulging. This does mean that most code is for single threaded use only!)

All code is for reference only and still under construction/untested
headerprep.h - Seems to work
Function: Builds binary (as in non-ascii bytes) bitcoin blockchain header from pool data
poolio.h - functional but still limited & blocking on connect
Function: Handles I/O to pool, saves relevant data in strings.
bm1387freq.ino - fully tested but still contains tons of debug printfs
Function: Sets BM1387 frequency to any possible value between 50-799MHz in user defined resolution

My mining software state:

Right after startup:
056fde77001b92 73972f049e5ab64237757e4ffd5a14721bbdc9f2ba27162c137f0aba9054c8e6 0c3766d0011f80 cdd6788b2a376a01d5fda247fc145c75a757655ec465e935e14019f0024438dc 82fb56f8000785 71ee60300d26bf68e6fe05443fed779ca657065e57f855d7bacc9ae60a7a6d15


Hashrate (target:27.93GHs): 25.42GHs asic#0:12.95GHs asic#1:8.80GHs Job interval (ms): 19 Vcore:0.66 Status: -warming up- -no pool data-

10772075010991 f5f7e1b3aa8373159d1938c8832f2a6e2beffef8b09c5e0b6ff150ec0cc6cf08 0a695dd2010b81 7bb935b29384b03edaca4c0d0458cdb628aca5e4ef6d4b6bffc86a6eabb552db 0c1c6d17010298 61879e7a0160ff774b87d55a7d4cdec6c37fa40d6cfb399f40d13bde516fe130
and after a minute:

a8cff0a100279f 773b72dec5ea5a5592d3bc77a0dbd524559cd1953172866b816fe9a900000000 87fcbcc2002986 ed163ea5416dd25fc3c36e0bdd3a49cb927ffba337754a76b567b38900000000 c70d280400308f 669a634bf0ff9a8499a476ff13a89d6151a268621f2434f0fa54c2a400000000 8bf0d4b700339c 554d340cc905da9ea662d2f6513fffece5373201138eae4fbebb2cab00000000


Hashrate (target:27.93GHs): 26.04GHs asic#0:13.21GHs asic#1:12.13GHs Job interval (ms): 76 Vcore:0.66 Status: -mining- -pool active-

1d99ee22003690 ef21d5a1b1e37eb93660083bd6b52607ccf543217dd7effdf3c73ae000000000 0ac3f4d1003894 711b888e8f47467ba20aca0a6653b2d2afcf832d2500f805a7cde46200000000 3124b686003894 2eb550e8ae7c1712ed268be37e87c644b139f3b1868c163486cdf66000000000 42f91e57023b85 79b77d746237d62b113f744353fa7a345ce65c99d8455cf624e8f7c100000000
During warmup the asics get fed random data, this activates all cores in the asics. The Antminer S9 does something similar during warmup. If I don't use a warmup my hashrate is significantly lower..
The asics run at 120MHz(asic#0) and 125MHz(asic#1), and will in time each reach the target hashrate.
The 1st hex block shows the tickets (nonces) returned by the asics, the second block the final (not yet reversed) hash. During mining stage it ends with at least 8 zeroes, success!!

A somewhat longer piece of logging to show pool I/O
c4447f10003d91 2bf594554a0b15604171755e63e962d5e03a131663db7566ff75bbe800000000 c21893f5003e91 9623918acb9f2d0cc17f672798c86217d2425afb169fd2b7a1fd757b00000000 938c67ee013f87 66ce0506ab2d5ad209bb4c5636c2ebdcf5765620adbe105b5ff1780800000000 Handling incomming pool message Received: {"params":["5eebeafb0018db94","64a29a614daaf2f958fc51644989c904c27da303000324100000000000000000","01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3503d5e00b00049802fc6304cef27d1b0c","0a636b706f6f6c112f736f6c6f2e636b706f6f6c2e6f72672fffffffff034e4f1e25000000001976a914d98deacca0c5d8b5c36f568106d01b30d9a1c95988acb8ecc100000000001976a914f4cbe6c6bb3a8535c963169c22963d3a20e7686988ac0000000000000000266a24aa21a9edf21e5d7b0925893e02a6e6ff6b88e271f285363a53d6b1a325ecca001b9b0e0300000000",["1238fb52849ae3325db6de39c13205294f3499bb181ea0ccf3f4bc54c37b54ab","89bd2d05ca37d543a5f1002c53500359bb9068863104b74fdf22c9991fc36233","c83db6998a892af0a34d0748dc5919c12bba58950a5c50f982811e24e02dadcd","e7da334b8195d1bd4df40616b1b3114fc3ab54767c03e88b2e266a40b98eb371","fd230009c444af2d7a48c9ea14e8f795f9e9909d64713c16be6d57e549154161","78a08227795635e883de47f755b61886e9f4687c83efecd05bd03d00b281d91c","296f533f86bc0e469749a463625a687ac9bf18e3f3169b03051af4c96ebc721e","9fb93c16c4ca66058856aa2aa14d8d6d78fc030ffd7f0a3b7a738cbef98b4883","8b2b3b56ff6979f36dadf106b2f6a22c0cad9e8e3230eaf63ba4be009f87996b","cdc428f313f405bdf445679950abd50ed62ec7f43e825cbae2ada97f2a60597e","e2b14f1ee84bca2adeeb8e7b3b9dee9d541993c285b52888e5a891d2c86aca05","e2a6998cfb8ff5b7fd1c5bda663f4592bcdaaab3880546468d8d983013656f88"],"20000000","170689a3","63fc0298",false],"id":null,"method":"mining.notify"} params [ 5eebeafb0018db94 64a29a614daaf2f958fc51644989c904c27da303000324100000000000000000 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3503d5e00b00049802fc6304cef27d1b0c 0a636b706f6f6c112f736f6c6f2e636b706f6f6c2e6f72672fffffffff034e4f1e25000000001976a914d98deacca0c5d8b5c36f568106d01b30d9a1c95988acb8ecc100000000001976a914f4cbe6c6bb3a8535c963169c22963d3a20e7686988ac0000000000000000266a24aa21a9edf21e5d7b0925893e02a6e6ff6b88e271f285363a53d6b1a325ecca001b9b0e0300000000 [ 1238fb52849ae3325db6de39c13205294f3499bb181ea0ccf3f4bc54c37b54ab 89bd2d05ca37d543a5f1002c53500359bb9068863104b74fdf22c9991fc36233 c83db6998a892af0a34d0748dc5919c12bba58950a5c50f982811e24e02dadcd e7da334b8195d1bd4df40616b1b3114fc3ab54767c03e88b2e266a40b98eb371 fd230009c444af2d7a48c9ea14e8f795f9e9909d64713c16be6d57e549154161 78a08227795635e883de47f755b61886e9f4687c83efecd05bd03d00b281d91c 296f533f86bc0e469749a463625a687ac9bf18e3f3169b03051af4c96ebc721e 9fb93c16c4ca66058856aa2aa14d8d6d78fc030ffd7f0a3b7a738cbef98b4883 8b2b3b56ff6979f36dadf106b2f6a22c0cad9e8e3230eaf63ba4be009f87996b cdc428f313f405bdf445679950abd50ed62ec7f43e825cbae2ada97f2a60597e e2b14f1ee84bca2adeeb8e7b3b9dee9d541993c285b52888e5a891d2c86aca05 e2a6998cfb8ff5b7fd1c5bda663f4592bcdaaab3880546468d8d983013656f88 ] 20000000 170689a3 63fc0298 false ] id null method mining.notify Stringify length 1356 Looking for method Skip: params Skip: [ Skip: 5eebeafb0018db94 Skip: 64a29a614daaf2f958fc51644989c904c27da303000324100000000000000000 Skip: 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3503d5e00b00049802fc6304cef27d1b0c Skip: 0a636b706f6f6c112f736f6c6f2e636b706f6f6c2e6f72672fffffffff034e4f1e25000000001976a914d98deacca0c5d8b5c36f568106d01b30d9a1c95988acb8ecc100000000001976a914f4cbe6c6bb3a8535c963169c22963d3a20e7686988ac0000000000000000266a24aa21a9edf21e5d7b0925893e02a6e6ff6b88e271f285363a53d6b1a325ecca001b9b0e0300000000 Skip: [ Skip: 1238fb52849ae3325db6de39c13205294f3499bb181ea0ccf3f4bc54c37b54ab Skip: 89bd2d05ca37d543a5f1002c53500359bb9068863104b74fdf22c9991fc36233 Skip: c83db6998a892af0a34d0748dc5919c12bba58950a5c50f982811e24e02dadcd Skip: e7da334b8195d1bd4df40616b1b3114fc3ab54767c03e88b2e266a40b98eb371 Skip: fd230009c444af2d7a48c9ea14e8f795f9e9909d64713c16be6d57e549154161 Skip: 78a08227795635e883de47f755b61886e9f4687c83efecd05bd03d00b281d91c Skip: 296f533f86bc0e469749a463625a687ac9bf18e3f3169b03051af4c96ebc721e Skip: 9fb93c16c4ca66058856aa2aa14d8d6d78fc030ffd7f0a3b7a738cbef98b4883 Skip: 8b2b3b56ff6979f36dadf106b2f6a22c0cad9e8e3230eaf63ba4be009f87996b Skip: cdc428f313f405bdf445679950abd50ed62ec7f43e825cbae2ada97f2a60597e Skip: e2b14f1ee84bca2adeeb8e7b3b9dee9d541993c285b52888e5a891d2c86aca05 Skip: e2a6998cfb8ff5b7fd1c5bda663f4592bcdaaab3880546468d8d983013656f88 Skip: ] Skip: 20000000 Skip: 170689a3 Skip: 63fc0298 Skip: false Skip: ] Skip: id Skip: null Method found: mining.notify Handling mining.notify p_Jobid:5eebeafb0018db94 p_prevblockhash:64a29a614daaf2f958fc51644989c904c27da303000324100000000000000000 p_coinb1:01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3503d5e00b00049802fc6304cef27d1b0c p_coinb2:0a636b706f6f6c112f736f6c6f2e636b706f6f6c2e6f72672fffffffff034e4f1e25000000001976a914d98deacca0c5d8b5c36f568106d01b30d9a1c95988acb8ecc100000000001976a914f4cbe6c6bb3a8535c963169c22963d3a20e7686988ac0000000000000000266a24aa21a9edf21e5d7b0925893e02a6e6ff6b88e271f285363a53d6b1a325ecca001b9b0e0300000000 p_partialmerkle:1238fb52849ae3325db6de39c13205294f3499bb181ea0ccf3f4bc54c37b54ab89bd2d05ca37d543a5f1002c53500359bb9068863104b74fdf22c9991fc36233c83db6998a892af0a34d0748dc5919c12bba58950a5c50f982811e24e02dadcde7da334b8195d1bd4df40616b1b3114fc3ab54767c03e88b2e266a40b98eb371fd230009c444af2d7a48c9ea14e8f795f9e9909d64713c16be6d57e54915416178a08227795635e883de47f755b61886e9f4687c83efecd05bd03d00b281d91c296f533f86bc0e469749a463625a687ac9bf18e3f3169b03051af4c96ebc721e9fb93c16c4ca66058856aa2aa14d8d6d78fc030ffd7f0a3b7a738cbef98b48838b2b3b56ff6979f36dadf106b2f6a22c0cad9e8e3230eaf63ba4be009f87996bcdc428f313f405bdf445679950abd50ed62ec7f43e825cbae2ada97f2a60597ee2b14f1ee84bca2adeeb8e7b3b9dee9d541993c285b52888e5a891d2c86aca05e2a6998cfb8ff5b7fd1c5bda663f4592bcdaaab3880546468d8d983013656f88 p_version:20000000 p_nbits:170689a3 p_ntime:63fc0298 p_clean:false 20363792012294 7f9255d5b199889eaea9688d5d447d2fa21f02968ac6d3c46e3c8b3b00000000 45b235f3002496 6d194cda882fcf125bf9d43160d2f72fadb736b9b9970488eee71e6200000000 067e339900258c d6e11e1052fa88f289c855bc3b0fe55ffa85b1172bd44e6bbbaf192000000000 bf500c5f03279b a8f2749196294e4dd3ca7a6149826c19cbcdeafdf06c379f1089f3e300000000 27a79098012994 bd8dd872b1a304f6cb4f52ab2671f8b519868c2438d9eb467ddd710100000000 b6834b94002b8c ec1a60baa65c51ba41ab6b8eba7a77b2d8fcebf8d423d86ed677ab7a00000000 0d08838e002e8c 78b6163e9158d96e8cfa7ca7ba08b334e8974fa1c8d71b7bd5f9b68300000000 0761f821003293 334ca2bd78ea56e8767d2aa5830b3d9e480b69295efda4369677f09900000000 9b765ac802339d 13b6495142da4fa514bd8e8b1f56aee070e2d6872a7b16c9347bed1600000000 1cfd7dea07358c 0a993bac8cec9717d23155ac4b9d5a90f6853cbda67d50b30179cf8600000000 2d49cfe7003580 6290a687b9ef7d9b51227ae0e9631b83a43e7970799c1807bbc5755800000000


Hashrate (target:27.93GHs): 27.79GHs asic#0:13.69GHs asic#1:14.07GHs Job interval (ms): 76 Vcore:0.66 Status: -mining- -pool active-

18993361013d9d 91918d12cef4b33c3293be61b56ffc7a77d2ed36f16a4ef655c51f6c00000000 1f31cb85013d88 4b889fadfe2c8320e840df497773843e628869bd77f857f6762d783d00000000 363fffc6003e84 f9e76f50406df0366a9e65500693f40d49f0147af56997c8885a9cb300000000 390bd305032383 8682c32ecf2e68716aa712578b66ce64f25724588f4a51341e11195b00000000 30c86a2a002592 4a5821027ad68647199d1cd0129748839158762764733ca991cf8b4200000000