BTB get version from Firmware
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
diff --git a/driver-avalon.c b/driver-avalon.c
index 6d5276a..94b0eb2 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -660,6 +660,31 @@ static int bitburner_get_core_voltage(struct cgpu_info *avalon)
}
}
+static void bitburner_get_version(struct cgpu_info *avalon)
+{
+ struct avalon_info *info = avalon->device_data;
+ uint8_t buf[3];
+ int err;
+ int amount;
+
+ err = usb_transfer_read(avalon, FTDI_TYPE_IN, BITBURNER_REQUEST,
+ BITBURNER_VALUE, BITBURNER_INDEX_GET_VERSION,
+ (char *)buf, sizeof(buf), &amount,
+ C_GETVERSION);
+ if (unlikely(err != 0 || amount != sizeof(buf))) {
+ applog(LOG_DEBUG, "%s%i: GetVersion failed: err=%d, amt=%d assuming %d.%d.%d",
+ avalon->drv->name, avalon->device_id, err, amount,
+ BITBURNER_VERSION1, BITBURNER_VERSION2, BITBURNER_VERSION3);
+ info->version1 = BITBURNER_VERSION1;
+ info->version2 = BITBURNER_VERSION2;
+ info->version3 = BITBURNER_VERSION3;
+ } else {
+ info->version1 = buf[0];
+ info->version2 = buf[1];
+ info->version3 = buf[2];
+ }
+}
+
static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found)
{
int baud, miner_count, asic_count, timeout, frequency;
@@ -746,6 +771,8 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
BITBURNER_MAX_COREMV);
} else
bitburner_set_core_voltage(avalon, opt_bitburner_core_voltage);
+
+ bitburner_get_version(avalon);
}
return true;
@@ -1454,6 +1481,7 @@ static struct api_data *avalon_api_stats(struct cgpu_info *cgpu)
{
struct api_data *root = NULL;
struct avalon_info *info = cgpu->device_data;
+ char buf[64];
int i;
root = api_add_int(root, "baud", &(info->baud), false);
@@ -1481,6 +1509,10 @@ static struct api_data *avalon_api_stats(struct cgpu_info *cgpu)
root = api_add_int(root, mcw, &(info->matching_work[i]), false);
}
+ snprintf(buf, sizeof(buf), "%"PRIu8".%"PRIu8".%"PRIu8,
+ info->version1, info->version2, info->version3);
+ root = api_add_string(root, "version", buf, true);
+
return root;
}
diff --git a/driver-avalon.h b/driver-avalon.h
index e8f07c7..6f8f2e1 100644
--- a/driver-avalon.h
+++ b/driver-avalon.h
@@ -142,8 +142,16 @@ struct avalon_info {
bool reset;
bool overheat;
bool optimal;
+
+ uint8_t version1;
+ uint8_t version2;
+ uint8_t version3;
};
+#define BITBURNER_VERSION1 1
+#define BITBURNER_VERSION2 0
+#define BITBURNER_VERSION3 0
+
#define AVALON_WRITE_SIZE (sizeof(struct avalon_task))
#define AVALON_READ_SIZE (sizeof(struct avalon_result))
#define AVALON_ARRAY_SIZE 3
diff --git a/usbutils.h b/usbutils.h
index b14709c..287ef04 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -53,6 +53,7 @@
#define BITBURNER_VALUE 0x4242
#define BITBURNER_INDEX_SET_VOLTAGE 1
#define BITBURNER_INDEX_GET_VOLTAGE 2
+#define BITBURNER_INDEX_GET_VERSION 4
// CMR = 115200 & 57600
#define FTDI_VALUE_BAUD_CMR_115 0xc068