|
|
@ -25,13 +25,12 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <unistd.h> |
|
|
|
#include <unistd.h> |
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include <config.h> |
|
|
|
|
|
|
|
|
|
|
|
#include "miner.h" |
|
|
|
#include "miner.h" |
|
|
|
#include "fpgautils.h" |
|
|
|
#include "fpgautils.h" |
|
|
|
#include "libztex.h" |
|
|
|
#include "libztex.h" |
|
|
|
|
|
|
|
|
|
|
|
#define BUFSIZE 256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//* Capability index for EEPROM support.
|
|
|
|
//* Capability index for EEPROM support.
|
|
|
|
#define CAPABILITY_EEPROM 0,0 |
|
|
|
#define CAPABILITY_EEPROM 0,0 |
|
|
|
//* Capability index for FPGA configuration support.
|
|
|
|
//* Capability index for FPGA configuration support.
|
|
|
@ -103,9 +102,10 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev) |
|
|
|
FILE *fp = NULL; |
|
|
|
FILE *fp = NULL; |
|
|
|
libusb_device_handle *hndl = NULL; |
|
|
|
libusb_device_handle *hndl = NULL; |
|
|
|
struct libusb_device_descriptor desc; |
|
|
|
struct libusb_device_descriptor desc; |
|
|
|
int i, ret = CHECK_ERROR, err, cnt; |
|
|
|
int ret = CHECK_ERROR, err, cnt; |
|
|
|
size_t got_bytes, length; |
|
|
|
size_t got_bytes, length; |
|
|
|
unsigned char buf[64], *fw_buf; |
|
|
|
unsigned char buf[64], *fw_buf; |
|
|
|
|
|
|
|
unsigned int i; |
|
|
|
|
|
|
|
|
|
|
|
err = libusb_get_device_descriptor(dev, &desc); |
|
|
|
err = libusb_get_device_descriptor(dev, &desc); |
|
|
|
if (unlikely(err != 0)) { |
|
|
|
if (unlikely(err != 0)) { |
|
|
@ -292,7 +292,7 @@ static bool libztex_checkCapability(struct libztex_device *ztex, int i, int j) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int libztex_detectBitstreamBitOrder(const unsigned char *buf, int size) |
|
|
|
static char libztex_detectBitstreamBitOrder(const unsigned char *buf, int size) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
@ -407,7 +407,6 @@ static int libztex_configureFpgaHS(struct libztex_device *ztex, const char* firm |
|
|
|
applog(LOG_ERR, "%s: HS FPGA configuration failed: DONE pin does not go high", ztex->repr); |
|
|
|
applog(LOG_ERR, "%s: HS FPGA configuration failed: DONE pin does not go high", ztex->repr); |
|
|
|
return -3; |
|
|
|
return -3; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
libusb_release_interface(ztex->hndl, settings[1]); |
|
|
|
libusb_release_interface(ztex->hndl, settings[1]); |
|
|
@ -415,7 +414,6 @@ static int libztex_configureFpgaHS(struct libztex_device *ztex, const char* firm |
|
|
|
nmsleep(200); |
|
|
|
nmsleep(200); |
|
|
|
applog(LOG_INFO, "%s: HS FPGA configuration done", ztex->repr); |
|
|
|
applog(LOG_INFO, "%s: HS FPGA configuration done", ztex->repr); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int libztex_configureFpgaLS(struct libztex_device *ztex, const char* firmware, bool force, char bs) |
|
|
|
static int libztex_configureFpgaLS(struct libztex_device *ztex, const char* firmware, bool force, char bs) |
|
|
@ -520,7 +518,7 @@ int libztex_numberOfFpgas(struct libztex_device *ztex) { |
|
|
|
|
|
|
|
|
|
|
|
int libztex_selectFpga(struct libztex_device *ztex) { |
|
|
|
int libztex_selectFpga(struct libztex_device *ztex) { |
|
|
|
int cnt, fpgacnt = libztex_numberOfFpgas(ztex->root); |
|
|
|
int cnt, fpgacnt = libztex_numberOfFpgas(ztex->root); |
|
|
|
int number = ztex->fpgaNum; |
|
|
|
uint16_t number = ztex->fpgaNum; |
|
|
|
if (number < 0 || number >= fpgacnt) { |
|
|
|
if (number < 0 || number >= fpgacnt) { |
|
|
|
applog(LOG_WARNING, "%s: Trying to select wrong fpga (%d in %d)", ztex->repr, number, fpgacnt); |
|
|
|
applog(LOG_WARNING, "%s: Trying to select wrong fpga (%d in %d)", ztex->repr, number, fpgacnt); |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
@ -631,7 +629,6 @@ int libztex_prepare_device(struct libusb_device *dev, struct libztex_device** zt |
|
|
|
newdev->moduleReserved[10] = buf[28]; |
|
|
|
newdev->moduleReserved[10] = buf[28]; |
|
|
|
newdev->moduleReserved[11] = buf[29]; |
|
|
|
newdev->moduleReserved[11] = buf[29]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cnt = libusb_control_transfer(newdev->hndl, 0xc0, 0x82, 0, 0, buf, 64, 500); |
|
|
|
cnt = libusb_control_transfer(newdev->hndl, 0xc0, 0x82, 0, 0, buf, 64, 500); |
|
|
|
if (unlikely(cnt < 0)) { |
|
|
|
if (unlikely(cnt < 0)) { |
|
|
|
applog(LOG_ERR, "Ztex check device: Failed to read ztex descriptor with err %d", cnt); |
|
|
|
applog(LOG_ERR, "Ztex check device: Failed to read ztex descriptor with err %d", cnt); |
|
|
@ -810,7 +807,7 @@ done: |
|
|
|
|
|
|
|
|
|
|
|
int libztex_sendHashData(struct libztex_device *ztex, unsigned char *sendbuf) |
|
|
|
int libztex_sendHashData(struct libztex_device *ztex, unsigned char *sendbuf) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int cnt, ret, len; |
|
|
|
int cnt = 0, ret, len; |
|
|
|
|
|
|
|
|
|
|
|
if (ztex == NULL || ztex->hndl == NULL) |
|
|
|
if (ztex == NULL || ztex->hndl == NULL) |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|