Date:2012-02-19 15:26:00 (9 years 6 days ago)
Author:Xiangfu Liu
Commit:c38f27772d6e224764ebcfddf6d63d99df40b668
Message:cgminer: now cgminer+icarus is 10% better then origin miner.py enable all FPGA devices

Files: cgminer/Makefile (2 diffs)
cgminer/patches/0001-add-Icarus-support-to-autoreconf-system.patch (1 diff)
cgminer/patches/0001-add-icarus.c-base-on-bitforce.c.patch (1 diff)
cgminer/patches/0002-add-icarus.c-base-on-bitforce.c.patch (1 diff)
cgminer/patches/0002-add-shutdown-function.patch (1 diff)
cgminer/patches/0003-add-icarus-to-cgminer.c.patch (5 diffs)
cgminer/patches/0004-add-Icarus-support-to-autoreconf-system.patch (1 diff)
cgminer/patches/0004-update-the-message-fit-both-bitforce-and-Icarus.patch (1 diff)
cgminer/patches/0005-update-README-for-Icarus.patch (2 diffs)
cgminer/patches/0006-add-shortcut-to-description-for-easy-grep.patch (1 diff)
cgminer/patches/0006-add-shortcuts-to-description-for-easy-grep.patch (1 diff)
cgminer/patches/0007-add-MIPSED-to-icarus-for-BIG_ENDIAN.patch.patch (1 diff)
cgminer/patches/0007-remove-icarus-detect-auto.-Icarus-should-configure-t.patch (1 diff)
cgminer/patches/0008-add-MIPSED-to-icarus-for-BIG_ENDIAN.patch (1 diff)

Change Details

cgminer/Makefile
99include $(TOPDIR)/rules.mk
1010
1111PKG_NAME:=cgminer
12PKG_VERSION:=20120215
13PKG_REV:=9a0e4f8facababf54cf6dcac7bf93a0e6099047e
12PKG_VERSION:=20120219
13PKG_REV:=3cdac04f4f4c638f4a721042208073e371726cf4
1414PKG_RELEASE:=1
1515PKG_INSTALL:=1
1616
...... 
3737define Package/cgminer/description
3838endef
3939
40CONFIGURE_ARGS += --disable-opencl --disable-adl --enable-icarus
40CONFIGURE_ARGS += --disable-opencl --disable-adl --enable-icarus --enable-bitforce
4141TARGET_CFLAGS +=
4242TARGET_LDFLAGS += -Wl,-rpath-link=$(STAGING_DIR)/usr/lib
4343
cgminer/patches/0001-add-Icarus-support-to-autoreconf-system.patch
1From 75e27968a62025d1ac3655275e8f52b879092255 Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Mon, 13 Feb 2012 16:04:13 +0800
4Subject: [PATCH 1/6] add Icarus support to autoreconf system
5
6
7Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
8 Makefile.am | 3 +++
9 configure.ac | 21 +++++++++++++++++++--
10 2 files changed, 22 insertions(+), 2 deletions(-)
11
12diff --git a/Makefile.am b/Makefile.am
13index 4249d51..5262d52 100644
14+++ b/Makefile.am
15@@ -70,3 +70,6 @@ if HAS_BITFORCE
16 cgminer_SOURCES += bitforce.c
17 endif
18
19+if HAS_ICARUS
20+cgminer_SOURCES += icarus.c
21+endif
22diff --git a/configure.ac b/configure.ac
23index ee665aa..a931867 100644
24+++ b/configure.ac
25@@ -196,6 +196,17 @@ if test "x$bitforce" = xyes; then
26 fi
27 AM_CONDITIONAL([HAS_BITFORCE], [test x$bitforce = xyes])
28
29+icarus="no"
30+
31+AC_ARG_ENABLE([icarus],
32+ [AC_HELP_STRING([--enable-icarus],[Compile support for Icarus (default disabled)])],
33+ [icarus=$enableval]
34+ )
35+if test "x$icarus" = xyes; then
36+ AC_DEFINE([USE_ICARUS], [1], [Defined to 1 if Icarus support is wanted])
37+fi
38+AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes])
39+
40 AC_SEARCH_LIBS(addstr, ncurses pdcurses, ,
41         AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev]))
42
43@@ -338,13 +349,13 @@ if test "x$opencl" != xno; then
44         echo " OpenCL...............: FOUND. GPU mining support enabled"
45     else
46         echo " OpenCL...............: NOT FOUND. GPU mining support DISABLED"
47- if test "x$cpumining$bitforce" = xnono; then
48+ if test "x$cpumining$bitforce$icarus" = xnonono; then
49             AC_MSG_ERROR([No mining configured in])
50         fi
51     fi
52 else
53     echo " OpenCL...............: Detection overrided. GPU mining support DISABLED"
54- if test "x$cpumining$bitforce" = xnono; then
55+ if test "x$cpumining$bitforce$icarus" = xnonono; then
56         AC_MSG_ERROR([No mining configured in])
57     fi
58 fi
59@@ -366,6 +377,12 @@ else
60     echo " BitForce.FPGAs.......: Disabled"
61 fi
62
63+if test "x$icarus" = xyes; then
64+ echo " Icarus.FPGAs.........: Enabled"
65+else
66+ echo " Icarus.FPGAs.........: Disabled"
67+fi
68+
69 echo
70 if test "x$cpumining" = xyes; then
71     echo " CPU Mining...........: Enabled"
721.7.5.4
73
cgminer/patches/0001-add-icarus.c-base-on-bitforce.c.patch
1From 340b923e42d32bd5173fe6b285923635a6fcc67f Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Mon, 13 Feb 2012 16:04:34 +0800
4Subject: [PATCH 1/7] add icarus.c, base on bitforce.c
5
6---
7 icarus.c | 307 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 1 files changed, 307 insertions(+), 0 deletions(-)
9 create mode 100644 icarus.c
10
11diff --git a/icarus.c b/icarus.c
12new file mode 100644
13index 0000000..56b8d8a
14--- /dev/null
15@@ -0,0 +1,307 @@
16+/*
17+ * Copyright 2012 Luke Dashjr
18+ * Copyright 2012 Xiangfu <xiangfu@openmobilefree.com>
19+ *
20+ * This program is free software; you can redistribute it and/or modify it
21+ * under the terms of the GNU General Public License as published by the Free
22+ * Software Foundation; either version 2 of the License, or (at your option)
23+ * any later version. See COPYING for more details.
24+ */
25+
26+/*
27+ * Those code should be works fine with V2 and V3 bitstream of Icarus.
28+ * Operation:
29+ * No detection implement.
30+ * Input: 64B = 32B midstate + 20B fill bytes + last 12 bytes of block head.
31+ * Return: send back 32bits immediately when Icarus found a valid nonce.
32+ * no query protocol implemented here, if no data send back in ~11.3
33+ * seconds (full cover time on 32bit nonce range by 380MH/s speed)
34+ * just send another work.
35+ * Notice:
36+ * 1. Icarus will start calculate when you push a work to them, even they
37+ * are busy.
38+ * 2. The 2 FPGAs on Icarus will distribute the job, one will calculate the
39+ * 0 ~ 7FFFFFFF, another one will cover the 80000000 ~ FFFFFFFF.
40+ * 3. It's possible for 2 FPGAs both find valid nonce in the meantime, the 2
41+ * valid nonce will all be send back.
42+ * 4. Icarus will stop work when: a valid nonce has been found or 32 bits
43+ * nonce range is completely calculated.
44+ */
45+
46+#include <limits.h>
47+#include <pthread.h>
48+#include <stdio.h>
49+#include <sys/time.h>
50+#include <sys/types.h>
51+#include <dirent.h>
52+#include <unistd.h>
53+#ifndef WIN32
54+ #include <termios.h>
55+ #include <sys/stat.h>
56+ #include <fcntl.h>
57+ #ifndef O_CLOEXEC
58+ #define O_CLOEXEC 0
59+ #endif
60+#else
61+ #include <windows.h>
62+ #include <io.h>
63+#endif
64+
65+#include "elist.h"
66+#include "miner.h"
67+
68+#define ICARUS_READ_FAULT_COUNT (8)
69+
70+int icarus_read_count;
71+struct device_api icarus_api;
72+
73+static void rev(unsigned char *s, size_t l)
74+{
75+ size_t i, j;
76+ unsigned char t;
77+
78+ for (i = 0, j = l - 1; i < j; i++, j--) {
79+ t = s[i];
80+ s[i] = s[j];
81+ s[j] = t;
82+ }
83+}
84+
85+static int icarus_open(const char *devpath)
86+{
87+#ifndef WIN32
88+ struct termios my_termios;
89+
90+ int serialfd = open(devpath, O_RDWR | O_CLOEXEC | O_NOCTTY);
91+
92+ if (serialfd == -1)
93+ return -1;
94+
95+ tcgetattr(serialfd, &my_termios);
96+ my_termios.c_cflag = B115200;
97+ my_termios.c_cflag |= CS8;
98+ my_termios.c_cflag |= CREAD;
99+ my_termios.c_cflag |= CLOCAL;
100+ my_termios.c_cflag &= ~(CSIZE | PARENB);
101+
102+ my_termios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK |
103+ ISTRIP | INLCR | IGNCR | ICRNL | IXON);
104+ my_termios.c_oflag &= ~OPOST;
105+ my_termios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
106+ my_termios.c_cc[VTIME] = 10; /* block 1 second */
107+ my_termios.c_cc[VMIN] = 0;
108+ tcsetattr(serialfd, TCSANOW, &my_termios);
109+
110+ tcflush(serialfd, TCOFLUSH);
111+ tcflush(serialfd, TCIFLUSH);
112+
113+ return serialfd;
114+#else
115+ HANDLE hSerial = CreateFile(devpath, GENERIC_READ | GENERIC_WRITE, 0,
116+ NULL, OPEN_EXISTING, 0, NULL);
117+ if (unlikely(hSerial == INVALID_HANDLE_VALUE))
118+ return -1;
119+ /* TODO: Needs setup read block time. just like VTIME = 10 */
120+ return _open_osfhandle((LONG)hSerial, 0);
121+#endif
122+}
123+
124+static void icarus_gets(char *buf, size_t bufLen, int fd)
125+{
126+ ssize_t ret = 0;
127+
128+ icarus_read_count = 0;
129+
130+ while (bufLen) {
131+ ret = read(fd, buf, 1);
132+ if (ret == 1) {
133+ bufLen--;
134+ buf++;
135+ continue;
136+ }
137+
138+ icarus_read_count++;
139+ if (icarus_read_count == ICARUS_READ_FAULT_COUNT) {
140+ applog(LOG_WARNING,
141+ "Icarus Read: No data in %d seconds",
142+ ICARUS_READ_FAULT_COUNT);
143+ break;
144+ }
145+ }
146+}
147+
148+static void icarus_write(int fd, const void *buf, size_t bufLen)
149+{
150+ ssize_t ret;
151+
152+ ret = write(fd, buf, bufLen);
153+ if (unlikely(ret != bufLen))
154+ quit(1, "Icarus: Send data failed!");
155+}
156+
157+#define icarus_close(fd) close(fd)
158+
159+static bool icarus_detect_one(const char *devpath)
160+{
161+ int fd;
162+ static int i = 0;
163+
164+ const unsigned char golden_ob[] =
165+ "2db907f9cb4eb938ded904f4832c4331"
166+ "0380e3aeb54364057e7fec5157bfc533"
167+ "00000000000000000000000080000000"
168+ "00000000a58e091ac342724e7c3dc346";
169+ const unsigned char golden_nonce[] = "063c5e01";
170+
171+ char ob_bin[64], nonce_bin[4];
172+ char *nonce_hex;
173+
174+ if (total_devices == MAX_DEVICES)
175+ return false;
176+
177+ fd = icarus_open(devpath);
178+ if (unlikely(fd == -1)) {
179+ applog(LOG_ERR, "Icarus Detect: Failed to open %s", devpath);
180+ return false;
181+ }
182+
183+ hex2bin(ob_bin, golden_ob, sizeof(ob_bin));
184+ icarus_write(fd, ob_bin, sizeof(ob_bin));
185+
186+ memset(nonce_bin, 0, sizeof(nonce_bin));
187+ icarus_gets(nonce_bin, sizeof(nonce_bin), fd);
188+
189+ icarus_close(fd);
190+
191+ nonce_hex = bin2hex(nonce_bin, sizeof(nonce_bin));
192+ if (nonce_hex) {
193+ if (strncmp(nonce_hex, golden_nonce, 8)) {
194+ applog(LOG_ERR,
195+ "Icarus Detect: "
196+ "Test failed at %s : get %s, should: %s",
197+ devpath, nonce_hex, golden_nonce);
198+ free(nonce_hex);
199+ return false;
200+ }
201+ free(nonce_hex);
202+ } else
203+ return false;
204+
205+ /* We have a real Icarus! */
206+ struct cgpu_info *icarus;
207+ icarus = calloc(1, sizeof(*icarus));
208+ devices[total_devices++] = icarus;
209+ icarus->api = &icarus_api;
210+ icarus->device_id = i++;
211+ icarus->device_path = strdup(devpath);
212+ icarus->threads = 1;
213+
214+ return true;
215+}
216+
217+static void icarus_detect()
218+{
219+ struct string_elist *iter, *tmp;
220+
221+ list_for_each_entry_safe(iter, tmp, &scan_devices, list) {
222+ if (icarus_detect_one(iter->string))
223+ string_elist_del(iter);
224+ }
225+}
226+
227+static bool icarus_thread_prepare(struct thr_info *thr)
228+{
229+ struct cgpu_info *icarus = thr->cgpu;
230+
231+ struct timeval now;
232+
233+ int fd = icarus_open(icarus->device_path);
234+ if (unlikely(-1 == fd)) {
235+ applog(LOG_ERR, "Failed to open Icarus on %s",
236+ icarus->device_path);
237+ return false;
238+ }
239+
240+ icarus->device_fd = fd;
241+
242+ applog(LOG_INFO, "Opened Icarus on %s", icarus->device_path);
243+ gettimeofday(&now, NULL);
244+ get_datestamp(icarus->init, &now);
245+
246+ return true;
247+}
248+
249+static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
250+ uint64_t max_nonce)
251+{
252+ struct cgpu_info *icarus;
253+ int fd;
254+
255+ unsigned char ob_bin[64], nonce_bin[4];
256+ unsigned char *ob_hex, *nonce_hex;
257+ uint32_t nonce;
258+ uint32_t hash_count;
259+ time_t t;
260+
261+ icarus = thr->cgpu;
262+ fd = icarus->device_fd;
263+
264+ memset(ob_bin, 0, sizeof(ob_bin));
265+ memcpy(ob_bin, work->midstate, 32);
266+ memcpy(ob_bin + 52, work->data + 64, 12);
267+ rev(ob_bin, 32);
268+ rev(ob_bin + 52, 12);
269+#ifndef WIN32
270+ tcflush(fd, TCOFLUSH);
271+#endif
272+ icarus_write(fd, ob_bin, sizeof(ob_bin));
273+
274+ ob_hex = bin2hex(ob_bin, sizeof(ob_bin));
275+ if (ob_hex) {
276+ t = time(NULL);
277+ applog(LOG_DEBUG, "Icarus send : %s", ob_hex);
278+ free(ob_hex);
279+ }
280+
281+ /* Icarus will return 8 bytes nonces or nothing */
282+ memset(nonce_bin, 0, sizeof(nonce_bin));
283+ icarus_gets(nonce_bin, sizeof(nonce_bin), fd);
284+
285+ nonce_hex = bin2hex(nonce_bin, sizeof(nonce_bin));
286+ if (nonce_hex) {
287+ t = time(NULL) - t;
288+ applog(LOG_DEBUG, "Icarus return (elapse %d seconds): %s",
289+ t, nonce_hex);
290+ free(nonce_hex);
291+ }
292+
293+ memcpy((char *)&nonce, nonce_bin, sizeof(nonce_bin));
294+
295+ if (nonce == 0 && icarus_read_count == ICARUS_READ_FAULT_COUNT)
296+ return 0xffffffff;
297+
298+#ifndef __BIG_ENDIAN__
299+ nonce = swab32(nonce);
300+#endif
301+ work->blk.nonce = 0xffffffff;
302+ submit_nonce(thr, work, nonce);
303+
304+ hash_count = (nonce & 0x7fffffff);
305+ if (hash_count == 0)
306+ hash_count = 2;
307+ else {
308+ if (hash_count++ == 0x7fffffff)
309+ hash_count = 0xffffffff;
310+ else
311+ hash_count <<= 1;
312+ }
313+
314+ return hash_count;
315+}
316+
317+struct device_api icarus_api = {
318+ .name = "Icarus",
319+ .api_detect = icarus_detect,
320+ .thread_prepare = icarus_thread_prepare,
321+ .scanhash = icarus_scanhash,
322+};
323--
3241.7.5.4
325
cgminer/patches/0002-add-icarus.c-base-on-bitforce.c.patch
1From 80451867b6eeeb79e02d639171999d99069bb27f Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Mon, 13 Feb 2012 16:04:34 +0800
4Subject: [PATCH 2/6] add icarus.c, base on bitforce.c
5
6
7Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
8 icarus.c | 268 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 1 files changed, 268 insertions(+), 0 deletions(-)
10 create mode 100644 icarus.c
11
12diff --git a/icarus.c b/icarus.c
13new file mode 100644
14index 0000000..141d639
15+++ b/icarus.c
16@@ -0,0 +1,268 @@
17+/*
18+ * Copyright 2012 Luke Dashjr
19+ * Copyright 2012 Xiangfu <xiangfu@openmobilefree.com>
20+ *
21+ * This program is free software; you can redistribute it and/or modify it
22+ * under the terms of the GNU General Public License as published by the Free
23+ * Software Foundation; either version 2 of the License, or (at your option)
24+ * any later version. See COPYING for more details.
25+ */
26+
27+#include <limits.h>
28+#include <pthread.h>
29+#include <stdio.h>
30+#include <sys/time.h>
31+#include <sys/types.h>
32+#include <dirent.h>
33+#include <unistd.h>
34+#ifndef WIN32
35+ #include <termios.h>
36+ #include <sys/stat.h>
37+ #include <fcntl.h>
38+ #ifndef O_CLOEXEC
39+ #define O_CLOEXEC 0
40+ #endif
41+#else
42+ #include <windows.h>
43+ #include <io.h>
44+#endif
45+
46+#include "elist.h"
47+#include "miner.h"
48+
49+#define ICARUS_READ_FAULT_COUNT (8)
50+
51+struct device_api icarus_api;
52+
53+static void rev(char *s, ssize_t l)
54+{
55+ int i, j;
56+ char t;
57+
58+ for(i = 0, j = l - 1; i < j; i++, j--) {
59+ t = s[i];
60+ s[i] = s[j];
61+ s[j] = t;
62+ }
63+}
64+
65+static int icarus_open(const char *devpath)
66+{
67+#ifndef WIN32
68+ struct termios my_termios;
69+
70+ int serialfd = open(devpath, O_RDWR | O_CLOEXEC | O_NOCTTY);
71+
72+ if(serialfd == -1)
73+ return -1;
74+
75+ tcgetattr(serialfd, &my_termios);
76+ my_termios.c_cflag = B115200;
77+ my_termios.c_cflag |= CS8;
78+ my_termios.c_cflag |= CREAD;
79+ my_termios.c_cflag |= CLOCAL;
80+ my_termios.c_cflag &= ~(CSIZE | PARENB);
81+
82+ my_termios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
83+ my_termios.c_oflag &= ~OPOST;
84+ my_termios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
85+ my_termios.c_cc[VTIME] = 10; /* block 1 second */
86+ my_termios.c_cc[VMIN] = 0;
87+ tcsetattr(serialfd, TCSANOW, &my_termios);
88+
89+ tcflush(serialfd, TCOFLUSH);
90+ tcflush(serialfd, TCIFLUSH);
91+
92+ return serialfd;
93+#else
94+ HANDLE hSerial = CreateFile(devpath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
95+ if (unlikely(hSerial == INVALID_HANDLE_VALUE))
96+ return -1;
97+ return _open_osfhandle((LONG)hSerial, 0);
98+#endif
99+}
100+
101+static void icarus_gets(char *buf, size_t bufLen, int fd)
102+{
103+ int ret = 0, count = 0;
104+
105+ while (bufLen) {
106+ ret = read(fd, buf, 1);
107+ if(ret == 1) {
108+ bufLen--;
109+ buf++;
110+ }
111+ count++;
112+ if(count == ICARUS_READ_FAULT_COUNT)
113+ break;
114+ }
115+}
116+
117+static void icarus_write(int fd, const void *buf, size_t bufLen)
118+{
119+ ssize_t ret = write(fd, buf, bufLen);
120+ if (unlikely(ret != bufLen))
121+ quit(1, "icarus_write failed");
122+}
123+
124+#define icarus_close(fd) close(fd)
125+
126+static bool icarus_detect_one(const char *devpath)
127+{
128+ static int i = 0;
129+
130+ const char ob[128] =
131+"ce92099c5a80bb81c52990d5c0924c625fd25a535640607d5a4bdf8174e2c8d500000000000000000000000080000000000000000b290c1a42313b4f21b5bcb8";
132+ const char nonce[] = "8e0b31c5";
133+ char ob_bin[64];
134+ char pdevbuf[4];
135+ int fdDev;
136+ char *nonce_hex;
137+
138+ if (total_devices == MAX_DEVICES)
139+ return false;
140+
141+ fdDev = icarus_open(devpath);
142+ if (unlikely(fdDev == -1)) {
143+ applog(LOG_ERR, "Icarus Detect: Failed to open %s", devpath);
144+ return false;
145+ }
146+
147+ hex2bin(ob_bin, ob, sizeof(ob_bin));
148+ icarus_write(fdDev, ob_bin, sizeof(ob_bin));
149+
150+ memset(pdevbuf, 0, sizeof(pdevbuf));
151+ icarus_gets(pdevbuf, sizeof(pdevbuf), fdDev);
152+
153+ icarus_close(fdDev);
154+
155+ nonce_hex = bin2hex(pdevbuf, sizeof(pdevbuf));
156+ if(strncmp(nonce_hex, nonce, 8)) {
157+ applog(LOG_DEBUG, "Icarus Detect: Test failed at %s : get %s, should: %s",
158+ devpath, nonce_hex, nonce);
159+ return false;
160+ }
161+ free(nonce_hex);
162+
163+ /* We have a real Icarus! */
164+ struct cgpu_info *icarus;
165+ icarus = calloc(1, sizeof(*icarus));
166+ devices[total_devices++] = icarus;
167+ icarus->api = &icarus_api;
168+ icarus->device_id = i++;
169+ icarus->device_path = strdup(devpath);
170+ icarus->enabled = true;
171+ icarus->threads = 1;
172+
173+ return true;
174+}
175+
176+static void icarus_detect_auto()
177+{
178+#ifndef WIN32
179+ DIR *D;
180+ struct dirent *de;
181+ const char udevdir[] = "/dev/serial/by-id";
182+ char devpath[sizeof(udevdir) + 1 + NAME_MAX];
183+ char *devfile = devpath + sizeof(udevdir);
184+
185+ D = opendir(udevdir);
186+ if (!D)
187+ return;
188+ memcpy(devpath, udevdir, sizeof(udevdir) - 1);
189+ devpath[sizeof(udevdir) - 1] = '/';
190+ while ( (de = readdir(D)) ) {
191+ /* Icarus using a PL2303 usb-serial chip */
192+ if (!strstr(de->d_name, "Prolific_Technology_Inc"))
193+ continue;
194+ strcpy(devfile, de->d_name);
195+ icarus_detect_one(devpath);
196+ }
197+ closedir(D);
198+#endif
199+}
200+
201+static void icarus_detect()
202+{
203+ struct string_elist *iter, *tmp;
204+
205+ list_for_each_entry_safe(iter, tmp, &scan_devices, list) {
206+ if (icarus_detect_one(iter->string))
207+ string_elist_del(iter);
208+ }
209+
210+ icarus_detect_auto();
211+}
212+
213+static pthread_mutex_t hash_lock;
214+
215+static bool icarus_thread_prepare(struct thr_info *thr)
216+{
217+ struct cgpu_info *icarus = thr->cgpu;
218+
219+ struct timeval now;
220+
221+ int fdDev = icarus_open(icarus->device_path);
222+ if (unlikely(-1 == fdDev)) {
223+ applog(LOG_ERR, "Failed to open Icarus on %s", icarus->device_path);
224+ return false;
225+ }
226+
227+ icarus->device_fd = fdDev;
228+
229+ applog(LOG_INFO, "Opened Icarus on %s", icarus->device_path);
230+ gettimeofday(&now, NULL);
231+ get_datestamp(icarus->init, &now);
232+
233+ mutex_init(&hash_lock);
234+ return true;
235+}
236+
237+static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work, uint64_t max_nonce)
238+{
239+ struct cgpu_info *icarus = thr->cgpu;
240+ int fdDev = icarus->device_fd;
241+
242+ char pdevbuf[4];
243+ unsigned char ob[64];
244+ uint32_t nonce;
245+ char *ob_hex, *nonce_hex;
246+
247+ mutex_lock(&hash_lock);
248+
249+ memcpy(ob, work->midstate, 32);
250+ memcpy(ob + 32, work->data + 64, 32);
251+ rev(ob, 32);
252+ rev(ob + 32, 32);
253+
254+ icarus_write(fdDev, ob, sizeof(ob));
255+
256+ ob_hex = bin2hex(ob, sizeof(ob));
257+ applog(LOG_DEBUG, "Icarus Send: %s", ob_hex);
258+ free(ob_hex);
259+
260+ memset(pdevbuf, 0, sizeof(pdevbuf));
261+ icarus_gets(pdevbuf, sizeof(pdevbuf), fdDev);
262+
263+ nonce_hex = bin2hex(pdevbuf, sizeof(pdevbuf));
264+ applog(LOG_DEBUG, "Icarus Return: %s", nonce_hex);
265+ free(nonce_hex);
266+
267+ work->blk.nonce = 0xffffffff;
268+
269+ memcpy((char *)&nonce, pdevbuf, sizeof(pdevbuf));
270+#ifndef __BIG_ENDIAN__
271+ nonce = swab32(nonce);
272+#endif
273+ submit_nonce(thr, work, nonce);
274+
275+ mutex_unlock(&hash_lock);
276+ return 0xffffffff;
277+}
278+
279+struct device_api icarus_api = {
280+ .name = "Icarus",
281+ .api_detect = icarus_detect,
282+ .thread_prepare = icarus_thread_prepare,
283+ .scanhash = icarus_scanhash,
284+};
2851.7.5.4
286
cgminer/patches/0002-add-shutdown-function.patch
1From 706c4de11159e06284b70cc1d12ba9c2cbcbb684 Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Sun, 19 Feb 2012 21:31:58 +0800
4Subject: [PATCH 2/7] add shutdown function
5
6---
7 icarus.c | 42 ++++++++++++++++++++++++++++++++++--------
8 1 files changed, 34 insertions(+), 8 deletions(-)
9
10diff --git a/icarus.c b/icarus.c
11index 56b8d8a..5562e5e 100644
12--- a/icarus.c
13@@ -52,7 +52,9 @@
14
15 #define ICARUS_READ_FAULT_COUNT (8)
16
17-int icarus_read_count;
18+static int icarus_read_count;
19+static int icarus_write_fault;
20+
21 struct device_api icarus_api;
22
23 static void rev(unsigned char *s, size_t l)
24@@ -136,7 +138,7 @@ static void icarus_write(int fd, const void *buf, size_t bufLen)
25
26     ret = write(fd, buf, bufLen);
27     if (unlikely(ret != bufLen))
28- quit(1, "Icarus: Send data failed!");
29+ icarus_write_fault = 1;
30 }
31
32 #define icarus_close(fd) close(fd)
33@@ -144,7 +146,6 @@ static void icarus_write(int fd, const void *buf, size_t bufLen)
34 static bool icarus_detect_one(const char *devpath)
35 {
36     int fd;
37- static int i = 0;
38
39     const unsigned char golden_ob[] =
40         "2db907f9cb4eb938ded904f4832c4331"
41@@ -189,12 +190,14 @@ static bool icarus_detect_one(const char *devpath)
42
43     /* We have a real Icarus! */
44     struct cgpu_info *icarus;
45- icarus = calloc(1, sizeof(*icarus));
46- devices[total_devices++] = icarus;
47+ icarus = calloc(1, sizeof(struct cgpu_info));
48     icarus->api = &icarus_api;
49- icarus->device_id = i++;
50+ icarus->device_id = total_devices;
51     icarus->device_path = strdup(devpath);
52     icarus->threads = 1;
53+ devices[total_devices++] = icarus;
54+
55+ icarus_write_fault = 0;
56
57     return true;
58 }
59@@ -209,7 +212,7 @@ static void icarus_detect()
60     }
61 }
62
63-static bool icarus_thread_prepare(struct thr_info *thr)
64+static bool icarus_prepare(struct thr_info *thr)
65 {
66     struct cgpu_info *icarus = thr->cgpu;
67
68@@ -255,6 +258,8 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
69     tcflush(fd, TCOFLUSH);
70 #endif
71     icarus_write(fd, ob_bin, sizeof(ob_bin));
72+ if (icarus_write_fault)
73+ return 0; /* This should never happen */
74
75     ob_hex = bin2hex(ob_bin, sizeof(ob_bin));
76     if (ob_hex) {
77@@ -299,9 +304,30 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
78         return hash_count;
79 }
80
81+static void icarus_shutdown(struct thr_info *thr)
82+{
83+ struct cgpu_info *icarus;
84+ int fd;
85+
86+ if (thr->cgpu) {
87+ icarus = thr->cgpu;
88+
89+ if (icarus->device_path)
90+ free(icarus->device_path);
91+
92+ close(icarus->device_fd);
93+
94+ devices[icarus->device_id] = NULL;
95+ free(icarus);
96+
97+ thr->cgpu = NULL;
98+ }
99+}
100+
101 struct device_api icarus_api = {
102     .name = "Icarus",
103     .api_detect = icarus_detect,
104- .thread_prepare = icarus_thread_prepare,
105+ .thread_prepare = icarus_prepare,
106     .scanhash = icarus_scanhash,
107+ .thread_shutdown = icarus_shutdown,
108 };
109--
1101.7.5.4
111
cgminer/patches/0003-add-icarus-to-cgminer.c.patch
1From fdcf21974b9b9d1b2d92ccad6b16eadf023515fc Mon Sep 17 00:00:00 2001
1From f46c2b28a0d50a026354013ead0963ce4248ef4e Mon Sep 17 00:00:00 2001
22From: Xiangfu <xiangfu@openmobilefree.net>
33Date: Mon, 13 Feb 2012 16:09:45 +0800
4Subject: [PATCH 3/6] add icarus to cgminer.c
4Subject: [PATCH 3/7] add icarus to cgminer.c
55
6
7Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
86---
9 cgminer.c | 17 ++++++++++++++---
10 1 files changed, 14 insertions(+), 3 deletions(-)
7 cgminer.c | 19 +++++++++++++++----
8 1 files changed, 15 insertions(+), 4 deletions(-)
119
1210diff --git a/cgminer.c b/cgminer.c
13index 596a21a..cea6f59 100644
11index 8264db5..3bd4eb0 100644
1412--- a/cgminer.c
1513+++ b/cgminer.c
16@@ -400,7 +400,7 @@ static char *set_int_1_to_10(const char *arg, int *i)
14@@ -399,7 +399,7 @@ static char *set_int_1_to_10(const char *arg, int *i)
1715     return set_int_range(arg, i, 1, 10);
1816 }
1917
...... 
2220 static char *add_serial(char *arg)
2321 {
2422     string_elist_add(arg, &scan_devices);
25@@ -662,7 +662,7 @@ static struct opt_table opt_config_table[] = {
23@@ -661,7 +661,7 @@ static struct opt_table opt_config_table[] = {
2624     OPT_WITHOUT_ARG("--disable-gpu|-G",
2725             opt_set_bool, &opt_nogpu,
2826             "Disable GPU mining even if suitable devices exist"),
...... 
3129     OPT_WITHOUT_ARG("--enable-cpu|-C",
3230             opt_set_bool, &opt_usecpu,
3331             "Enable CPU mining with other mining (default: no CPU mining if other devices exist)"),
34@@ -777,7 +777,7 @@ static struct opt_table opt_config_table[] = {
32@@ -776,10 +776,10 @@ static struct opt_table opt_config_table[] = {
3533     OPT_WITHOUT_ARG("--round-robin",
3634              set_rr, &pool_strategy,
3735              "Change multipool strategy from failover to round robin on failure"),
3836-#ifdef USE_BITFORCE
39+#if defined(USE_BITFORCE) || (defined(USE_ICARUS) && defined(WIN32))
37+#if defined(USE_BITFORCE) || defined(USE_ICARUS)
4038     OPT_WITH_ARG("--scan-serial|-S",
4139              add_serial, NULL, NULL,
42              "Serial port to probe for BitForce device"),
43@@ -962,6 +962,9 @@ static char *opt_verusage_and_exit(const char *extra)
40- "Serial port to probe for BitForce device"),
41+ "Serial port to probe for FPGA Mining device"),
42 #endif
43     OPT_WITH_ARG("--scan-time|-s",
44              set_int_0_to_9999, opt_show_intval, &opt_scantime,
45@@ -961,6 +961,9 @@ static char *opt_verusage_and_exit(const char *extra)
4446 #ifdef USE_BITFORCE
4547         "bitforce "
4648 #endif
...... 
5052         "mining support.\n"
5153         , packagename);
5254     printf("%s", opt_usage(opt_argv0, extra));
53@@ -4117,6 +4120,10 @@ struct device_api cpu_api = {
55@@ -4153,6 +4156,10 @@ struct device_api cpu_api = {
5456 extern struct device_api bitforce_api;
5557 #endif
5658
...... 
6163
6264 static int cgminer_id_count = 0;
6365
64@@ -4271,6 +4278,10 @@ int main (int argc, char *argv[])
66@@ -4307,6 +4314,10 @@ int main (int argc, char *argv[])
6567     bitforce_api.api_detect();
6668 #endif
6769
cgminer/patches/0004-add-Icarus-support-to-autoreconf-system.patch
1From 2bb92ebcdc4612d218e965b8f6f6f22b6b3ff21d Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Mon, 13 Feb 2012 16:04:13 +0800
4Subject: [PATCH 4/7] add Icarus support to autoreconf system
5
6---
7 Makefile.am | 3 +++
8 configure.ac | 21 +++++++++++++++++++--
9 2 files changed, 22 insertions(+), 2 deletions(-)
10
11diff --git a/Makefile.am b/Makefile.am
12index 4249d51..5262d52 100644
13--- a/Makefile.am
14@@ -70,3 +70,6 @@ if HAS_BITFORCE
15 cgminer_SOURCES += bitforce.c
16 endif
17
18+if HAS_ICARUS
19+cgminer_SOURCES += icarus.c
20+endif
21diff --git a/configure.ac b/configure.ac
22index d2fdbb4..ce89c6f 100644
23--- a/configure.ac
24@@ -196,6 +196,17 @@ if test "x$bitforce" = xyes; then
25 fi
26 AM_CONDITIONAL([HAS_BITFORCE], [test x$bitforce = xyes])
27
28+icarus="no"
29+
30+AC_ARG_ENABLE([icarus],
31+ [AC_HELP_STRING([--enable-icarus],[Compile support for Icarus (default disabled)])],
32+ [icarus=$enableval]
33+ )
34+if test "x$icarus" = xyes; then
35+ AC_DEFINE([USE_ICARUS], [1], [Defined to 1 if Icarus support is wanted])
36+fi
37+AM_CONDITIONAL([HAS_ICARUS], [test x$icarus = xyes])
38+
39 AC_SEARCH_LIBS(addstr, ncurses pdcurses, ,
40         AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev]))
41
42@@ -338,13 +349,13 @@ if test "x$opencl" != xno; then
43         echo " OpenCL...............: FOUND. GPU mining support enabled"
44     else
45         echo " OpenCL...............: NOT FOUND. GPU mining support DISABLED"
46- if test "x$cpumining$bitforce" = xnono; then
47+ if test "x$cpumining$bitforce$icarus" = xnonono; then
48             AC_MSG_ERROR([No mining configured in])
49         fi
50     fi
51 else
52     echo " OpenCL...............: Detection overrided. GPU mining support DISABLED"
53- if test "x$cpumining$bitforce" = xnono; then
54+ if test "x$cpumining$bitforce$icarus" = xnonono; then
55         AC_MSG_ERROR([No mining configured in])
56     fi
57 fi
58@@ -366,6 +377,12 @@ else
59     echo " BitForce.FPGAs.......: Disabled"
60 fi
61
62+if test "x$icarus" = xyes; then
63+ echo " Icarus.FPGAs.........: Enabled"
64+else
65+ echo " Icarus.FPGAs.........: Disabled"
66+fi
67+
68 echo
69 if test "x$cpumining" = xyes; then
70     echo " CPU Mining...........: Enabled"
71--
721.7.5.4
73
cgminer/patches/0004-update-the-message-fit-both-bitforce-and-Icarus.patch
1From aed89bc1d85f6d4dc0834f850730894571ed9e71 Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Tue, 14 Feb 2012 00:02:06 +0800
4Subject: [PATCH 4/6] update the message fit both bitforce and Icarus
5
6
7Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
8 cgminer.c | 2 +-
9 1 files changed, 1 insertions(+), 1 deletions(-)
10
11diff --git a/cgminer.c b/cgminer.c
12index cea6f59..bfb8399 100644
13+++ b/cgminer.c
14@@ -780,7 +780,7 @@ static struct opt_table opt_config_table[] = {
15 #if defined(USE_BITFORCE) || (defined(USE_ICARUS) && defined(WIN32))
16     OPT_WITH_ARG("--scan-serial|-S",
17              add_serial, NULL, NULL,
18- "Serial port to probe for BitForce device"),
19+ "Serial port to probe for FPGA Mining device"),
20 #endif
21     OPT_WITH_ARG("--scan-time|-s",
22              set_int_0_to_9999, opt_show_intval, &opt_scantime,
231.7.5.4
24
cgminer/patches/0005-update-README-for-Icarus.patch
1From 5ae847013d58990a1686d2875b768945c65a2f6e Mon Sep 17 00:00:00 2001
1From beaf158a409920ab436cef749b997f487e0225b9 Mon Sep 17 00:00:00 2001
22From: Xiangfu <xiangfu@openmobilefree.net>
33Date: Tue, 14 Feb 2012 00:01:20 +0800
4Subject: [PATCH 5/6] update README for Icarus
4Subject: [PATCH 5/7] update README for Icarus
55
6
7Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
86---
9 README | 6 ++++++
10 1 files changed, 6 insertions(+), 0 deletions(-)
7 README | 5 +++--
8 1 files changed, 3 insertions(+), 2 deletions(-)
119
1210diff --git a/README b/README
13index f3c0a26..0ef1b9f 100644
11index f3c0a26..30cf037 100644
1412--- a/README
1513+++ b/README
1614@@ -50,6 +50,7 @@ CGMiner specific configuration options:
...... 
2119
2220 Basic *nix build instructions:
2321     To build with GPU mining support:
24@@ -198,6 +199,11 @@ BitForce only options:
25 --scan-serial|-S <arg> Serial port to probe for BitForce device
22@@ -193,9 +194,9 @@ GPU only options:
23 --ndevs|-n Enumerate number of detected GPUs and exit
2624
2725
28+Icarus only options(only under Windows system):
29+
30+--scan-serial|-S <arg> Serial port to probe for Icarus device
31+
32+
33 CPU only options:
26-BitForce only options:
27+FPGA mining boards(BitForce, Icarus) only options:
28
29---scan-serial|-S <arg> Serial port to probe for BitForce device
30+--scan-serial|-S <arg> Serial port to probe for FPGA mining device
3431
35 --algo|-a <arg> Specify sha256 implementation for CPU mining:
32
33 CPU only options:
3634--
37351.7.5.4
3836
cgminer/patches/0006-add-shortcut-to-description-for-easy-grep.patch
1From 867a939c012ffcdbff018625c76571a588642662 Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Wed, 15 Feb 2012 12:43:25 +0800
4Subject: [PATCH 6/6] add shortcut to description for easy grep
5
6
7Signed-off-by: Xiangfu <xiangfu@openmobilefree.net>
8 README | 16 ++++++++--------
9 1 files changed, 8 insertions(+), 8 deletions(-)
10
11diff --git a/README b/README
12index 0ef1b9f..174882a 100644
13+++ b/README
14@@ -320,14 +320,14 @@ The output line shows the following:
15 (5s):1713.6 (avg):1707.8 Mh/s | Q:301 A:729 R:8 HW:0 E:242% U:22.53/m
16
17 Each column is as follows:
18-A 5 second exponentially decaying average hash rate
19-An all time average hash rate
20-The number of requested (Queued) work items from the pools
21-The number of Accepted shares
22-The number of Rejected shares
23-The number of HardWare errors
24-The Efficiency defined as number of shares returned / work item
25-The Utility defined as the number of shares / minute
26+5s: A 5 second exponentially decaying average hash rate
27+avg: An all time average hash rate
28+Q: The number of requested (Queued) work items from the pools
29+A: The number of Accepted shares
30+R: The number of Rejected shares
31+HW: The number of HardWare errors
32+E: The Efficiency defined as number of shares returned / work item
33+U: The Utility defined as the number of shares / minute
34
35  GPU 1: 73.5C 2551RPM | 427.3/443.0Mh/s | A:8 R:0 HW:0 U:4.39/m
36
371.7.5.4
38
cgminer/patches/0006-add-shortcuts-to-description-for-easy-grep.patch
1From dfead150f78fcaa5b052c791b6ee0ee8f2939b1c Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Wed, 15 Feb 2012 12:43:25 +0800
4Subject: [PATCH 6/7] add shortcuts to description for easy grep
5
6---
7 README | 16 ++++++++--------
8 1 files changed, 8 insertions(+), 8 deletions(-)
9
10diff --git a/README b/README
11index 30cf037..d801a9a 100644
12--- a/README
13@@ -315,14 +315,14 @@ The output line shows the following:
14 (5s):1713.6 (avg):1707.8 Mh/s | Q:301 A:729 R:8 HW:0 E:242% U:22.53/m
15
16 Each column is as follows:
17-A 5 second exponentially decaying average hash rate
18-An all time average hash rate
19-The number of requested (Queued) work items from the pools
20-The number of Accepted shares
21-The number of Rejected shares
22-The number of HardWare errors
23-The Efficiency defined as number of shares returned / work item
24-The Utility defined as the number of shares / minute
25+5s: A 5 second exponentially decaying average hash rate
26+avg: An all time average hash rate
27+Q: The number of requested (Queued) work items from the pools
28+A: The number of Accepted shares
29+R: The number of Rejected shares
30+HW: The number of HardWare errors
31+E: The Efficiency defined as number of shares returned / work item
32+U: The Utility defined as the number of shares / minute
33
34  GPU 1: 73.5C 2551RPM | 427.3/443.0Mh/s | A:8 R:0 HW:0 U:4.39/m
35
36--
371.7.5.4
38
cgminer/patches/0007-add-MIPSED-to-icarus-for-BIG_ENDIAN.patch.patch
1From 83df54b91b99aad744e0f62431d6f3ceecd0ac51 Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Sun, 19 Feb 2012 22:20:22 +0800
4Subject: [PATCH 7/7] add-MIPSED-to-icarus-for-BIG_ENDIAN.patch
5
6---
7 icarus.c | 2 +-
8 1 files changed, 1 insertions(+), 1 deletions(-)
9
10diff --git a/icarus.c b/icarus.c
11index 5562e5e..73cd4de 100644
12--- a/icarus.c
13@@ -285,7 +285,7 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
14         if (nonce == 0 && icarus_read_count == ICARUS_READ_FAULT_COUNT)
15                 return 0xffffffff;
16
17-#ifndef __BIG_ENDIAN__
18+#if !defined (__BIG_ENDIAN__) && !defined(MIPSEB)
19     nonce = swab32(nonce);
20 #endif
21     work->blk.nonce = 0xffffffff;
22--
231.7.5.4
24
cgminer/patches/0007-remove-icarus-detect-auto.-Icarus-should-configure-t.patch
1From 46143d76539752dc929da18fed74301008c75184 Mon Sep 17 00:00:00 2001
2From: Xiangfu <xiangfu@openmobilefree.net>
3Date: Fri, 17 Feb 2012 11:19:44 +0800
4Subject: [PATCH] remove icarus detect auto. Icarus should configure the
5 pl2303 eeprom for this
6
7 cgminer.c | 2 +-
8 icarus.c | 27 ---------------------------
9 2 files changed, 1 insertions(+), 28 deletions(-)
10
11diff --git a/cgminer.c b/cgminer.c
12index bfb8399..c97f276 100644
13+++ b/cgminer.c
14@@ -777,7 +777,7 @@ static struct opt_table opt_config_table[] = {
15     OPT_WITHOUT_ARG("--round-robin",
16              set_rr, &pool_strategy,
17              "Change multipool strategy from failover to round robin on failure"),
18-#if defined(USE_BITFORCE) || (defined(USE_ICARUS) && defined(WIN32))
19+#if defined(USE_BITFORCE) || defined(USE_ICARUS)
20     OPT_WITH_ARG("--scan-serial|-S",
21              add_serial, NULL, NULL,
22              "Serial port to probe for FPGA Mining device"),
23diff --git a/icarus.c b/icarus.c
24index 141d639..1f8ab52 100644
25+++ b/icarus.c
26@@ -157,31 +157,6 @@ static bool icarus_detect_one(const char *devpath)
27     return true;
28 }
29
30-static void icarus_detect_auto()
31-{
32-#ifndef WIN32
33- DIR *D;
34- struct dirent *de;
35- const char udevdir[] = "/dev/serial/by-id";
36- char devpath[sizeof(udevdir) + 1 + NAME_MAX];
37- char *devfile = devpath + sizeof(udevdir);
38-
39- D = opendir(udevdir);
40- if (!D)
41- return;
42- memcpy(devpath, udevdir, sizeof(udevdir) - 1);
43- devpath[sizeof(udevdir) - 1] = '/';
44- while ( (de = readdir(D)) ) {
45- /* Icarus using a PL2303 usb-serial chip */
46- if (!strstr(de->d_name, "Prolific_Technology_Inc"))
47- continue;
48- strcpy(devfile, de->d_name);
49- icarus_detect_one(devpath);
50- }
51- closedir(D);
52-#endif
53-}
54-
55 static void icarus_detect()
56 {
57     struct string_elist *iter, *tmp;
58@@ -190,8 +165,6 @@ static void icarus_detect()
59         if (icarus_detect_one(iter->string))
60             string_elist_del(iter);
61     }
62-
63- icarus_detect_auto();
64 }
65
66 static pthread_mutex_t hash_lock;
671.7.5.4
68
cgminer/patches/0008-add-MIPSED-to-icarus-for-BIG_ENDIAN.patch
1diff --git a/icarus.c b/icarus.c
2index 141d639..2e89a86 100644
3+++ b/icarus.c
4@@ -251,7 +251,7 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work, uint64_
5     work->blk.nonce = 0xffffffff;
6
7     memcpy((char *)&nonce, pdevbuf, sizeof(pdevbuf));
8-#ifndef __BIG_ENDIAN__
9+#if !defined (__BIG_ENDIAN__) && !defined(MIPSEB)
10     nonce = swab32(nonce);
11 #endif
12     submit_nonce(thr, work, nonce);

Archive Download the corresponding diff file



interactive