Merge commit 'b606a60349fe2f1c1c56a1fec833ec849b798676' into redfury Conflicts: driver-bitfury.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657
diff --git a/ASIC-README b/ASIC-README
index e485032..4da05ab 100644
--- a/ASIC-README
+++ b/ASIC-README
@@ -1,10 +1,10 @@
SUPPORTED DEVICES
Currently supported devices include the Avalon (including BitBurner), the
-Butterfly Labs SC range of devices and the ASICMINER block erupters. No COM
-ports on windows or TTY devices will be used by cgminer as it communicates
-directly with them via USB so it is normal for them to not exist or be
-disconnected when cgminer is running.
+Butterfly Labs SC range of devices, the ASICMINER block erupters and the BPMC
+BF1 (bitfury) USB devices. No COM ports on windows or TTY devices will be used
+by cgminer as it communicates directly with them via USB so it is normal for
+them to not exist or be disconnected when cgminer is running.
The BFL devices should come up as one of the following:
@@ -24,7 +24,18 @@ ASICMINER block erupters will come up as AMU.
ASICMINER devices need the --enable-icarus option when compiling cgminer.
Also note that the AMU is managed by the Icarus driver which is detailed
-in the FPGA-README
+in the FPGA-README. Configuring them uses the same mechanism as outlined
+below for getting started with butterfly labs ASICs.
+
+
+BITFURY devices
+
+Bitfury devices need the --enable-bitfury option when compiling cgminer.
+
+Currently only the BPMC BF1 devices AKA redfury/bluefury are supported and
+come up as BF1. There are no options available for them. Bitfury device are
+also set up as per the butterfly labs ASICs below.
+
GETTING STARTED WITH BUTTERFLY LABS ASICS
diff --git a/api.c b/api.c
index c60414f..e86ac7b 100644
--- a/api.c
+++ b/api.c
@@ -29,7 +29,7 @@
#include "miner.h"
#include "util.h"
-#if defined(USE_BFLSC) || defined(USE_AVALON)
+#if defined(USE_BFLSC) || defined(USE_AVALON) || defined(USE_BITFURY)
#define HAVE_AN_ASIC 1
#endif
@@ -176,6 +176,9 @@ static const char *DEVICECODE = ""
#ifdef USE_BITFORCE
"BFL "
#endif
+#ifdef USE_BITFURY
+ "BFU "
+#endif
#ifdef USE_ICARUS
"ICA "
#endif
@@ -1224,6 +1227,10 @@ static int numascs()
if (devices[i]->drv->drv_id == DRIVER_BFLSC)
count++;
#endif
+#ifdef USE_BITFURY
+ if (devices[i]->drv->drv_id == DRIVER_BITFURY)
+ count++;
+#endif
}
rd_unlock(&devices_lock);
return count;
@@ -1244,6 +1251,10 @@ static int ascdevice(int ascid)
if (devices[i]->drv->drv_id == DRIVER_BFLSC)
count++;
#endif
+#ifdef USE_BITFURY
+ if (devices[i]->drv->drv_id == DRIVER_BITFURY)
+ count++;
+#endif
if (count == (ascid + 1))
goto foundit;
}
diff --git a/cgminer.c b/cgminer.c
index 29fd52e..953ab02 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3658,15 +3658,6 @@ static void rebuild_hash(struct work *work)
scrypt_regenhash(work);
else
regen_hash(work);
-
- work->share_diff = share_diff(work);
- if (unlikely(work->share_diff >= current_diff)) {
- work->block = true;
- work->pool->solved++;
- found_blocks++;
- work->mandatory = true;
- applog(LOG_NOTICE, "Found block for pool %d!", work->pool->pool_no);
- }
}
static bool cnx_needed(struct pool *pool);
@@ -3844,7 +3835,7 @@ int restart_wait(struct thr_info *thr, unsigned int mstime)
mutex_lock(&restart_lock);
if (thr->work_restart)
- rc = ETIMEDOUT;
+ rc = 0;
else
rc = pthread_cond_timedwait(&restart_cond, &restart_lock, &abstime);
mutex_unlock(&restart_lock);
@@ -6016,17 +6007,12 @@ void inc_hw_errors(struct thr_info *thr)
thr->cgpu->drv->hw_error(thr);
}
-/* Returns true if nonce for work was a valid share */
-bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
+bool test_nonce(struct work *work, uint32_t nonce)
{
uint32_t *work_nonce = (uint32_t *)(work->data + 64 + 12);
- struct timeval tv_work_found;
- unsigned char hash2[32];
- uint32_t *hash2_32 = (uint32_t *)hash2;
+ uint32_t *hash2_32 = (uint32_t *)work->hash2;
uint32_t diff1targ;
- bool ret = true;
- cgtime(&tv_work_found);
*work_nonce = htole32(nonce);
/* Do one last check before attempting to submit the work */
@@ -6034,14 +6020,16 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
flip32(hash2_32, work->hash);
diff1targ = opt_scrypt ? 0x0000ffffUL : 0;
- if (be32toh(hash2_32[7]) > diff1targ) {
- applog(LOG_INFO, "%s%d: invalid nonce - HW error",
- thr->cgpu->drv->name, thr->cgpu->device_id);
+ return (be32toh(hash2_32[7]) <= diff1targ);
+}
- inc_hw_errors(thr);
- ret = false;
- goto out;
- }
+/* To be used once the work has been tested to be meet diff1 and has had its
+ * nonce adjusted. */
+void submit_tested_work(struct thr_info *thr, struct work *work)
+{
+ struct timeval tv_work_found;
+
+ work->share_diff = share_diff(work);
mutex_lock(&stats_lock);
total_diff1 += work->device_diff;
@@ -6050,13 +6038,30 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
thr->cgpu->last_device_valid_work = time(NULL);
mutex_unlock(&stats_lock);
- if (!fulltest(hash2, work->target)) {
+ if (!fulltest(work->hash2, work->target)) {
applog(LOG_INFO, "Share below target");
- goto out;
+ return;
}
+ cgtime(&tv_work_found);
submit_work_async(work, &tv_work_found);
-out:
+}
+
+/* Returns true if nonce for work was a valid share */
+bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
+{
+ bool ret = true;
+
+ if (test_nonce(work, nonce))
+ submit_tested_work(thr, work);
+ else {
+ applog(LOG_INFO, "%s%d: invalid nonce - HW error",
+ thr->cgpu->drv->name, thr->cgpu->device_id);
+
+ inc_hw_errors(thr);
+ ret = false;
+ }
+
return ret;
}
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 356a69d..4d666c1 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -11,7 +11,10 @@
#include "miner.h"
#include "driver-bitfury.h"
+#include "sha2.h"
+/* Wait longer 1/3 longer than it would take for a full nonce range */
+#define BF1WAIT 1600
struct device_drv bitfury_drv;
static void bitfury_empty_buffer(struct cgpu_info *bitfury)
@@ -27,16 +30,17 @@ static void bitfury_empty_buffer(struct cgpu_info *bitfury)
static void bitfury_open(struct cgpu_info *bitfury)
{
/* Magic open sequence */
- usb_transfer(bitfury, 0x21, 0x22, 0x0003, 0, C_BFO_OPEN);
+ usb_transfer(bitfury, 0x21, 0x22, 0x0003, 0, C_BF1_OPEN);
bitfury_empty_buffer(bitfury);
}
static void bitfury_close(struct cgpu_info *bitfury)
{
+ bitfury_empty_buffer(bitfury);
/* Magic close sequence */
- usb_transfer(bitfury, 0x21, 0x22, 0, 0, C_BFO_CLOSE);
+ usb_transfer(bitfury, 0x21, 0x22, 0, 0, C_BF1_CLOSE);
bitfury_empty_buffer(bitfury);
- usb_transfer(bitfury, 0x23, 0x08, 0x9053, 1, C_BFO_CLOSE);
+ usb_transfer(bitfury, 0x23, 0x08, 0x9053, 1, C_BF1_CLOSE);
bitfury_empty_buffer(bitfury);
}
@@ -47,12 +51,51 @@ static void bitfury_identify(struct cgpu_info *bitfury)
usb_write(bitfury, "L", 1, &amount, C_PING);
}
+static bool bitfury_getinfo(struct cgpu_info *bitfury, struct bitfury_info *info)
+{
+ char buf[512];
+ int amount;
+
+ usb_write(bitfury, "I", 1, &amount, C_BF1_REQINFO);
+ usb_read(bitfury, buf, 14, &amount, C_BF1_GETINFO);
+ if (amount != 14) {
+ applog(LOG_INFO, "%s %d: Getinfo received %d bytes",
+ bitfury->drv->name, bitfury->device_id, amount);
+ return false;
+ }
+ info->version = buf[1];
+ memcpy(&info->product, buf + 2, 8);
+ memcpy(&info->serial, buf + 10, 4);
+
+ applog(LOG_INFO, "%s %d: Getinfo returned version %d, product %s serial %08x", bitfury->drv->name,
+ bitfury->device_id, info->version, info->product, info->serial);
+ bitfury_empty_buffer(bitfury);
+ return true;
+}
+
+static bool bitfury_reset(struct cgpu_info *bitfury)
+{
+ char buf[512];
+ int amount;
+
+ usb_write(bitfury, "R", 1, &amount, C_BF1_REQRESET);
+ usb_read_timeout(bitfury, buf, 7, &amount, BF1WAIT, C_BF1_GETRESET);
+
+ if (amount != 7) {
+ applog(LOG_INFO, "%s %d: Getreset received %d bytes",
+ bitfury->drv->name, bitfury->device_id, amount);
+ return false;
+ }
+ applog(LOG_INFO, "%s %d: Getreset returned %s", bitfury->drv->name,
+ bitfury->device_id, buf);
+ bitfury_empty_buffer(bitfury);
+ return true;
+}
+
static bool bitfury_detect_one(struct libusb_device *dev, struct usb_find_devices *found)
{
struct cgpu_info *bitfury;
struct bitfury_info *info;
- char buf[512];
- int amount;
bitfury = usb_alloc_cgpu(&bitfury_drv, 1);
@@ -60,7 +103,7 @@ static bool bitfury_detect_one(struct libusb_device *dev, struct usb_find_device
bitfury = usb_free_cgpu(bitfury);
goto out;
}
- applog(LOG_INFO, "%s%d: Found at %s", bitfury->drv->name,
+ applog(LOG_INFO, "%s %d: Found at %s", bitfury->drv->name,
bitfury->device_id, bitfury->device_path);
info = calloc(sizeof(struct bitfury_info), 1);
@@ -73,37 +116,23 @@ static bool bitfury_detect_one(struct libusb_device *dev, struct usb_find_device
bitfury_open(bitfury);
/* Send getinfo request */
- usb_write(bitfury, "I", 1, &amount, C_BFO_REQINFO);
- usb_read(bitfury, buf, 14, &amount, C_BFO_GETINFO);
- if (amount != 14) {
- applog(LOG_WARNING, "%s%d: Getinfo received %d bytes",
- bitfury->drv->name, bitfury->device_id, amount);
+ if (!bitfury_getinfo(bitfury, info))
goto out_close;
- }
- info->version = buf[1];
- memcpy(&info->product, buf + 2, 8);
- memcpy(&info->serial, buf + 10, 4);
-
- applog(LOG_INFO, "%s%d: Getinfo returned version %d, product %s serial %08x", bitfury->drv->name,
- bitfury->device_id, info->version, info->product, info->serial);
- bitfury_empty_buffer(bitfury);
/* Send reset request */
- usb_write(bitfury, "R", 1, &amount, C_BFO_REQRESET);
- usb_read_timeout(bitfury, buf, 7, &amount, 1000, C_BFO_GETRESET);
-
- if (amount != 7) {
- applog(LOG_WARNING, "%s%d: Getreset received %d bytes",
- bitfury->drv->name, bitfury->device_id, amount);
+ if (!bitfury_reset(bitfury))
goto out_close;
- }
- applog(LOG_INFO, "%s%d: Getreset returned %s", bitfury->drv->name,
- bitfury->device_id, buf);
- bitfury_empty_buffer(bitfury);
bitfury_identify(bitfury);
bitfury_empty_buffer(bitfury);
- //return true;
+
+ if (!add_cgpu(bitfury))
+ goto out_close;
+
+ update_usb_stats(bitfury);
+ applog(LOG_INFO, "%s %d: Found at %s",
+ bitfury->drv->name, bitfury->device_id, bitfury->device_path);
+ return true;
out_close:
bitfury_close(bitfury);
out:
@@ -115,40 +144,152 @@ static void bitfury_detect(void)
usb_detect(&bitfury_drv, bitfury_detect_one);
}
-static bool bitfury_prepare(struct thr_info __maybe_unused *thr)
+static uint32_t decnonce(uint32_t in)
{
- return false;
+ uint32_t out;
+
+ /* First part load */
+ out = (in & 0xFF) << 24; in >>= 8;
+
+ /* Byte reversal */
+ in = (((in & 0xaaaaaaaa) >> 1) | ((in & 0x55555555) << 1));
+ in = (((in & 0xcccccccc) >> 2) | ((in & 0x33333333) << 2));
+ in = (((in & 0xf0f0f0f0) >> 4) | ((in & 0x0f0f0f0f) << 4));
+
+ out |= (in >> 2)&0x3FFFFF;
+
+ /* Extraction */
+ if (in & 1) out |= (1 << 23);
+ if (in & 2) out |= (1 << 22);
+
+ out -= 0x800004;
+ return out;
}
-static bool bitfury_fill(struct cgpu_info __maybe_unused *bitfury)
+#define BT_OFFSETS 3
+const uint32_t bf_offsets[] = {0, -0x400000, -0x800000};
+
+static bool bitfury_checkresults(struct thr_info *thr, struct work *work, uint32_t nonce)
{
- return true;
+ int i;
+
+ for (i = 0; i < BT_OFFSETS; i++) {
+ if (test_nonce(work, nonce + bf_offsets[i])) {
+ submit_tested_work(thr, work);
+ return true;
+ }
+ }
+ return false;
}
-static int64_t bitfury_scanhash(struct thr_info __maybe_unused *thr)
+static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
+ int64_t __maybe_unused max_nonce)
{
+ struct cgpu_info *bitfury = thr->cgpu;
+ struct bitfury_info *info = bitfury->device_data;
+ struct timeval tv_now;
+ int amount, i;
+ char buf[45];
+ int ms_diff;
+
+ buf[0] = 'W';
+ memcpy(buf + 1, work->midstate, 32);
+ memcpy(buf + 33, work->data + 64, 12);
+
+ /* New results may spill out from the latest work, making us drop out
+ * too early so read whatever we get for the first half nonce and then
+ * look for the results to prev work. */
+ cgtime(&tv_now);
+ ms_diff = 600 - ms_tdiff(&tv_now, &info->tv_start);
+ if (ms_diff > 0) {
+ usb_read_timeout(bitfury, info->buf, 512, &amount, ms_diff, C_BF1_GETRES);
+ info->tot += amount;
+ }
+
+ if (unlikely(thr->work_restart))
+ goto cascade;
+
+ /* Now look for the bulk of the previous work results, they will come
+ * in a batch following the first data. */
+ cgtime(&tv_now);
+ ms_diff = BF1WAIT - ms_tdiff(&tv_now, &info->tv_start);
+ if (unlikely(ms_diff < 10))
+ ms_diff = 10;
+ usb_read_once_timeout(bitfury, info->buf + info->tot, 7, &amount, ms_diff, C_BF1_GETRES);
+ info->tot += amount;
+ while (amount) {
+ usb_read_once_timeout(bitfury, info->buf + info->tot, 512, &amount, 10, C_BF1_GETRES);
+ info->tot += amount;
+ };
+
+ if (unlikely(thr->work_restart))
+ goto cascade;
+
+ /* Send work */
+ usb_write(bitfury, buf, 45, &amount, C_BF1_REQWORK);
+ cgtime(&info->tv_start);
+ /* Get response acknowledging work */
+ usb_read(bitfury, buf, 7, &amount, C_BF1_GETWORK);
+
+ /* Only happens on startup */
+ if (unlikely(!info->prevwork[BF1ARRAY_SIZE]))
+ goto cascade;
+
+ /* Search for what work the nonce matches in order of likelihood. Last
+ * entry is end of result marker. */
+ for (i = 0; i < info->tot - 7; i += 7) {
+ uint32_t nonce;
+ int j;
+
+ /* Ignore state & switched data in results for now. */
+ memcpy(&nonce, info->buf + i + 3, 4);
+ nonce = decnonce(nonce);
+ for (j = 0; j < BF1ARRAY_SIZE; j++) {
+ if (bitfury_checkresults(thr, info->prevwork[j], nonce)) {
+ info->nonces++;
+ break;
+ }
+ }
+ }
+
+ info->tot = 0;
+ free_work(info->prevwork[BF1ARRAY_SIZE]);
+cascade:
+ for (i = BF1ARRAY_SIZE; i > 0; i--)
+ info->prevwork[i] = info->prevwork[i - 1];
+ info->prevwork[0] = copy_work(work);
+ work->blk.nonce = 0xffffffff;
+ if (info->nonces) {
+ info->nonces--;
+ return (int64_t)0xffffffff;
+ }
return 0;
}
-static void bitfury_flush_work(struct cgpu_info __maybe_unused *bitfury)
+static struct api_data *bitfury_api_stats(struct cgpu_info *cgpu)
{
-}
+ struct bitfury_info *info = cgpu->device_data;
+ struct api_data *root = NULL;
+ char serial[16];
+ int version;
-static struct api_data *bitfury_api_stats(struct cgpu_info __maybe_unused *cgpu)
-{
- return NULL;
-}
+ version = info->version;
+ root = api_add_int(root, "Version", &version, true);
+ root = api_add_string(root, "Product", info->product, false);
+ sprintf(serial, "%08x", info->serial);
+ root = api_add_string(root, "Serial", serial, true);
-static void get_bitfury_statline_before(char __maybe_unused *buf, size_t __maybe_unused bufsiz,
- struct cgpu_info __maybe_unused *bitfury)
-{
+ return root;
}
-static void bitfury_init(struct cgpu_info __maybe_unused *bitfury)
+static void bitfury_init(struct cgpu_info *bitfury)
{
+ bitfury_close(bitfury);
+ bitfury_open(bitfury);
+ bitfury_reset(bitfury);
}
-static void bitfury_shutdown(struct thr_info __maybe_unused *thr)
+static void bitfury_shutdown(struct thr_info *thr)
{
struct cgpu_info *bitfury = thr->cgpu;
@@ -159,15 +300,10 @@ static void bitfury_shutdown(struct thr_info __maybe_unused *thr)
struct device_drv bitfury_drv = {
.drv_id = DRIVER_BITFURY,
.dname = "bitfury",
- .name = "BFO",
+ .name = "BF1",
.drv_detect = bitfury_detect,
- .thread_prepare = bitfury_prepare,
- .hash_work = hash_queued_work,
- .queue_full = bitfury_fill,
- .scanwork = bitfury_scanhash,
- .flush_work = bitfury_flush_work,
+ .scanhash = bitfury_scanhash,
.get_api_stats = bitfury_api_stats,
- .get_statline_before = get_bitfury_statline_before,
.reinit_device = bitfury_init,
.thread_shutdown = bitfury_shutdown,
.identify_device = bitfury_identify
diff --git a/driver-bitfury.h b/driver-bitfury.h
index c427fdc..db13323 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -10,12 +10,20 @@
#ifndef BITFURY_H
#define BITFURY_H
+#include "miner.h"
#include "usbutils.h"
+#define BF1ARRAY_SIZE 2
+
struct bitfury_info {
uint8_t version;
char product[8];
uint32_t serial;
+ struct work *prevwork[BF1ARRAY_SIZE + 1];
+ char buf[512];
+ int tot;
+ int nonces;
+ struct timeval tv_start;
};
#endif /* BITFURY_H */
diff --git a/miner.h b/miner.h
index bc10f5e..867ca0e 100644
--- a/miner.h
+++ b/miner.h
@@ -1263,6 +1263,7 @@ struct work {
#endif
double device_diff;
uint64_t share_diff;
+ unsigned char hash2[32];
int rolls;
@@ -1356,6 +1357,8 @@ struct modminer_fpga_state {
extern void get_datestamp(char *, size_t, struct timeval *);
extern void inc_hw_errors(struct thr_info *thr);
+extern bool test_nonce(struct work *work, uint32_t nonce);
+extern void submit_tested_work(struct thr_info *thr, struct work *work);
extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
extern struct work *get_queued(struct cgpu_info *cgpu);
extern struct work *__find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
diff --git a/usbutils.c b/usbutils.c
index 9bf0b17..fe3b9cf 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -84,7 +84,7 @@
#else
#define BFLSC_TIMEOUT_MS 300
#define BITFORCE_TIMEOUT_MS 200
-#define BITFURY_TIMEOUT_MS 200
+#define BITFURY_TIMEOUT_MS 100
#define MODMINER_TIMEOUT_MS 100
#define AVALON_TIMEOUT_MS 200
#define ICARUS_TIMEOUT_MS 200
@@ -266,7 +266,7 @@ static struct usb_find_devices find_dev[] = {
#ifdef USE_BITFURY
{
.drv = DRV_BITFURY,
- .name = "BFO",
+ .name = "BF1",
.ident = IDENT_BFU,
.idVendor = 0x03eb,
.idProduct = 0x204b,
@@ -2671,7 +2671,7 @@ int _usb_read(struct cgpu_info *cgpu, int epinfo, char *buf, size_t bufsiz, int
memcpy(usbdev->buffer, usbbuf + bufsiz, usbdev->bufamt);
tot -= usbdev->bufamt;
usbbuf[tot] = '\0';
- applog(LOG_ERR, "USB: %s%i read1 buffering %d extra bytes",
+ applog(LOG_INFO, "USB: %s%i read1 buffering %d extra bytes",
cgpu->drv->name, cgpu->device_id, usbdev->bufamt);
}
diff --git a/usbutils.h b/usbutils.h
index 3119e4a..d4b872f 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -322,12 +322,15 @@ struct cg_usb_info {
USB_ADD_COMMAND(C_ENABLE_UART, "EnableUART") \
USB_ADD_COMMAND(C_BB_SET_VOLTAGE, "SetCoreVoltage") \
USB_ADD_COMMAND(C_BB_GET_VOLTAGE, "GetCoreVoltage") \
- USB_ADD_COMMAND(C_BFO_OPEN, "BF1Open") \
- USB_ADD_COMMAND(C_BFO_CLOSE, "BF1Close") \
- USB_ADD_COMMAND(C_BFO_REQINFO, "BF1RequestInfo") \
- USB_ADD_COMMAND(C_BFO_GETINFO, "BF1GetInfo") \
- USB_ADD_COMMAND(C_BFO_REQRESET, "BF1RequestReset") \
- USB_ADD_COMMAND(C_BFO_GETRESET, "BF1GetReset")
+ USB_ADD_COMMAND(C_BF1_OPEN, "BF1Open") \
+ USB_ADD_COMMAND(C_BF1_CLOSE, "BF1Close") \
+ USB_ADD_COMMAND(C_BF1_REQINFO, "BF1RequestInfo") \
+ USB_ADD_COMMAND(C_BF1_GETINFO, "BF1GetInfo") \
+ USB_ADD_COMMAND(C_BF1_REQRESET, "BF1RequestReset") \
+ USB_ADD_COMMAND(C_BF1_GETRESET, "BF1GetReset") \
+ USB_ADD_COMMAND(C_BF1_REQWORK, "BF1RequestWork") \
+ USB_ADD_COMMAND(C_BF1_GETWORK, "BF1GetWork") \
+ USB_ADD_COMMAND(C_BF1_GETRES, "BF1GetResults")
/* Create usb_cmds enum from USB_PARSE_COMMANDS macro */
#define USB_ADD_COMMAND(X, Y) X,
diff --git a/util.c b/util.c
index c0feaaf..ecece48 100644
--- a/util.c
+++ b/util.c
@@ -1074,6 +1074,12 @@ double us_tdiff(struct timeval *end, struct timeval *start)
return end->tv_sec * 1000000 + end->tv_usec - start->tv_sec * 1000000 - start->tv_usec;
}
+/* Returns the milliseconds difference between end and start times */
+int ms_tdiff(struct timeval *end, struct timeval *start)
+{
+ return end->tv_sec * 1000 + end->tv_usec / 1000 - start->tv_sec * 1000 - start->tv_usec / 1000;
+}
+
/* Returns the seconds difference between end and start times as a double */
double tdiff(struct timeval *end, struct timeval *start)
{
diff --git a/util.h b/util.h
index 96157fa..5a3d968 100644
--- a/util.h
+++ b/util.h
@@ -98,6 +98,7 @@ void cgsleep_us_r(cgtimer_t *ts_start, int64_t us);
int cgtimer_to_ms(cgtimer_t *cgt);
void cgtimer_sub(cgtimer_t *a, cgtimer_t *b, cgtimer_t *res);
double us_tdiff(struct timeval *end, struct timeval *start);
+int ms_tdiff(struct timeval *end, struct timeval *start);
double tdiff(struct timeval *end, struct timeval *start);
bool stratum_send(struct pool *pool, char *s, ssize_t len);
bool sock_full(struct pool *pool);