/ driver-blockerupter.h
driver-blockerupter.h
1 #ifndef _BLOCKERUPTER_H 2 #define _BLOCKERUPTER_H 3 4 /* 5 WIN32 Build 6 7 1. Install mxe (check tutorial on http://mxe.cc) 8 9 2. After install mxe 10 export PATH={PATH_TO_MXE}/usr/bin:$PATH 11 autoreconf -fi 12 ./configure --host=i686-pc-mingw32 --enable-blockerupter --without-curses CFLAGS=-DCURL_STATICLIB 13 make 14 15 3. Before starting cgminer 16 install WinUSB driver for detected CP2102x device with Zadig (Some users might need to reboot) 17 */ 18 19 #include "miner.h" 20 #include "util.h" 21 22 #define BET_MAXBOARDS 32 23 #define BET_MAXASICS 48 24 #define BET_BAUD 460800 25 26 #define BET_CLOCK_MAX 29 27 #define BET_CLOCK_DEFAULT 23 28 #define BET_DIFF_DEFAULT 64 29 #define BET_ROLLING_DEFAULT 5 30 extern int opt_bet_clk; 31 32 #define BET_WORK_FIFO 128 33 #define BET_NONCE_FIX 4 34 35 #define SEND_OK 0 36 #define SEND_FAIL 1 37 #define READ_OK 0 38 #define READ_FAIL 1 39 40 // Global Commands 41 // resets all mega88, recv nothing 42 #define C_RES (0 << 5) 43 // stop jobs on all boards, set nTime rolling to (BoardID+1)*30, recv nothing 44 #define C_LPO (1 << 5) 45 // set clock for all boards, clock = (BoardID+1)*5, recv nothing 46 #define C_GCK (2 << 5) 47 // set difficulty bits for all boards with last 2bits from BoardID, recv nothing 48 #define C_DIF (3 << 5) 49 50 // Board Specific Commands (CMD|BoardID) 51 // Send midstate(32 bytes), remaining block header(12 bytes), extranonce2(4 bytes) and job index(1 byte) to board 52 // Recv 0x58 53 #define C_JOB (4 << 5) 54 // Recv current status of board 55 #define C_ASK (5 << 5) 56 // Recv (max_asics) bytes of chip test result, (max asics) bytes of clocks, 1 byte of diff bits, 1 byte of max nTime rolling, 1 byte of firmware version. Total (max asics)*2+3 bytes 57 #define C_TRS (6 << 5) 58 59 // answers on C_ASK|BoardID 60 // Idle, waiting for new job 61 #define A_WAL 0x56 62 // Mining but no nonce yet 63 #define A_NO 0xa6 64 // Found nonce, followed with midstate(32 bytes), remaining block header(12 bytes), extranonce2(4 bytes), nonce(4 bytes), job index(1 byte), chip index(1 byte). Total 54 bytes. 65 #define A_YES 0x5A 66 67 // answer on C_JOB|BoardID 68 #define A_GET 0x58 69 70 #pragma pack(1) 71 72 typedef struct asic_info { 73 int bad; 74 int accepted; 75 int nonces; 76 int hashes; 77 double hwe; 78 } asic_info; 79 80 #pragma pack(1) 81 82 typedef struct board_info { 83 int bad; 84 int job_count; 85 int nonces; 86 int accepted; 87 int hashes; 88 double hashrate; 89 double hwe; 90 struct asic_info asics[BET_MAXASICS]; 91 } board_info; 92 93 #pragma pack(1) 94 95 typedef struct blockerupter_info { 96 struct pool pool; 97 uint8_t found; 98 int clock; 99 int nonces; 100 int diff; 101 int rolling; 102 int accepted; 103 int hashes; 104 double hashrate; 105 double expected; 106 double eff; 107 uint8_t work_idx; 108 struct work works[BET_WORK_FIFO]; 109 uint8_t boards[BET_MAXBOARDS]; 110 board_info b_info[BET_MAXBOARDS]; 111 struct timeval start_time; 112 struct timeval last_job; 113 } blockerupter_info; 114 115 116 #pragma pack(1) 117 118 typedef struct blockerupter_response { 119 uint8_t midstate[32]; 120 uint8_t merkle[4]; 121 uint8_t ntime[4]; 122 uint8_t diff[4]; 123 uint8_t exnonc2[4]; 124 uint8_t nonce[4]; 125 uint8_t work_idx; 126 uint8_t chip; 127 } blockerupter_response; 128 #define BET_RESP_SZ (sizeof(blockerupter_response)) 129 130 #endif