bitmain-board-test.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * Copyright 2016-2017 Fazio Bai <yang.bai@bitmain.com>
  3. * Copyright 2016-2017 Clement Duan <kai.duan@bitmain.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the Free
  7. * Software Foundation; either version 3 of the License, or (at your option)
  8. * any later version. See COPYING for more details.
  9. */
  10. #ifndef __BITMAIN_BOARD_TEST_H__
  11. #define __BITMAIN_BOARD_TEST_H__
  12. #include <stdbool.h>
  13. #define MAX_ASIC_NUM 128
  14. #define MAX_WORK 5000
  15. #define FIL 0x1
  16. #define VIL 0x0
  17. struct configuration
  18. {
  19. bool AutoStart;
  20. bool Gray;
  21. int NonceMask; //???
  22. int DataCount;
  23. int PassCount1;
  24. int PassCount2;
  25. int PassCount3;
  26. int Freq;
  27. int Timeout;
  28. bool Regulate;
  29. int Value;
  30. int ReadIntervalTimeout;
  31. int AddrInterval;
  32. int CoreNum;
  33. int AsicNum;
  34. int UseFreqPIC;
  35. int TestMode;
  36. int CheckChain;
  37. int CommandMode;
  38. int AsicType;
  39. int ValidNonce1;
  40. int ValidNonce2;
  41. int ValidNonce3;
  42. unsigned int Pic;
  43. unsigned int Voltage1;
  44. unsigned int Voltage2;
  45. unsigned int Voltage3;
  46. unsigned int final_voltage1;
  47. unsigned int final_voltage2;
  48. unsigned int final_voltage3;
  49. unsigned int freq_gap;
  50. int OpenCoreGap;
  51. int checktemp;
  52. unsigned int IICPic;
  53. unsigned int OpenCoreNum1;
  54. unsigned int OpenCoreNum2;
  55. unsigned int OpenCoreNum3;
  56. unsigned int OpenCoreNum4;
  57. unsigned int dac;
  58. unsigned int GetTempFrom;
  59. unsigned int TempSel;
  60. unsigned int TempSensor1;
  61. unsigned int TempSensor2;
  62. unsigned int TempSensor3;
  63. unsigned int TempSensor4;
  64. signed char DefaultTempOffset;
  65. int freq_e;
  66. int freq_m;
  67. int freq_a;
  68. int freq_t;
  69. int force_freq;
  70. int UseConfigVol;
  71. int StartSensor;
  72. int StartTemp;
  73. int year;
  74. int month;
  75. int date;
  76. int hour;
  77. int minute;
  78. int second;
  79. };
  80. struct _CONFIG
  81. {
  82. int dataCount;
  83. int passCount1;
  84. int passCount2;
  85. int passCount3;
  86. int core;
  87. int freq;
  88. int timeout;
  89. int baud;
  90. bool regulate;
  91. int value;
  92. int addrInterval;
  93. int asicNum;
  94. int testMode;
  95. int CommandMode;
  96. int AsicType;
  97. int ValidNonce1;
  98. int ValidNonce2;
  99. int ValidNonce3;
  100. unsigned int Pic;
  101. unsigned int Voltage1;
  102. unsigned int Voltage2;
  103. unsigned int Voltage3;
  104. int OpenCoreGap;
  105. int checktemp;
  106. unsigned int IICPic;
  107. int UseFreqPIC;
  108. unsigned int freq_gap;
  109. unsigned int OpenCoreNum1;
  110. unsigned int OpenCoreNum2;
  111. unsigned int OpenCoreNum3;
  112. unsigned int OpenCoreNum4;
  113. unsigned int dac;
  114. unsigned int GetTempFrom;
  115. unsigned int TempSel;
  116. unsigned char TempSensor1;
  117. unsigned char TempSensor2;
  118. unsigned char TempSensor3;
  119. unsigned char TempSensor4;
  120. signed char DefaultTempOffset;
  121. int freq_e;
  122. int freq_m;
  123. int freq_a;
  124. int freq_t;
  125. int force_freq;
  126. int UseConfigVol;
  127. unsigned char StartSensor;
  128. signed char StartTemp;
  129. int year;
  130. int month;
  131. int date;
  132. int hour;
  133. int minute;
  134. int second;
  135. };
  136. struct testpatten_work
  137. {
  138. int id;
  139. uint32_t nonce; /* For devices that hash sole work */
  140. unsigned char data[12];
  141. unsigned char midstate[32];
  142. };
  143. struct testpatten_cgpu_info
  144. {
  145. FILE * fps[MAX_ASIC_NUM];
  146. pthread_t receive_id, show_id, pic_heart_beat_id, read_temp,freq_id;
  147. pthread_t send_id[BITMAIN_MAX_CHAIN_NUM];
  148. int device_fd;
  149. int lcd_fd;
  150. char workdataPathPrefix[64];
  151. struct testpatten_work *works[MAX_ASIC_NUM];
  152. //int work_array[MAX_ASIC_NUM]; //work number of every asic
  153. uint32_t results[MAX_ASIC_NUM][MAX_WORK];
  154. int result_array[MAX_ASIC_NUM]; //return nonce number of every asic
  155. int subid[MAX_ASIC_NUM];
  156. int min_work_subid;
  157. int index;
  158. int valid_nonce;
  159. int err_nonce;
  160. int repeated_nonce;
  161. int start_key_fd;
  162. int red_led_fd;
  163. int green_led_fd;
  164. int beep_fd;
  165. unsigned int real_asic_num;
  166. unsigned int asicNum;
  167. unsigned int core_num;
  168. int freq_e;
  169. int freq_m;
  170. int freq_a;
  171. int freq_t;
  172. int AsicType;
  173. unsigned int chain_num;
  174. unsigned short int frequency;
  175. unsigned int CommandMode; // 1:fil 0:vil
  176. unsigned int chain_exist[BITMAIN_MAX_CHAIN_NUM];
  177. unsigned int timeout;
  178. unsigned char chain_asic_num[BITMAIN_MAX_CHAIN_NUM];
  179. unsigned int addrInterval;
  180. unsigned char baud;
  181. unsigned short int freq[BITMAIN_MAX_CHAIN_NUM];
  182. unsigned int max_asic_num_in_one_chain;
  183. unsigned char temp_sel;
  184. unsigned char rfs;
  185. unsigned char tfs;
  186. signed char T1_offset_value;
  187. signed char T2_offset_value;
  188. signed char T3_offset_value;
  189. signed char T4_offset_value;
  190. };
  191. #define PRE_HEAT_TEST_COUNT 2
  192. #undef CHECK_ALLNONCE_ADD_VOLTAGE_USERMODE //if defined, when in user mode (restartNum>0), then check nonce num in test patten, if failed, add 0.1V voltage , must according to hashrate
  193. #define RETRY_FREQ_INDEX 12 // 400M, if search base freq < 400M, will switch to use RETRY_VOLTAGE to search again.
  194. #define REBOOT_TEST_NUM 2 // save into file
  195. #define ENABLE_SEARCH_LOGFILE //enable log info into kernel info web page.
  196. #define LOG_CHIPS_CORE_DETAIL // if enabled , will show details nonce number info for chips and cores, open for debug
  197. #define TEST_MODE_OK_NUM 2 // if 8xPatten test mode test OK counter >= TEST_MODE_OK_NUM, then this board is OK, 3
  198. #define SEARCH_FREQ_CHANCE_NUM 2 // give each board 2 chances to search freq, the first failed, we can add voltage SEARCH_VOLTAGE_ADD_STEP to search for next chance
  199. #define SEARCH_VOLTAGE_ADD_STEP 30 // means, each chance will add 0.3V to search freq again.
  200. #define SEARCH_BASEFREQ_PATTEN_NUM 912
  201. #define SEARCH_BASEFREQ_NONCE_NUM (SEARCH_BASEFREQ_PATTEN_NUM*CHAIN_ASIC_NUM)
  202. #define SEARCH_FREQ_PATTEN_NUM 114
  203. #define SEARCH_FREQ_NONCE_NUM (SEARCH_FREQ_PATTEN_NUM*CHAIN_ASIC_NUM)
  204. #define TESTMODE_PATTEN_NUM 912
  205. #define TESTMODE_NONCE_NUM (TESTMODE_PATTEN_NUM*CHAIN_ASIC_NUM)
  206. #define DEFAULT_TEMP_OFFSET -70
  207. #define FOR_LOOP_CHAIN for(i=0; i<BITMAIN_MAX_CHAIN_NUM; i++)
  208. #define LOWEST_FREQ_INDEX 4 // 8:300M 6:250M 4:200M
  209. #define HIGHEST_FREQ_INDEX 100 // 850M:100 700M:82 668M:77
  210. #define SEND_WAIT_TIMEOUT 120 // unit is 100ms
  211. #define RECV_WAIT_TIMEOUT 20 // unit is 100ms
  212. #define NOBOARD_RETRY_COUNT 3
  213. #ifdef ALLOW_KPERCENT_8xPATTEN
  214. static void fix_result_byPercent(int chainIndex);
  215. #endif
  216. static int calculate_core_number(unsigned int actual_core_number);
  217. #endif