Browse Source

libztex: Match mining firmware ZTEX descriptor against the dummy firmware

The first 8 bytes are matched, which ensures that the mining firmware
actually fits the hardware, assuming that the correct dummy firmware
is present in the device.
Denis Ahrens 13 years ago
parent
commit
843e9120b3
1 changed files with 9 additions and 0 deletions
  1. 9 0
      libztex.c

+ 9 - 0
libztex.c

@@ -152,6 +152,15 @@ static enum check_result libztex_checkDevice(struct libusb_device *dev)
 		goto done;
 		goto done;
 	}
 	}
 
 
+	// in buf[] is still the identifier of the dummy firmware
+	// use it to compare it with the new firmware
+	char *rv = memmem(fw_buf, got_bytes, buf, 8);
+	if (rv == NULL)
+	{
+		applog(LOG_ERR, "%s: found firmware is not ZTEX", __func__);
+		goto done;
+	}
+
 	// reset 1
 	// reset 1
 	buf[0] = 1;
 	buf[0] = 1;
 	cnt = libusb_control_transfer(hndl, 0x40, 0xA0, 0xE600, 0, buf, 1,1000);
 	cnt = libusb_control_transfer(hndl, 0x40, 0xA0, 0xE600, 0, buf, 1,1000);