Browse Source

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.
nfactor-troky
Denis Ahrens 12 years ago
parent
commit
8d7ad82806
  1. 18
      libztex.c

18
libztex.c

@ -124,15 +124,6 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev) @@ -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) @@ -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;

Loading…
Cancel
Save