FPGA - allow device detect override without an open failure
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
diff --git a/README b/README
index fac8e6f..862ec54 100644
--- a/README
+++ b/README
@@ -199,6 +199,8 @@ FPGA mining boards(BitForce, Icarus, ModMiner, Ztex) only options:
--scan-serial|-S <arg> Serial port to probe for FPGA mining device
+ This option is only for BitForce, Icarus, and/or ModMiner FPGAs
+
By default, cgminer will scan for autodetected FPGAs unless at least one
-S is specified for that driver. If you specify -S and still want cgminer
to scan, you must also use "-S auto". If you want to prevent cgminer from
@@ -210,6 +212,11 @@ FPGA mining boards(BitForce, Icarus, ModMiner, Ztex) only options:
On windows <arg> is usually of the format \\.\COMn
(where n = the correct device number for the FPGA device)
+ The official supplied binaries are compiled with support for all FPGAs.
+ To force the code to only attempt detection with a specific driver,
+ prepend the argument with the driver name followed by a colon.
+ For example, "icarus:/dev/ttyUSB0" or "bitforce:\\.\COM5"
+
For other FPGA details see the FPGA-README
diff --git a/driver-bitforce.c b/driver-bitforce.c
index aa22dee..08595a7 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -53,9 +53,11 @@ static bool bitforce_detect_one(const char *devpath)
char *s;
char pdevbuf[0x100];
+ applog(LOG_DEBUG, "BitForce Detect: Attempting to open %s", devpath);
+
int fdDev = BFopen(devpath);
if (unlikely(fdDev == -1)) {
- applog(LOG_DEBUG, "BitForce Detect: Failed to open %s", devpath);
+ applog(LOG_ERR, "BitForce Detect: Failed to open %s", devpath);
return false;
}
BFwrite(fdDev, "ZGX", 3);
@@ -96,7 +98,7 @@ static char bitforce_detect_auto()
static void bitforce_detect()
{
- serial_detect_auto("bitforce", bitforce_detect_one, bitforce_detect_auto);
+ serial_detect_auto(bitforce_api.dname, bitforce_detect_one, bitforce_detect_auto);
}
static void get_bitforce_statline_before(char *buf, struct cgpu_info *bitforce)
diff --git a/driver-icarus.c b/driver-icarus.c
index ee9800c..a463c28 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -379,6 +379,8 @@ static bool icarus_detect_one(const char *devpath)
unsigned char ob_bin[64], nonce_bin[ICARUS_READ_SIZE];
char *nonce_hex;
+ applog(LOG_DEBUG, "Icarus Detect: Attempting to open %s", devpath);
+
fd = icarus_open2(devpath, true);
if (unlikely(fd == -1)) {
applog(LOG_ERR, "Icarus Detect: Failed to open %s", devpath);
@@ -444,7 +446,7 @@ static bool icarus_detect_one(const char *devpath)
static void icarus_detect()
{
- serial_detect("icarus", icarus_detect_one);
+ serial_detect(icarus_api.dname, icarus_detect_one);
}
static bool icarus_prepare(struct thr_info *thr)
diff --git a/driver-modminer.c b/driver-modminer.c
index 0afce2d..70442e7 100644
--- a/driver-modminer.c
+++ b/driver-modminer.c
@@ -103,7 +103,7 @@ modminer_detect_auto()
static void
modminer_detect()
{
- serial_detect_auto("modminer", modminer_detect_one, modminer_detect_auto);
+ serial_detect_auto(modminer_api.dname, modminer_detect_one, modminer_detect_auto);
}
#define bailout(...) return _bailout(-1, modminer, __VA_ARGS__);
diff --git a/fpgautils.c b/fpgautils.c
index 783015a..70387c6 100644
--- a/fpgautils.c
+++ b/fpgautils.c
@@ -119,20 +119,25 @@ serial_autodetect_devserial(detectone_func_t detectone, const char*prodname)
}
char
-_serial_detect(const char*dnamec, size_t dnamel, detectone_func_t detectone, autoscan_func_t autoscan, bool forceauto)
+_serial_detect(const char*dname, detectone_func_t detectone, autoscan_func_t autoscan, bool forceauto)
{
if (total_devices == MAX_DEVICES)
return 0;
struct string_elist *iter, *tmp;
- const char*s;
+ const char*s, *p;
bool inhibitauto = false;
char found = 0;
+ size_t dnamel = strlen(dname);
list_for_each_entry_safe(iter, tmp, &scan_devices, list) {
s = iter->string;
- if (!strncmp(dnamec, iter->string, dnamel))
- s += dnamel;
+ if ((p = strchr(s, ':')) && p[1] != '\0') {
+ size_t plen = p - s;
+ if (plen != dnamel || strncasecmp(s, dname, plen))
+ continue;
+ s = p + 1;
+ }
if (!strcmp(s, "auto"))
forceauto = true;
else
diff --git a/fpgautils.h b/fpgautils.h
index 91ccb30..c45183b 100644
--- a/fpgautils.h
+++ b/fpgautils.h
@@ -16,13 +16,13 @@
typedef bool(*detectone_func_t)(const char*);
typedef char(*autoscan_func_t)();
-extern char _serial_detect(const char*dnamec, size_t dnamel, detectone_func_t, autoscan_func_t, bool force_autoscan);
+extern char _serial_detect(const char*dname, detectone_func_t, autoscan_func_t, bool force_autoscan);
#define serial_detect_fauto(dname, detectone, autoscan) \
- _serial_detect(dname ":", sizeof(dname), detectone, autoscan, true)
+ _serial_detect(dname, detectone, autoscan, true)
#define serial_detect_auto(dname, detectone, autoscan) \
- _serial_detect(dname ":", sizeof(dname), detectone, autoscan, false)
+ _serial_detect(dname, detectone, autoscan, false)
#define serial_detect(dname, detectone) \
- _serial_detect(dname ":", sizeof(dname), detectone, NULL, false)
+ _serial_detect(dname, detectone, NULL, false)
extern char serial_autodetect_devserial(detectone_func_t, const char*prodname);
extern char serial_autodetect_udev (detectone_func_t, const char*prodname);