1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-23 04:54:26 +00:00

libztex: Start download sequence only after reading in the new firmware

The download sequence starts with a reset command, which tells the board
that a new firmware is about to be downloaded. The board gets unhappy if
no new firmware is actually sent, so only send the reset command AFTER
the new firmware has actually been successfully read.
This commit is contained in:
Denis Ahrens 2012-12-01 03:29:58 +01:00
parent 584dc5acd5
commit 8d7ad82806

View File

@ -124,15 +124,6 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev)
applog(LOG_ERR, "Found dummy firmware, trying to send mining firmware: %s", firmware);
// reset 1
buf[0] = 1;
cnt = libusb_control_transfer(hndl, 0x40, 0xA0, 0xE600, 0, buf, 1,1000);
if (cnt < 0)
{
applog(LOG_ERR, "Ztex reset 1 failed: %s", libusb_error_name(cnt));
goto done;
}
fp = open_bitstream("ztex", firmware);
if (!fp) {
applog(LOG_ERR, "failed to open firmware file '%s'", firmware);
@ -161,6 +152,15 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev)
goto done;
}
// reset 1
buf[0] = 1;
cnt = libusb_control_transfer(hndl, 0x40, 0xA0, 0xE600, 0, buf, 1,1000);
if (cnt < 0)
{
applog(LOG_ERR, "Ztex reset 1 failed: %s", libusb_error_name(cnt));
goto done;
}
for (i = 0; i < length; i+= 256) {
// firmware wants data in small chunks like 256 bytes
int numbytes = (length - i) < 256 ? (length - i) : 256;