|
|
|
@ -51,7 +51,7 @@ modminer_detect_one(const char *devpath)
@@ -51,7 +51,7 @@ modminer_detect_one(const char *devpath)
|
|
|
|
|
size_t len; |
|
|
|
|
|
|
|
|
|
// Sending 45 noops, just in case the device was left in "start job" reading
|
|
|
|
|
write(fd, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 45) ?:0; |
|
|
|
|
(void)(write(fd, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 45) ?:0); |
|
|
|
|
while (serial_read(fd, buf, sizeof(buf)) > 0) |
|
|
|
|
; |
|
|
|
|
|
|
|
|
@ -142,9 +142,9 @@ get_modminer_statline_before(char *buf, struct cgpu_info *modminer)
@@ -142,9 +142,9 @@ get_modminer_statline_before(char *buf, struct cgpu_info *modminer)
|
|
|
|
|
FD_SET(fd, &fds); \ |
|
|
|
|
select(fd+1, &fds, NULL, NULL, NULL); \ |
|
|
|
|
if (1 != read(fd, buf, 1)) \ |
|
|
|
|
bailout2(LOG_ERR, "Error programming ModMiner %s (" eng ")", modminer->device_path); \ |
|
|
|
|
bailout2(LOG_ERR, "%s %u: Error programming %s (" eng ")", modminer->api->name, modminer->device_id, modminer->device_path); \ |
|
|
|
|
if (buf[0] != 1) \ |
|
|
|
|
bailout2(LOG_ERR, "Wrong " eng " programming ModMiner %s", modminer->device_path); \ |
|
|
|
|
bailout2(LOG_ERR, "%s %u: Wrong " eng " programming %s", modminer->api->name, modminer->device_id, modminer->device_path); \ |
|
|
|
|
} while(0) |
|
|
|
|
|
|
|
|
|
static bool |
|
|
|
@ -198,7 +198,7 @@ fd_set fds;
@@ -198,7 +198,7 @@ fd_set fds;
|
|
|
|
|
|
|
|
|
|
int fd = modminer->device_fd; |
|
|
|
|
|
|
|
|
|
applog(LOG_WARNING, "Programming %s... DO NOT EXIT CGMINER UNTIL COMPLETE", modminer->device_path, fpgaid); |
|
|
|
|
applog(LOG_WARNING, "%s %u: Programming %s... DO NOT EXIT CGMINER UNTIL COMPLETE", modminer->api->name, modminer->device_id, modminer->device_path); |
|
|
|
|
buf[0] = '\x05'; // Program Bitstream
|
|
|
|
|
buf[1] = fpgaid; |
|
|
|
|
buf[2] = (len >> 0) & 0xff; |
|
|
|
@ -206,20 +206,20 @@ fd_set fds;
@@ -206,20 +206,20 @@ fd_set fds;
|
|
|
|
|
buf[4] = (len >> 16) & 0xff; |
|
|
|
|
buf[5] = (len >> 24) & 0xff; |
|
|
|
|
if (6 != write(fd, buf, 6)) |
|
|
|
|
bailout2(LOG_ERR, "Error programming ModMiner %s (cmd)", modminer->device_path); |
|
|
|
|
bailout2(LOG_ERR, "%s %u: Error programming %s (cmd)", modminer->api->name, modminer->device_id, modminer->device_path); |
|
|
|
|
status_read("cmd reply"); |
|
|
|
|
size_t buflen; |
|
|
|
|
while (len) { |
|
|
|
|
buflen = len < 32 ? len : 32; |
|
|
|
|
if (fread(buf, buflen, 1, f) != 1) |
|
|
|
|
bailout2(LOG_ERR, "File underrun programming ModMiner %s (%d bytes left)", modminer->device_path, len); |
|
|
|
|
bailout2(LOG_ERR, "%s %u: File underrun programming %s (%d bytes left)", modminer->api->name, modminer->device_id, modminer->device_path, len); |
|
|
|
|
if (write(fd, buf, buflen) != buflen) |
|
|
|
|
bailout2(LOG_ERR, "Error programming ModMiner %s (data)"); |
|
|
|
|
bailout2(LOG_ERR, "%s %u: Error programming %s (data)", modminer->api->name, modminer->device_id, modminer->device_path); |
|
|
|
|
status_read("status"); |
|
|
|
|
len -= buflen; |
|
|
|
|
} |
|
|
|
|
status_read("final status"); |
|
|
|
|
applog(LOG_WARNING, "Done programming %s", modminer->device_path); |
|
|
|
|
applog(LOG_WARNING, "%s %u: Done programming %s", modminer->api->name, modminer->device_id, modminer->device_path); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -229,10 +229,10 @@ modminer_device_prepare(struct cgpu_info *modminer)
@@ -229,10 +229,10 @@ modminer_device_prepare(struct cgpu_info *modminer)
|
|
|
|
|
{ |
|
|
|
|
int fd = serial_open(modminer->device_path, 0, /*FIXME=-1*/3000, true); |
|
|
|
|
if (unlikely(-1 == fd)) |
|
|
|
|
bailout(LOG_ERR, "Failed to open ModMiner on %s", modminer->device_path); |
|
|
|
|
bailout(LOG_ERR, "%s %u: Failed to open %s", modminer->api->name, modminer->device_id, modminer->device_path); |
|
|
|
|
|
|
|
|
|
modminer->device_fd = fd; |
|
|
|
|
applog(LOG_INFO, "Opened ModMiner on %s", modminer->device_path); |
|
|
|
|
applog(LOG_INFO, "%s %u: Opened %s", modminer->api->name, modminer->device_id, modminer->device_path); |
|
|
|
|
|
|
|
|
|
struct timeval now; |
|
|
|
|
gettimeofday(&now, NULL); |
|
|
|
@ -294,13 +294,13 @@ modminer_reduce_clock(struct thr_info*thr, bool needlock)
@@ -294,13 +294,13 @@ modminer_reduce_clock(struct thr_info*thr, bool needlock)
|
|
|
|
|
if (needlock) |
|
|
|
|
mutex_lock(&modminer->device_mutex); |
|
|
|
|
if (6 != write(fd, cmd, 6)) |
|
|
|
|
bailout2(LOG_ERR, "Error writing to ModMiner (set clock speed)"); |
|
|
|
|
bailout2(LOG_ERR, "%s %u.%u: Error writing (set clock speed)", modminer->api->name, modminer->device_id, fpgaid); |
|
|
|
|
if (serial_read(fd, &buf, 1) != 1) |
|
|
|
|
bailout2(LOG_ERR, "Error reading from ModMiner (set clock speed)"); |
|
|
|
|
bailout2(LOG_ERR, "%s %u.%u: Error reading (set clock speed)", modminer->api->name, modminer->device_id, fpgaid); |
|
|
|
|
if (needlock) |
|
|
|
|
mutex_unlock(&modminer->device_mutex); |
|
|
|
|
|
|
|
|
|
applog(LOG_WARNING, "ModMiner: Setting clock speed of %s %d (FPGA #%u) to %u", modminer->api->name, modminer->device_id, fpgaid, state->clock); |
|
|
|
|
applog(LOG_WARNING, "%s %u.%u: Setting clock speed to %u", modminer->api->name, modminer->device_id, fpgaid, state->clock); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -326,17 +326,17 @@ modminer_fpga_init(struct thr_info *thr)
@@ -326,17 +326,17 @@ modminer_fpga_init(struct thr_info *thr)
|
|
|
|
|
cmd[0] = '\x04'; // Read USER code (bitstream id)
|
|
|
|
|
cmd[1] = fpgaid; |
|
|
|
|
if (write(fd, cmd, 2) != 2) |
|
|
|
|
bailout2(LOG_ERR, "Error writing to ModMiner (read USER code)"); |
|
|
|
|
bailout2(LOG_ERR, "%s %u.%u: Error writing (read USER code)", modminer->api->name, modminer->device_id, fpgaid); |
|
|
|
|
if (serial_read(fd, buf, 4) != 4) |
|
|
|
|
bailout2(LOG_ERR, "Error reading from ModMiner (read USER code)"); |
|
|
|
|
bailout2(LOG_ERR, "%s %u.%u: Error reading (read USER code)", modminer->api->name, modminer->device_id, fpgaid); |
|
|
|
|
|
|
|
|
|
if (memcmp(buf, BISTREAM_USER_ID, 4)) { |
|
|
|
|
applog(LOG_ERR, "FPGA #%d not programmed", fpgaid); |
|
|
|
|
applog(LOG_ERR, "%s %u.%u: FPGA not programmed", modminer->api->name, modminer->device_id, fpgaid); |
|
|
|
|
if (!modminer_fpga_upload_bitstream(modminer)) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
applog(LOG_DEBUG, "FPGA #%d is already programmed :)", fpgaid); |
|
|
|
|
applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed :)", modminer->api->name, modminer->device_id, fpgaid); |
|
|
|
|
|
|
|
|
|
state->clock = 212; // Will be reduced to 210 by modminer_reduce_clock
|
|
|
|
|
modminer_reduce_clock(thr, false); |
|
|
|
@ -364,13 +364,14 @@ modminer_start_work(struct thr_info*thr)
@@ -364,13 +364,14 @@ modminer_start_work(struct thr_info*thr)
|
|
|
|
|
fd_set fds; |
|
|
|
|
struct cgpu_info*modminer = thr->cgpu; |
|
|
|
|
struct modminer_fpga_state *state = thr->cgpu_data; |
|
|
|
|
char fpgaid = thr->device_thread; |
|
|
|
|
int fd = modminer->device_fd; |
|
|
|
|
|
|
|
|
|
char buf[1]; |
|
|
|
|
|
|
|
|
|
mutex_lock(&modminer->device_mutex); |
|
|
|
|
if (46 != write(fd, state->next_work_cmd, 46)) |
|
|
|
|
bailout2(LOG_ERR, "Error writing to ModMiner (start work)"); |
|
|
|
|
bailout2(LOG_ERR, "%s %u.%u: Error writing (start work)", modminer->api->name, modminer->device_id, fpgaid); |
|
|
|
|
gettimeofday(&state->tv_workstart, NULL); |
|
|
|
|
state->hashes = 0; |
|
|
|
|
status_read("start work"); |
|
|
|
@ -403,7 +404,7 @@ modminer_process_results(struct thr_info*thr)
@@ -403,7 +404,7 @@ modminer_process_results(struct thr_info*thr)
|
|
|
|
|
modminer->temp = (float)temperature; |
|
|
|
|
if (temperature > modminer->cutofftemp - 2) { |
|
|
|
|
if (temperature > modminer->cutofftemp) { |
|
|
|
|
applog(LOG_WARNING, "Hit thermal cutoff limit on %s %d, disabling!", modminer->api->name, modminer->device_id); |
|
|
|
|
applog(LOG_WARNING, "%s %u.%u: Hit thermal cutoff limit, disabling device!", modminer->api->name, modminer->device_id, fpgaid); |
|
|
|
|
modminer->deven = DEV_RECOVER; |
|
|
|
|
|
|
|
|
|
modminer->device_last_not_well = time(NULL); |
|
|
|
@ -423,7 +424,7 @@ modminer_process_results(struct thr_info*thr)
@@ -423,7 +424,7 @@ modminer_process_results(struct thr_info*thr)
|
|
|
|
|
iter = 200; |
|
|
|
|
while (1) { |
|
|
|
|
if (write(fd, cmd, 2) != 2) |
|
|
|
|
bailout2(LOG_ERR, "Error reading from ModMiner (get nonce)"); |
|
|
|
|
bailout2(LOG_ERR, "%s %u.%u: Error reading (get nonce)", modminer->api->name, modminer->device_id, fpgaid); |
|
|
|
|
serial_read(fd, &nonce, 4); |
|
|
|
|
mutex_unlock(&modminer->device_mutex); |
|
|
|
|
if (memcmp(&nonce, "\xff\xff\xff\xff", 4)) { |
|
|
|
|