|
|
@ -51,7 +51,7 @@ modminer_detect_one(const char *devpath) |
|
|
|
size_t len; |
|
|
|
size_t len; |
|
|
|
|
|
|
|
|
|
|
|
// Sending 45 noops, just in case the device was left in "start job" reading
|
|
|
|
// 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) |
|
|
|
while (serial_read(fd, buf, sizeof(buf)) > 0) |
|
|
|
; |
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
@ -142,9 +142,9 @@ get_modminer_statline_before(char *buf, struct cgpu_info *modminer) |
|
|
|
FD_SET(fd, &fds); \ |
|
|
|
FD_SET(fd, &fds); \ |
|
|
|
select(fd+1, &fds, NULL, NULL, NULL); \ |
|
|
|
select(fd+1, &fds, NULL, NULL, NULL); \ |
|
|
|
if (1 != read(fd, buf, 1)) \ |
|
|
|
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) \ |
|
|
|
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) |
|
|
|
} while(0) |
|
|
|
|
|
|
|
|
|
|
|
static bool |
|
|
|
static bool |
|
|
@ -198,7 +198,7 @@ fd_set fds; |
|
|
|
|
|
|
|
|
|
|
|
int fd = modminer->device_fd; |
|
|
|
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[0] = '\x05'; // Program Bitstream
|
|
|
|
buf[1] = fpgaid; |
|
|
|
buf[1] = fpgaid; |
|
|
|
buf[2] = (len >> 0) & 0xff; |
|
|
|
buf[2] = (len >> 0) & 0xff; |
|
|
@ -206,20 +206,20 @@ fd_set fds; |
|
|
|
buf[4] = (len >> 16) & 0xff; |
|
|
|
buf[4] = (len >> 16) & 0xff; |
|
|
|
buf[5] = (len >> 24) & 0xff; |
|
|
|
buf[5] = (len >> 24) & 0xff; |
|
|
|
if (6 != write(fd, buf, 6)) |
|
|
|
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"); |
|
|
|
status_read("cmd reply"); |
|
|
|
size_t buflen; |
|
|
|
size_t buflen; |
|
|
|
while (len) { |
|
|
|
while (len) { |
|
|
|
buflen = len < 32 ? len : 32; |
|
|
|
buflen = len < 32 ? len : 32; |
|
|
|
if (fread(buf, buflen, 1, f) != 1) |
|
|
|
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) |
|
|
|
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"); |
|
|
|
status_read("status"); |
|
|
|
len -= buflen; |
|
|
|
len -= buflen; |
|
|
|
} |
|
|
|
} |
|
|
|
status_read("final status"); |
|
|
|
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; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -229,10 +229,10 @@ modminer_device_prepare(struct cgpu_info *modminer) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int fd = serial_open(modminer->device_path, 0, /*FIXME=-1*/3000, true); |
|
|
|
int fd = serial_open(modminer->device_path, 0, /*FIXME=-1*/3000, true); |
|
|
|
if (unlikely(-1 == fd)) |
|
|
|
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; |
|
|
|
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; |
|
|
|
struct timeval now; |
|
|
|
gettimeofday(&now, NULL); |
|
|
|
gettimeofday(&now, NULL); |
|
|
@ -294,13 +294,13 @@ modminer_reduce_clock(struct thr_info*thr, bool needlock) |
|
|
|
if (needlock) |
|
|
|
if (needlock) |
|
|
|
mutex_lock(&modminer->device_mutex); |
|
|
|
mutex_lock(&modminer->device_mutex); |
|
|
|
if (6 != write(fd, cmd, 6)) |
|
|
|
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) |
|
|
|
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) |
|
|
|
if (needlock) |
|
|
|
mutex_unlock(&modminer->device_mutex); |
|
|
|
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; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -326,17 +326,17 @@ modminer_fpga_init(struct thr_info *thr) |
|
|
|
cmd[0] = '\x04'; // Read USER code (bitstream id)
|
|
|
|
cmd[0] = '\x04'; // Read USER code (bitstream id)
|
|
|
|
cmd[1] = fpgaid; |
|
|
|
cmd[1] = fpgaid; |
|
|
|
if (write(fd, cmd, 2) != 2) |
|
|
|
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) |
|
|
|
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)) { |
|
|
|
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)) |
|
|
|
if (!modminer_fpga_upload_bitstream(modminer)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
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
|
|
|
|
state->clock = 212; // Will be reduced to 210 by modminer_reduce_clock
|
|
|
|
modminer_reduce_clock(thr, false); |
|
|
|
modminer_reduce_clock(thr, false); |
|
|
@ -364,13 +364,14 @@ modminer_start_work(struct thr_info*thr) |
|
|
|
fd_set fds; |
|
|
|
fd_set fds; |
|
|
|
struct cgpu_info*modminer = thr->cgpu; |
|
|
|
struct cgpu_info*modminer = thr->cgpu; |
|
|
|
struct modminer_fpga_state *state = thr->cgpu_data; |
|
|
|
struct modminer_fpga_state *state = thr->cgpu_data; |
|
|
|
|
|
|
|
char fpgaid = thr->device_thread; |
|
|
|
int fd = modminer->device_fd; |
|
|
|
int fd = modminer->device_fd; |
|
|
|
|
|
|
|
|
|
|
|
char buf[1]; |
|
|
|
char buf[1]; |
|
|
|
|
|
|
|
|
|
|
|
mutex_lock(&modminer->device_mutex); |
|
|
|
mutex_lock(&modminer->device_mutex); |
|
|
|
if (46 != write(fd, state->next_work_cmd, 46)) |
|
|
|
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); |
|
|
|
gettimeofday(&state->tv_workstart, NULL); |
|
|
|
state->hashes = 0; |
|
|
|
state->hashes = 0; |
|
|
|
status_read("start work"); |
|
|
|
status_read("start work"); |
|
|
@ -403,7 +404,7 @@ modminer_process_results(struct thr_info*thr) |
|
|
|
modminer->temp = (float)temperature; |
|
|
|
modminer->temp = (float)temperature; |
|
|
|
if (temperature > modminer->cutofftemp - 2) { |
|
|
|
if (temperature > modminer->cutofftemp - 2) { |
|
|
|
if (temperature > modminer->cutofftemp) { |
|
|
|
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->deven = DEV_RECOVER; |
|
|
|
|
|
|
|
|
|
|
|
modminer->device_last_not_well = time(NULL); |
|
|
|
modminer->device_last_not_well = time(NULL); |
|
|
@ -423,7 +424,7 @@ modminer_process_results(struct thr_info*thr) |
|
|
|
iter = 200; |
|
|
|
iter = 200; |
|
|
|
while (1) { |
|
|
|
while (1) { |
|
|
|
if (write(fd, cmd, 2) != 2) |
|
|
|
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); |
|
|
|
serial_read(fd, &nonce, 4); |
|
|
|
mutex_unlock(&modminer->device_mutex); |
|
|
|
mutex_unlock(&modminer->device_mutex); |
|
|
|
if (memcmp(&nonce, "\xff\xff\xff\xff", 4)) { |
|
|
|
if (memcmp(&nonce, "\xff\xff\xff\xff", 4)) { |
|
|
|