libztex: Add firmware download support for ZTEX 1.15d and 1.15x The correct firmware file is automatically determined based on the ZTEX descriptor in the dummy 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
diff --git a/libztex.c b/libztex.c
index 9ae421e..ae39829 100644
--- a/libztex.c
+++ b/libztex.c
@@ -1,5 +1,5 @@
/**
- * libztex.c - Ztex 1.15x fpga board support library
+ * libztex.c - Ztex 1.15x/1.15y fpga board support library
*
* Copyright (c) 2012 nelisky.btc@gmail.com
* Copyright (c) 2012 Denis Ahrens <denis@h3q.com>
@@ -105,7 +105,6 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev)
int i, ret = CHECK_ERROR, err, cnt;
size_t got_bytes, length;
unsigned char buf[64], *fw_buf;
- char *firmware = "ztex_ufm1_15y1.bin";
err = libusb_get_device_descriptor(dev, &desc);
if (unlikely(err != 0)) {
@@ -145,9 +144,8 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev)
switch(buf[7])
{
case 13:
- applog(LOG_ERR, "Found ztex board 1.15d or 1.15x but currently unsupported!");
- ret = CHECK_IS_NOT_ZTEX;
- goto done;
+ applog(LOG_ERR, "Found ztex board 1.15d or 1.15x");
+ break;
case 15:
applog(LOG_ERR, "Found ztex board 1.15y");
break;
@@ -163,7 +161,41 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev)
goto done;
}
- applog(LOG_ERR, "Found dummy firmware, trying to send mining firmware: %s", firmware);
+ applog(LOG_ERR, "Found dummy firmware, trying to send mining firmware");
+
+ char productString[32];
+
+ cnt = libztex_get_string_descriptor_ascii(hndl, desc.iProduct, productString, sizeof(productString));
+ if (unlikely(cnt < 0)) {
+ applog(LOG_ERR, "Ztex check device: Failed to read device productString with err %d", cnt);
+ return cnt;
+ }
+
+ applog(LOG_ERR, "productString: %s", productString);
+
+ unsigned char productID2 = buf[7];
+ char *firmware = NULL;
+
+ if (strcmp("USB-FPGA Module 1.15d (default)", productString) == 0 && productID2 == 13)
+ {
+ firmware = "ztex_ufm1_15d4.bin";
+ }
+ else if (strcmp("USB-FPGA Module 1.15x (default)", productString) == 0 && productID2 == 13)
+ {
+ firmware = "ztex_ufm1_15d4.bin";
+ }
+ else if (strcmp("USB-FPGA Module 1.15y (default)", productString) == 0 && productID2 == 15)
+ {
+ firmware = "ztex_ufm1_15y1.bin";
+ }
+
+ if (firmware == NULL)
+ {
+ applog(LOG_ERR, "could not figure out which firmware to use");
+ goto done;
+ }
+
+ applog(LOG_ERR, "Mining firmware filename: %s", firmware);
fp = open_bitstream("ztex", firmware);
if (!fp) {