Automatic detect the small miners
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
diff --git a/driver-avalon2.c b/driver-avalon2.c
index 189d669..02468b6 100644
--- a/driver-avalon2.c
+++ b/driver-avalon2.c
@@ -238,7 +238,7 @@ static int decode_pkg(struct thr_info *thr, struct avalon2_ret *ar, uint8_t *pkg
miner = be32toh(miner);
pool_no = be32toh(pool_no);
if (miner >= AVA2_DEFAULT_MINERS ||
- modular_id >= AVA2_DEFAULT_MINERS ||
+ modular_id >= AVA2_DEFAULT_MINERS ||
pool_no >= total_pools ||
pool_no < 0) {
applog(LOG_DEBUG, "Avalon2: Wrong miner/pool/id no %d,%d,%d", miner, pool_no, modular_id);
@@ -560,7 +560,7 @@ static bool avalon2_detect_one(const char *devpath)
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
modular[i] = 0;
- strcpy(mm_version[i], "NONE");
+ strcpy(mm_version[i], AVA2_MM_VERNULL);
/* Send out detect pkg */
memset(detect_pkg.data, 0, AVA2_P_DATA_LEN);
tmp = be32toh(i);
@@ -783,23 +783,61 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
int i, a, b;
char buf[24];
double hwp;
+ int devtype[AVA2_DEFAULT_MODULARS];
+ int minerindex = 0;
+
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+ devtype[i] = AVA2_ID_AVAX;
+ if(strncmp((char*)&(info->mm_version[i]), AVA2_FW2_PREFIXSTR, 2) == 0){
+ devtype[i] = AVA2_ID_AVA2;
+ }
+ else if(strncmp((char*)&(info->mm_version[i]), AVA2_FW3_PREFIXSTR, 2) == 0){
+ devtype[i] = AVA2_ID_AVA3;
+ }
+ else if(strncmp((char*)&(info->mm_version[i]), AVA2_MM_VERNULL, 4) == 0){
+ continue;
+ }
+
sprintf(buf, "ID%d MM Version", i + 1);
root = api_add_string(root, buf, &(info->mm_version[i]), false);
}
- for (i = 0; i < AVA2_DEFAULT_MINERS * AVA2_DEFAULT_MODULARS; i++) {
- sprintf(buf, "Match work count%02d", i + 1);
- root = api_add_int(root, buf, &(info->matching_work[i]), false);
+
+ minerindex = 0;
+ for (i = 0; i < AVA2_DEFAULT_MODULARS; i++){
+ if(devtype[i] == AVA2_ID_AVA2){
+ for (i = minerindex; i < (minerindex + AVA2_DEFAULT_MINERS); i++) {
+ sprintf(buf, "Match work count%02d", i+1);
+ root = api_add_int(root, buf, &(info->matching_work[i]), false);
+ }
+ minerindex += AVA2_DEFAULT_MINERS;
+ }else
+ if(devtype[i] == AVA2_ID_AVA3){
+ for (i = minerindex; i < (minerindex + AVA2_AVA3_MINERS); i++) {
+ sprintf(buf, "Match work count%02d", i+1);
+ root = api_add_int(root, buf, &(info->matching_work[i]), false);
+ }
+ minerindex += AVA2_AVA3_MINERS;
+ }
+ else{
+ minerindex += AVA2_DEFAULT_MINERS;
+ }
}
+
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+ if(devtype[i] == AVA2_ID_AVAX)
+ continue;
sprintf(buf, "Local works%d", i + 1);
root = api_add_int(root, buf, &(info->local_works[i]), false);
}
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+ if(devtype[i] == AVA2_ID_AVAX)
+ continue;
sprintf(buf, "Hardware error works%d", i + 1);
root = api_add_int(root, buf, &(info->hw_works[i]), false);
}
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+ if(devtype[i] == AVA2_ID_AVAX)
+ continue;
a = info->hw_works[i];
b = info->local_works[i];
hwp = b ? ((double)a / (double)b) : 0;
@@ -808,27 +846,36 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
root = api_add_percent(root, buf, &hwp, true);
}
for (i = 0; i < 2 * AVA2_DEFAULT_MODULARS; i++) {
+ if(devtype[i/2] == AVA2_ID_AVAX)
+ continue;
sprintf(buf, "Temperature%d", i + 1);
root = api_add_int(root, buf, &(info->temp[i]), false);
}
for (i = 0; i < 2 * AVA2_DEFAULT_MODULARS; i++) {
+ if(devtype[i/2] == AVA2_ID_AVAX)
+ continue;
sprintf(buf, "Fan%d", i + 1);
root = api_add_int(root, buf, &(info->fan[i]), false);
}
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+ if(devtype[i] == AVA2_ID_AVAX)
+ continue;
sprintf(buf, "Voltage%d", i + 1);
root = api_add_int(root, buf, &(info->get_voltage[i]), false);
}
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+ if(devtype[i] == AVA2_ID_AVAX)
+ continue;
sprintf(buf, "Frequency%d", i + 1);
root = api_add_int(root, buf, &(info->get_frequency[i]), false);
}
for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+ if(devtype[i] == AVA2_ID_AVAX)
+ continue;
sprintf(buf, "Power good %02x", i + 1);
- root = api_add_int(root, buf, &(info->power_good[i]), false);
+ root = api_add_int(root, buf, &(info->power_good[i]), false);
}
-
return root;
}
diff --git a/driver-avalon2.h b/driver-avalon2.h
index c641dbc..ee0f74c 100644
--- a/driver-avalon2.h
+++ b/driver-avalon2.h
@@ -22,6 +22,7 @@
#define AVA2_IO_SPEED 115200
#define AVA2_DEFAULT_MINERS 10
+#define AVA2_AVA3_MINERS 5
#define AVA2_DEFAULT_MODULARS 4
#define AVA2_PWM_MAX 0x3FF
@@ -69,6 +70,16 @@
#define AVA2_P_TEST_RET 26
/* Avalon2 protocol package type */
+/* Avalon2/3 prefix */
+#define AVA2_FW2_PREFIXSTR "20"
+#define AVA2_FW3_PREFIXSTR "33"
+
+#define AVA2_MM_VERNULL "NONE"
+
+#define AVA2_ID_AVA2 (0x3255)
+#define AVA2_ID_AVA3 (0x3233)
+#define AVA2_ID_AVAX (0x3200)
+
struct avalon2_pkg {
uint8_t head[2];
uint8_t type;