Commit 167b787ec51962b6a33b59ab7d4b24a8ac162ff1

kanoi 2014-04-26T17:14:02

Merge remote-tracking branch 'conman/master'

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
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
diff --git a/Makefile.am b/Makefile.am
index 658bfa2..573b8d5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -104,6 +104,11 @@ if HAS_COINTERRA
 cgminer_SOURCES += driver-cointerra.c driver-cointerra.h
 endif
 
+if HAS_SPONDOOLIES
+cgminer_SOURCES += driver-spondoolies.c driver-spondoolies.h \
+		   mg_proto_parser.c mg_proto_parser.h
+endif
+
 if HAS_BAB
 cgminer_SOURCES += driver-bab.c
 endif
diff --git a/NEWS b/NEWS
index 8940299..eec6a3d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,38 @@
+Version 4.3.0 - 18th April 2014
+
+- Put sleep in spond hash instead of queue full function
+- Remove unused function for when compiled without curses
+- Fix typo
+- Add temperature rate, front, rear and device temperature to spond API output
+- Limit bxf sleep in bxf_scan to 100ms minimum for strings of many chips
+- -Werror=format-security error on driver-bitmain.c
+- Fix parameters passed with getblockhash
+- Check the block hash with the proper command when looking for orphan chains
+- syslog requires a facility ... in more than one place
+- Shuffle windows headers included
+- Adjust the bxf sleep time according to the number of chips detected
+- Fix off by one error in bxf chip count when adjusting device size
+- Recalloc correct pointer
+- Make instructions associated with winusb error even more explicit
+- Add midsing headers to cgminer source in Makefile
+- Trivial style changes to mg proto parser
+- Trivial style and warning clean ups on spondoolies driver
+- Merge spondoolies driver patch
+- Call any BXF device with 3-6 chips reported HXF
+- Avoid derefrence when calling statline before on hfa device during init
+sequence
+- Calloc the info structures even on failed hfa reset to prevent later possible
+dereference
+- Load all hfa devices based on identification alone and defer init sequence
+till mining thread init sequence to allow all devices to be recognised rapidly
+but each device initialisation not delay others
+- Do not do thread shutdown unless thread init succeeded
+- Remove unnecessary check for thread_prepare function
+- Recognise variations on BXF based on chip value returned in responses
+- Provide helper function for recallocing memory
+- syslog requires a facility
+
+
 Version 4.2.3 - 3rd April 2014
 
 - Decay the per device hashrates when only the watchdog is calling the hashmeter
diff --git a/README b/README
index 1f93e48..7cd8478 100644
--- a/README
+++ b/README
@@ -119,23 +119,23 @@ CGMiner specific configuration options:
   --enable-bitforce       Compile support for BitForce FPGAs (default
                           disabled)
   --enable-bitfury        Compile support for BitFury ASICs (default disabled)
-  --enable-cointerra      Compile support for Cointerra ASICs (default
+  --enable-bitmine_A1     Compile support for Bitmine.ch A1 ASICs (default
                           disabled)
   --enable-drillbit       Compile support for Drillbit BitFury ASICs (default
                           disabled)
   --enable-hashfast       Compile support for Hashfast (default disabled)
   --enable-icarus         Compile support for Icarus (default disabled)
-  --enable-knc            Compile support for KnC miners (default disabled)
   --enable-klondike       Compile support for Klondike (default disabled)
   --enable-knc            Compile support for KnC miners (default disabled)
+  --enable-avalon2        Compile support for Avalon2 (default disabled)
   --enable-minion         Compile support for Minion BlackArrow ASIC (default
                           disabled)
   --enable-modminer       Compile support for ModMiner FPGAs(default disabled)
+  --enable-spondoolies    Compile support for Spondoolies (default disabled)
   --disable-libcurl       Disable building with libcurl for getwork and GBT
                           support
   --without-curses        Compile support for curses TUI (default enabled)
   --with-system-libusb    Compile against dynamic system libusb (default use
-                          included static libusb)
 
 Basic *nix build instructions:
 	To actually build:
diff --git a/api.c b/api.c
index cf12762..ef63e95 100644
--- a/api.c
+++ b/api.c
@@ -30,7 +30,7 @@
 	defined(USE_HASHFAST) || defined(USE_BITFURY) || defined(USE_KLONDIKE) || \
 	defined(USE_KNC) || defined(USE_BAB) || defined(USE_DRILLBIT) || \
 	defined(USE_MINION) || defined(USE_COINTERRA) || defined(USE_BITMINE_A1) || \
-	defined(USE_ANT_S1)
+	defined(USE_ANT_S1) || defined(USE_SPONDOOLIES)
 #define HAVE_AN_ASIC 1
 #endif
 
@@ -196,6 +196,10 @@ static const char *DEVICECODE = ""
 #ifdef USE_COINTERRA
 			"CTA "
 #endif
+#ifdef USE_SPONDOOLIES
+			"SPN "
+#endif
+
 			"";
 
 static const char *OSINFO =
diff --git a/cgminer.c b/cgminer.c
index 34c9296..f9bf561 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -76,6 +76,11 @@ char *curly = ":D";
 #include "driver-bflsc.h"
 #endif
 
+#ifdef USE_SPONDOOLIES
+#include "driver-spondoolies.h"
+#endif
+
+
 #ifdef USE_BITFURY
 #include "driver-bitfury.h"
 #endif
@@ -732,6 +737,11 @@ static char *set_int_1_to_10(const char *arg, int *i)
 	return set_int_range(arg, i, 1, 10);
 }
 
+static char __maybe_unused *set_int_0_to_4(const char *arg, int *i)
+{
+	return set_int_range(arg, i, 0, 4);
+}
+
 #ifdef USE_FPGA_SERIAL
 static char *opt_add_serial;
 static char *add_serial(char *arg)
@@ -1175,6 +1185,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--bxf-bits",
 		     set_int_32_to_63, opt_show_intval, &opt_bxf_bits,
 		     "Set max BXF/HXF bits for overclocking"),
+	OPT_WITH_ARG("--bxf-debug",
+		     set_int_0_to_4, opt_show_intval, &opt_bxf_debug,
+		    "BXF: Debug all USB I/O, > is to the board(s), < is from the board(s)"),
 	OPT_WITH_ARG("--bxf-temp-target",
 		     set_int_0_to_200, opt_show_intval, &opt_bxf_temp_target,
 		     "Set target temperature for BXF/HXF devices"),
@@ -1315,6 +1328,11 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITHOUT_ARG("--no-submit-stale",
 			opt_set_invbool, &opt_submit_stale,
 		        "Don't submit shares if they are detected as stale"),
+#ifdef USE_BITFURY
+	OPT_WITH_ARG("--osm-led-mode",
+		     set_int_0_to_4, opt_show_intval, &opt_osm_led_mode,
+		     "Set LED mode for OneStringMiner devices"),
+#endif
 	OPT_WITH_ARG("--pass|-p",
 		     set_pass, NULL, &opt_set_null,
 		     "Password for bitcoin JSON-RPC server"),
@@ -1638,6 +1656,9 @@ static char *opt_verusage_and_exit(const char *extra)
 #ifdef USE_BITMINE_A1
 		"Bitmine.A1 "
 #endif
+#ifdef USE_SPONDOOLIES
+		"spondoolies "
+#endif
 		"mining support.\n"
 		, packagename);
 	printf("%s", opt_usage(opt_argv0, extra));
@@ -2768,10 +2789,6 @@ void _wlogprint(const char *str)
 		unlock_curses();
 	}
 }
-#else
-static void switch_logsize(bool __maybe_unused newdevs)
-{
-}
 #endif
 
 #ifdef HAVE_CURSES
@@ -7707,9 +7724,8 @@ void *miner_thread(void *userdata)
 
 	cgpu->last_device_valid_work = time(NULL);
 	drv->hash_work(mythr);
-out:
 	drv->thread_shutdown(mythr);
-
+out:
 	return NULL;
 }
 
@@ -7876,6 +7892,7 @@ retry_pool:
 					continue;
 				}
 
+				sprintf(lpreq, "{\"id\": 0, \"method\": \"getblockhash\", \"params\": [%d]}\n", height);
 				get_gbt_curl(pool, 500);
 				curl_easy_setopt(pool->gbt_curl, CURLOPT_FORBID_REUSE, 1);
 				val = json_rpc_call(pool->gbt_curl, pool->rpc_url, pool->rpc_userpass,
@@ -8913,6 +8930,11 @@ bool add_cgpu(struct cgpu_info *cgpu)
 		devices[total_devices++] = cgpu;
 
 	adjust_mostdevs();
+#ifdef USE_USBUTILS
+	if (cgpu->usbdev && !cgpu->unique_id && cgpu->usbdev->serial_string &&
+	    strlen(cgpu->usbdev->serial_string) > 4)
+		cgpu->unique_id = str_text(cgpu->usbdev->serial_string);
+#endif
 	return true;
 }
 
@@ -8970,7 +8992,7 @@ static void hotplug_process(void)
 			thr->cgpu = cgpu;
 			thr->device_thread = j;
 
-			if (cgpu->drv->thread_prepare && !cgpu->drv->thread_prepare(thr)) {
+			if (!cgpu->drv->thread_prepare(thr)) {
 				null_device_drv(cgpu->drv);
 				cgpu->deven = DEV_DISABLED;
 				continue;
@@ -8996,7 +9018,9 @@ static void hotplug_process(void)
 	wr_unlock(&mining_thr_lock);
 
 	adjust_mostdevs();
+#ifdef HAVE_CURSES
 	switch_logsize(true);
+#endif
 }
 
 #define DRIVER_DRV_DETECT_HOTPLUG(X) X##_drv.drv_detect(true);
diff --git a/configure.ac b/configure.ac
index 842d6bc..5d6bb3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,8 @@
 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
 m4_define([v_maj], [4])
-m4_define([v_min], [2])
-m4_define([v_mic], [3])
+m4_define([v_min], [3])
+m4_define([v_mic], [0])
 ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
 m4_define([v_ver], [v_maj.v_min.v_mic])
 m4_define([lt_rev], m4_eval(v_maj + v_min))
@@ -304,6 +304,20 @@ if test "x$modminer" = xyes; then
 fi
 AM_CONDITIONAL([HAS_MODMINER], [test x$modminer = xyes])
 
+
+
+spondoolies="no"
+
+AC_ARG_ENABLE([spondoolies],
+	[AC_HELP_STRING([--enable-spondoolies],[Compile support for Spondoolies (default disabled)])],
+	[spondoolies=$enableval]
+	)
+if test "x$spondoolies" = xyes; then
+	AC_DEFINE([USE_SPONDOOLIES], [1], [Defined to 1 if Spondoolies support is wanted])
+fi
+AM_CONDITIONAL([HAS_SPONDOOLIES], [test x$spondoolies = xyes])
+
+
 curses="auto"
 
 AC_ARG_WITH([curses],
@@ -562,6 +576,12 @@ else
 	echo "  Cointerra.ASICs......: Disabled"
 fi
 
+if test "x$spondoolies" = xyes; then
+	echo "  Spondoolies.ASICs....: Enabled"
+else
+	echo "  Spondoolies.ASICs....: Disabled"
+fi
+
 if test "x$bitmine_A1" = xyes; then
 	echo "  Bitmine-A1.ASICs.....: Enabled"
 else
@@ -604,7 +624,7 @@ else
 	echo "  ModMiner.FPGAs.......: Disabled"
 fi
 
-if test "x$avalon$avalon2$bab$bflsc$bitforce$bitfury$hashfast$icarus$klondike$knc$modminer$drillbit$minion$cointerra$bitmine_A1$ants1" = xnononononononononononononononono; then
+if test "x$avalon$avalon2$bab$bflsc$bitforce$bitfury$hashfast$icarus$klondike$knc$modminer$drillbit$minion$cointerra$bitmine_A1$ants1$spondoolies" = xnonononononononononononononononono; then
 	AC_MSG_ERROR([No mining configured in])
 fi
 
diff --git a/driver-avalon2.c b/driver-avalon2.c
index 0312e73..5261054 100644
--- a/driver-avalon2.c
+++ b/driver-avalon2.c
@@ -193,8 +193,7 @@ static int decode_pkg(struct thr_info *thr, struct avalon2_ret *ar, uint8_t *pkg
 	if (thr) {
 		avalon2 = thr->cgpu;
 		info = avalon2->device_data;
-	} else // FIXME: Should this happen at all!?
-		return 0;
+	}
 
 	memcpy((uint8_t *)ar, pkg, AVA2_READ_SIZE);
 
@@ -263,6 +262,7 @@ static int decode_pkg(struct thr_info *thr, struct avalon2_ret *ar, uint8_t *pkg
 			memcpy(&(info->get_voltage[modular_id]), ar->data + 12, 4);
 			memcpy(&(info->local_work[modular_id]), ar->data + 16, 4);
 			memcpy(&(info->hw_work[modular_id]), ar->data + 20, 4);
+			memcpy(&(info->power_good[modular_id]), ar->data + 24, 4);
 
 			info->get_frequency[modular_id] = be32toh(info->get_frequency[modular_id]);
 			info->get_voltage[modular_id] = be32toh(info->get_voltage[modular_id]);
@@ -273,6 +273,8 @@ static int decode_pkg(struct thr_info *thr, struct avalon2_ret *ar, uint8_t *pkg
 			info->hw_works[modular_id] += info->hw_work[modular_id];
 
 			info->get_voltage[modular_id] = decode_voltage(info->get_voltage[modular_id]);
+			info->power_good[modular_id] = info->power_good[modular_id]  >> 24;
+
 			avalon2->temp = get_temp_max(info);
 			break;
 		case AVA2_P_ACKDETECT:
@@ -797,6 +799,11 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
 		sprintf(buf, "Frequency%d", i + 1);
 		root = api_add_int(root, buf, &(info->get_frequency[i]), false);
 	}
+	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
+		sprintf(buf, "Power good %02x", i + 1);
+	root = api_add_int(root, buf, &(info->power_good[i]), false);
+	}
+
 
 	return root;
 }
diff --git a/driver-avalon2.h b/driver-avalon2.h
index f89bab8..ca2e2df 100644
--- a/driver-avalon2.h
+++ b/driver-avalon2.h
@@ -86,6 +86,7 @@ struct avalon2_info {
 
 	int get_voltage[AVA2_DEFAULT_MODULARS];
 	int get_frequency[AVA2_DEFAULT_MODULARS];
+	int power_good[AVA2_DEFAULT_MODULARS];
 
 	int fan_pwm;
 
diff --git a/driver-bitfury.c b/driver-bitfury.c
index a629af7..a646241 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -19,6 +19,8 @@ int opt_bxf_temp_target = BXF_TEMP_TARGET / 10;
 int opt_nf1_bits = 50;
 int opt_bxm_bits = 54;
 int opt_bxf_bits = 54;
+int opt_bxf_debug;
+int opt_osm_led_mode = 4;
 
 /* Wait longer 1/3 longer than it would take for a full nonce range */
 #define BF1WAIT 1600
@@ -132,6 +134,7 @@ static void bitfury_identify(struct cgpu_info *bitfury)
 			bf1_identify(bitfury);
 			break;
 		case IDENT_BXF:
+		case IDENT_OSM:
 		default:
 			break;
 	}
@@ -206,6 +209,13 @@ static bool bxf_send_msg(struct cgpu_info *bitfury, char *buf, enum usb_cmds cmd
 	if (unlikely(bitfury->usbinfo.nodev))
 		return false;
 
+	if (opt_bxf_debug) {
+		char *strbuf = str_text(buf);
+
+		applog(LOG_ERR, "%s %d: >BXF [%s]", bitfury->drv->name, bitfury->device_id, strbuf);
+		free(strbuf);
+	}
+
 	len = strlen(buf);
 	applog(LOG_DEBUG, "%s %d: Sending %s", bitfury->drv->name, bitfury->device_id, buf);
 	err = usb_write(bitfury, buf, len, &amount, cmd);
@@ -217,6 +227,22 @@ static bool bxf_send_msg(struct cgpu_info *bitfury, char *buf, enum usb_cmds cmd
 	return true;
 }
 
+static bool bxf_send_debugmode(struct cgpu_info *bitfury)
+{
+	char buf[16];
+
+	sprintf(buf, "debug-mode %d\n", opt_bxf_debug);
+	return bxf_send_msg(bitfury, buf, C_BXF_DEBUGMODE);
+}
+
+static bool bxf_send_ledmode(struct cgpu_info *bitfury)
+{
+	char buf[16];
+
+	sprintf(buf, "led-mode %d\n", opt_osm_led_mode);
+	return bxf_send_msg(bitfury, buf, C_BXF_LEDMODE);
+}
+
 /* Returns the amount received only if we receive a full message, otherwise
  * it returns the err value. */
 static int bxf_recv_msg(struct cgpu_info *bitfury, char *buf)
@@ -292,11 +318,13 @@ static bool bxf_detect_one(struct cgpu_info *bitfury, struct bitfury_info *info)
 	applog(LOG_INFO, "%s %d: Successfully initialised %s",
 	       bitfury->drv->name, bitfury->device_id, bitfury->device_path);
 
-	/* Sanity check and recognise the hexfury */
+	/* Sanity check and recognise variations */
 	if (info->chips <= 2 || info->chips > 999)
 		info->chips = 2;
-	else if (info->chips == 6)
+	else if (info->chips <= 6 && info->ident == IDENT_BXF)
 		bitfury->drv->name = "HXF";
+	else if (info->chips > 6 && info->ident == IDENT_BXF)
+		bitfury->drv->name = "MXF";
 	info->filtered_hw = calloc(sizeof(int), info->chips);
 	info->job = calloc(sizeof(int), info->chips);
 	info->submits = calloc(sizeof(int), info->chips);
@@ -771,6 +799,7 @@ static struct cgpu_info *bitfury_detect_one(struct libusb_device *dev, struct us
 			ret = bf1_detect_one(bitfury, info);
 			break;
 		case IDENT_BXF:
+		case IDENT_OSM:
 			ret = bxf_detect_one(bitfury, info);
 			break;
 		case IDENT_NF1:
@@ -799,6 +828,30 @@ static void bitfury_detect(bool __maybe_unused hotplug)
 	usb_detect(&bitfury_drv, bitfury_detect_one);
 }
 
+static void adjust_bxf_chips(struct cgpu_info *bitfury, struct bitfury_info *info, int chip)
+{
+	int chips = chip + 1;
+	size_t old, new;
+
+	if (likely(chips <= info->chips))
+		return;
+	if (chips > 999)
+		return;
+	old = sizeof(int) * info->chips;
+	new = sizeof(int) * chips;
+	applog(LOG_INFO, "%s %d: Adjust chip size to %d", bitfury->drv->name, bitfury->device_id,
+	       chips);
+
+	recalloc(info->filtered_hw, old, new);
+	recalloc(info->job, old, new);
+	recalloc(info->submits, old, new);
+	if (info->chips == 2 && chips <= 6 && info->ident == IDENT_BXF)
+		bitfury->drv->name = "HXF";
+	else if (info->chips <= 6 && chips > 6 && info->ident == IDENT_BXF)
+		bitfury->drv->name = "MXF";
+	info->chips = chips;
+}
+
 static void parse_bxf_submit(struct cgpu_info *bitfury, struct bitfury_info *info, char *buf)
 {
 	struct work *match_work, *tmp, *work = NULL;
@@ -811,7 +864,11 @@ static void parse_bxf_submit(struct cgpu_info *bitfury, struct bitfury_info *inf
 		       bitfury->drv->name, bitfury->device_id);
 		return;
 	}
-	if (likely(chip > -1 && chip < info->chips))
+	adjust_bxf_chips(bitfury, info, chip);
+	if (unlikely(chip >= info->chips || chip < 0)) {
+		applog(LOG_INFO, "%s %d: Invalid submit chip number %d",
+		       bitfury->drv->name, bitfury->device_id, chip);
+	} else
 		info->submits[chip]++;
 
 	applog(LOG_DEBUG, "%s %d: Parsed nonce %u workid %d timestamp %u",
@@ -957,7 +1014,8 @@ static void parse_bxf_job(struct cgpu_info *bitfury, struct bitfury_info *info, 
 		       bitfury->drv->name, bitfury->device_id);
 		return;
 	}
-	if (chip >= info->chips) {
+	adjust_bxf_chips(bitfury, info, chip);
+	if (chip >= info->chips || chip < 0) {
 		applog(LOG_INFO, "%s %d: Invalid job chip number %d",
 		       bitfury->drv->name, bitfury->device_id, chip);
 		return;
@@ -974,7 +1032,8 @@ static void parse_bxf_hwerror(struct cgpu_info *bitfury, struct bitfury_info *in
 		       bitfury->drv->name, bitfury->device_id);
 		return;
 	}
-	if (chip >= info->chips) {
+	adjust_bxf_chips(bitfury, info, chip);
+	if (chip >= info->chips || chip < 0) {
 		applog(LOG_INFO, "%s %d: Invalid hwerror chip number %d",
 		       bitfury->drv->name, bitfury->device_id, chip);
 		return;
@@ -1010,7 +1069,7 @@ static void *bxf_get_results(void *userdata)
 	bxf_update_work(bitfury, info);
 
 	while (likely(!bitfury->shutdown)) {
-		char *msg;
+		char *msg, *strbuf;
 		int err;
 
 		if (unlikely(bitfury->usbinfo.nodev))
@@ -1025,14 +1084,25 @@ static void *bxf_get_results(void *userdata)
 		if (!err)
 			continue;
 
-		PARSE_BXF_MSG(submit);
+		if (opt_bxf_debug) {
+			strbuf = str_text(buf);
+			applog(LOG_ERR, "%s %d: < [%s]",
+				bitfury->drv->name, bitfury->device_id, strbuf);
+			free(strbuf);
+		}
+
+                PARSE_BXF_MSG(submit);
 		PARSE_BXF_MSG(temp);
 		PARSE_BXF_MSG(needwork);
 		PARSE_BXF_MSG(job);
 		PARSE_BXF_MSG(hwerror);
 
-		applog(LOG_DEBUG, "%s %d: Unrecognised string %s",
-		       bitfury->drv->name, bitfury->device_id, buf);
+		if (buf[0] != '#') {
+			strbuf = str_text(buf);
+			applog(LOG_DEBUG, "%s %d: Unrecognised string %s",
+			       bitfury->drv->name, bitfury->device_id, strbuf);
+			free(strbuf);
+		}
 	}
 out:
 	return NULL;
@@ -1040,9 +1110,13 @@ out:
 
 static bool bxf_prepare(struct cgpu_info *bitfury, struct bitfury_info *info)
 {
+	bxf_send_ledmode(bitfury);
+	bxf_send_debugmode(bitfury);
+
 	mutex_init(&info->lock);
 	if (pthread_create(&info->read_thr, NULL, bxf_get_results, (void *)bitfury))
 		quit(1, "Failed to create bxf read_thr");
+
 	return bxf_send_clock(bitfury, info, opt_bxf_bits);
 }
 
@@ -1055,6 +1129,7 @@ static bool bitfury_prepare(struct thr_info *thr)
 
 	switch(info->ident) {
 		case IDENT_BXF:
+		case IDENT_OSM:
 			return bxf_prepare(bitfury, info);
 			break;
 		case IDENT_BF1:
@@ -1190,11 +1265,14 @@ out:
 
 static int64_t bxf_scan(struct cgpu_info *bitfury, struct bitfury_info *info)
 {
+	int ms, aged;
 	int64_t ret;
-	int aged;
 
 	bxf_update_work(bitfury, info);
-	cgsleep_ms(600);
+	ms = 1200 / info->chips;
+	if (ms < 100)
+		ms = 100;
+	cgsleep_ms(ms);
 
 	mutex_lock(&info->lock);
 	ret = bitfury_rate(info);
@@ -1311,6 +1389,7 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
 			ret = bf1_scan(thr, bitfury, info);
 			break;
 		case IDENT_BXF:
+		case IDENT_OSM:
 			ret = bxf_scan(bitfury, info);
 			break;
 		case IDENT_NF1:
@@ -1373,6 +1452,7 @@ static void bitfury_flush_work(struct cgpu_info *bitfury)
 
 	switch(info->ident) {
 		case IDENT_BXF:
+		case IDENT_OSM:
 			bxf_send_flush(bitfury);
 			bxf_update_work(bitfury, info);
 			bxf_update_work(bitfury, info);
@@ -1388,6 +1468,7 @@ static void bitfury_update_work(struct cgpu_info *bitfury)
 
 	switch(info->ident) {
 		case IDENT_BXF:
+		case IDENT_OSM:
 			bxf_update_work(bitfury, info);
 		case IDENT_BF1:
 		default:
@@ -1451,6 +1532,7 @@ static struct api_data *bitfury_api_stats(struct cgpu_info *cgpu)
 			return bf1_api_stats(info);
 			break;
 		case IDENT_BXF:
+		case IDENT_OSM:
 			return bxf_api_stats(cgpu, info);
 			break;
 		default:
@@ -1465,6 +1547,7 @@ static void bitfury_get_statline_before(char *buf, size_t bufsiz, struct cgpu_in
 
 	switch(info->ident) {
 		case IDENT_BXF:
+		case IDENT_OSM:
 			tailsprintf(buf, bufsiz, "%5.1fC", cgpu->temp);
 			break;
 		default:
@@ -1508,6 +1591,7 @@ static void bitfury_shutdown(struct thr_info *thr)
 			bf1_close(bitfury);
 			break;
 		case IDENT_BXF:
+		case IDENT_OSM:
 			bxf_close(info);
 			break;
 		case IDENT_NF1:
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 028e17b..742d7b9 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -26,6 +26,8 @@ extern int opt_bxf_temp_target;
 extern int opt_nf1_bits;
 extern int opt_bxm_bits;
 extern int opt_bxf_bits;
+extern int opt_bxf_debug;
+extern int opt_osm_led_mode;
 
 #define NF1_PIN_LED 0
 #define NF1_PIN_SCK_OVR 5
diff --git a/driver-bitmain.c b/driver-bitmain.c
index 6ea9930..98d5b78 100644
--- a/driver-bitmain.c
+++ b/driver-bitmain.c
@@ -796,7 +796,7 @@ static void bitmain_update_temps(struct cgpu_info *bitmain, struct bitmain_info 
 	}
 	sprintf(tmp, ", TempMAX: %dC", info->temp_max);
 	strcat(msg, tmp);
-	applog(LOG_INFO, msg);
+	applog(LOG_INFO, "%s", msg);
 	info->temp_history_index++;
 	info->temp_sum += bitmain->temp;
 	applog(LOG_DEBUG, "%s%d: temp_index: %d, temp_count: %d, temp_max: %d",
diff --git a/driver-hashfast.c b/driver-hashfast.c
index da32da0..7d154a5 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -879,9 +879,7 @@ static void hfa_detect(bool __maybe_unused hotplug)
 	/* Set up the CRC tables only once. */
 	if (!hfa_crc8_set)
 		hfa_init_crc8();
-	/* Bringing each device online takes a massive amount of work, so only
-	 * do one at a time. */
-	usb_detect_one(&hashfast_drv, hfa_detect_one);
+	usb_detect(&hashfast_drv, hfa_detect_one);
 }
 
 static bool hfa_get_packet(struct cgpu_info *hashfast, struct hf_header *h)
@@ -1255,7 +1253,7 @@ static void *hfa_read(void *arg)
 static void hfa_set_fanspeed(struct cgpu_info *hashfast, struct hashfast_info *info,
 			     int fanspeed);
 
-static bool hfa_prepare(struct thr_info *thr)
+static bool hfa_init(struct thr_info *thr)
 {
 	struct cgpu_info *hashfast = thr->cgpu;
 	struct hashfast_info *info = hashfast->device_data;
@@ -1268,19 +1266,6 @@ static bool hfa_prepare(struct thr_info *thr)
 
 	/* hashfast_reset should fill in details for info */
 	ret = hfa_reset(hashfast, info);
-	if (!ret)
-		goto out;
-
-	/* We will have extracted the serial number by now */
-	if (info->has_opname && !info->opname_valid)
-		hfa_choose_opname(hashfast, info);
-
-	/* Use the opname as the displayed unique identifier */
-	hashfast->unique_id = info->op_name;
-
-	/* Inherit the old device id */
-	if (info->old_cgpu)
-		hashfast->device_id = info->old_cgpu->device_id;
 
 	// The per-die status array
 	info->die_status = calloc(info->asic_count, sizeof(struct hf_g1_die_data));
@@ -1301,6 +1286,19 @@ static bool hfa_prepare(struct thr_info *thr)
 	info->works = calloc(sizeof(struct work *), info->num_sequence);
 	if (!info->works)
 		quit(1, "Failed to calloc info works in hfa_detect_common");
+	if (!ret)
+		goto out;
+
+	/* We will have extracted the serial number by now */
+	if (info->has_opname && !info->opname_valid)
+		hfa_choose_opname(hashfast, info);
+
+	/* Use the opname as the displayed unique identifier */
+	hashfast->unique_id = info->op_name;
+
+	/* Inherit the old device id */
+	if (info->old_cgpu)
+		hashfast->device_id = info->old_cgpu->device_id;
 
 	/* If we haven't found a matching old instance, we might not have
 	 * a valid op_name yet or lack support so try to match based on
@@ -1874,6 +1872,9 @@ static void hfa_statline_before(char *buf, size_t bufsiz, struct cgpu_info *hash
 	if (!hashfast->device_data)
 		return;
 	info = hashfast->device_data;
+	/* Can happen during init sequence */
+	if (!info->die_status)
+		return;
 	max_volt = 0.0;
 
 	for (i = 0; i < info->asic_count; i++) {
@@ -1937,7 +1938,7 @@ struct device_drv hashfast_drv = {
 	.name = "HFA",
 	.max_diff = 256.0, // Limit max diff to get some nonces back regardless
 	.drv_detect = hfa_detect,
-	.thread_prepare = hfa_prepare,
+	.thread_init = hfa_init,
 	.hash_work = &hash_driver_work,
 	.scanwork = hfa_scanwork,
 	.get_api_stats = hfa_api_stats,
diff --git a/driver-spondoolies.c b/driver-spondoolies.c
new file mode 100644
index 0000000..73d74a1
--- /dev/null
+++ b/driver-spondoolies.c
@@ -0,0 +1,441 @@
+/*
+ * Copyright 2014 Con Kolivas <kernel@kolivas.org>
+ * Copyright 2014 Zvi (Zvisha) Shteingart - Spondoolies-tech.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.  See COPYING for more details.
+ */
+
+/*
+ This driver communicates the job requests via Unix socket to the minergate
+ process, that is responsible for controlling the Spondoolies Dawson SP10 miner.
+
+ The jobs sent each with unique ID and returned asynchronously in one of the next
+ transactions. REQUEST_PERIOD and REQUEST_SIZE define the communication rate with minergate.
+*/
+
+#include <float.h>
+#include <limits.h>
+#include <pthread.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <strings.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <assert.h>
+#include <time.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <string.h>
+#include <math.h>
+
+#include "config.h"
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+#include "compat.h"
+#include "miner.h"
+#include "mg_proto_parser.h"
+#include "driver-spondoolies.h"
+
+#ifdef WORDS_BIGENDIAN
+#  define swap32tobe(out, in, sz)  ((out == in) ? (void)0 : memmove(out, in, sz))
+#  define LOCAL_swap32be(type, var, sz)  ;
+#  define swap32tole(out, in, sz)  swap32yes(out, in, sz)
+#  define LOCAL_swap32le(type, var, sz)  LOCAL_swap32(type, var, sz)
+#else
+#  define swap32tobe(out, in, sz)  swap32yes(out, in, sz)
+#  define LOCAL_swap32be(type, var, sz)  LOCAL_swap32(type, var, sz)
+#  define swap32tole(out, in, sz)  ((out == in) ? (void)0 : memmove(out, in, sz))
+#  define LOCAL_swap32le(type, var, sz)  ;
+#endif
+
+static inline void swap32yes(void *out, const void *in, size_t sz)
+{
+	size_t swapcounter;
+
+	for (swapcounter = 0; swapcounter < sz; ++swapcounter)
+		(((uint32_t*)out)[swapcounter]) = swab32(((uint32_t*)in)[swapcounter]);
+}
+
+static void send_minergate_pkt(const minergate_req_packet* mp_req, minergate_rsp_packet* mp_rsp,
+			       int  socket_fd)
+{
+	int nbytes, nwrote, nread;
+
+	nbytes = sizeof(minergate_req_packet);
+	nwrote = write(socket_fd, (const void *)mp_req, nbytes);
+	if (unlikely(nwrote != nbytes))
+		_quit(-1);
+	nbytes = sizeof(minergate_rsp_packet);
+	nread = read(socket_fd, (void *)mp_rsp, nbytes);
+	if (unlikely(nread != nbytes))
+		_quit(-1);
+	passert(mp_rsp->magic == 0xcaf4);
+}
+
+static bool spondoolies_prepare(struct thr_info *thr)
+{
+	struct cgpu_info *spondoolies = thr->cgpu;
+	struct timeval now;
+
+	assert(spondoolies);
+	cgtime(&now);
+	/* FIXME: Vladik */
+#if NEED_FIX
+	get_datestamp(spondoolies->init, &now);
+#endif
+	return true;
+}
+
+static int init_socket(void)
+{
+	int socket_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+	struct sockaddr_un address;
+
+	if (socket_fd < 0) {
+		printf("socket() failed\n");
+		perror("Err:");
+		return 0;
+	}
+
+	/* start with a clean address structure */
+	memset(&address, 0, sizeof(struct sockaddr_un));
+
+	address.sun_family = AF_UNIX;
+	sprintf(address.sun_path, MINERGATE_SOCKET_FILE);
+
+	if(connect(socket_fd, (struct sockaddr *) &address, sizeof(struct sockaddr_un))) {
+		printf("connect() failed\n");
+		perror("Err:");
+		return 0;
+	}
+
+	return socket_fd;
+}
+
+static bool spondoolies_flush_queue(struct spond_adapter* a, bool flush_queue)
+{
+	if (!a->parse_resp) {
+		static int i = 0;
+
+		if (i++ % 10 == 0 && a->works_in_minergate_and_pending_tx + a->works_pending_tx != a->works_in_driver)
+			printf("%d + %d != %d\n", a->works_in_minergate_and_pending_tx, a->works_pending_tx,a->works_in_driver);
+		assert(a->works_in_minergate_and_pending_tx + a->works_pending_tx == a->works_in_driver);
+		send_minergate_pkt(a->mp_next_req,  a->mp_last_rsp, a->socket_fd);
+		if (flush_queue)
+			a->mp_next_req->mask |= 0x02;
+		else
+			a->mp_next_req->mask &= ~0x02;
+
+		a->mp_next_req->req_count = 0;
+		a->parse_resp = 1;
+		a->works_in_minergate_and_pending_tx += a->works_pending_tx;
+		a->works_pending_tx = 0;
+	}
+	return true;
+}
+
+static void spondoolies_detect(__maybe_unused bool hotplug)
+{
+	struct cgpu_info *cgpu = calloc(1, sizeof(*cgpu));
+	struct device_drv *drv = &spondoolies_drv;
+	struct spond_adapter *a;
+
+#if NEED_FIX
+	nDevs = 1;
+#endif
+
+	assert(cgpu);
+	cgpu->drv = drv;
+	cgpu->deven = DEV_ENABLED;
+	cgpu->threads = 1;
+	cgpu->device_data = calloc(sizeof(struct spond_adapter), 1);
+	if (unlikely(!(cgpu->device_data)))
+		quit(1, "Failed to calloc cgpu_info data");
+	a = cgpu->device_data;
+	a->cgpu = (void *)cgpu;
+	a->adapter_state = ADAPTER_STATE_OPERATIONAL;
+	a->mp_next_req = allocate_minergate_packet_req(0xca, 0xfe);
+	a->mp_last_rsp = allocate_minergate_packet_rsp(0xca, 0xfe);
+
+	pthread_mutex_init(&a->lock, NULL);
+	a->socket_fd = init_socket();
+	if (a->socket_fd < 1) {
+		printf("Error connecting to minergate server!");
+		_quit(-1);
+	}
+
+	assert(add_cgpu(cgpu));
+	// Clean MG socket
+	spondoolies_flush_queue(a, true);
+	spondoolies_flush_queue(a, true);
+	spondoolies_flush_queue(a, true);
+	applog(LOG_DEBUG, "SPOND spondoolies_detect done");
+}
+
+static struct api_data *spondoolies_api_stats(struct cgpu_info *cgpu)
+{
+	struct spond_adapter *a = cgpu->device_data;
+	struct api_data *root = NULL;
+
+	root = api_add_int(root, "ASICs total rate", &a->temp_rate, false);
+	root = api_add_int(root, "Temparature rear", &a->rear_temp, false);
+	root = api_add_int(root, "Temparature front", &a->front_temp, false);
+
+	return root;
+}
+
+#if 0
+static unsigned char get_leading_zeroes(const unsigned char *target)
+{
+	unsigned char leading = 0;
+	int first_non_zero_chr;
+	uint8_t m;
+
+	for (first_non_zero_chr = 31; first_non_zero_chr >= 0; first_non_zero_chr--) {
+		if (target[first_non_zero_chr] == 0)
+			leading += 8;
+		else
+			break;
+	}
+
+	// j = first non-zero
+	m = target[first_non_zero_chr];
+	while ((m & 0x80) == 0) {
+		leading++;
+		m = m << 1;
+	}
+	return leading;
+}
+#endif
+
+static void spondoolies_shutdown(__maybe_unused struct thr_info *thr)
+{
+}
+
+static void fill_minergate_request(minergate_do_job_req* work, struct work *cg_work,
+				   int ntime_offset)
+{
+	uint32_t x[64/4];
+	int wd;
+
+	memset(work, 0, sizeof(minergate_do_job_req));
+	//work->
+	LOCAL_swap32le(unsigned char, cg_work->midstate, 32/4)
+	LOCAL_swap32le(unsigned char, cg_work->data+64, 64/4)
+	swap32yes(x, cg_work->data + 64, 64/4);
+	memcpy(work->midstate, cg_work->midstate, 32);
+	work->mrkle_root = ntohl(x[0]);
+	work->timestamp  = ntohl(x[1]);
+	work->difficulty = ntohl(x[2]);
+	//work->leading_zeroes = get_leading_zeroes(cg_work->target);
+	// Is there no better way to get leading zeroes?
+	work->leading_zeroes = 30;
+	wd = (int)round(cg_work->work_difficulty);
+	while (wd) {
+		work->leading_zeroes++;
+		wd = wd >> 1;
+	}
+	//printf("%d %d\n",work->leading_zeroes, (int)round(cg_work->work_difficulty));
+	work->work_id_in_sw = cg_work->subid;
+	work->ntime_limit = 0;
+	work->ntime_offset = ntime_offset;
+}
+
+// returns true if queue full.
+static struct timeval last_force_queue = {0};
+
+static bool spondoolies_queue_full(struct cgpu_info *cgpu)
+{
+	// Only once every 1/10 second do work.
+	struct spond_adapter* a = cgpu->device_data;
+	int next_job_id, ntime_clones, i;
+	struct timeval tv;
+	struct work *work;
+	unsigned int usec;
+	bool ret = false;
+
+	mutex_lock(&a->lock);
+	passert(a->works_pending_tx <= REQUEST_SIZE);
+
+	gettimeofday(&tv, NULL);
+
+	usec = (tv.tv_sec-last_force_queue.tv_sec) * 1000000;
+	usec += (tv.tv_usec-last_force_queue.tv_usec);
+
+	if ((usec >= REQUEST_PERIOD) || (a->reset_mg_queue == 2) ||
+	    ((a->reset_mg_queue == 1) && (a->works_pending_tx == REQUEST_SIZE))) {
+		spondoolies_flush_queue(a, (a->reset_mg_queue == 2));
+		if (a->reset_mg_queue)
+			a->reset_mg_queue--;
+		last_force_queue = tv;
+	}
+
+	// see if we have enough jobs
+	if (a->works_pending_tx == REQUEST_SIZE) {
+		ret = true;
+		goto return_unlock;
+	}
+
+	// see if can take 1 more job.
+	next_job_id = (a->current_job_id + 1) % MAX_JOBS_IN_MINERGATE;
+	if (a->my_jobs[next_job_id].cgminer_work) {
+		ret = true;
+		goto return_unlock;
+	}
+	work = get_queued(cgpu);
+	if (!work) {
+		cgsleep_ms(10);
+		goto return_unlock;
+	}
+
+	work->thr = cgpu->thr[0];
+	work->thr_id = cgpu->thr[0]->id;
+	assert(work->thr);
+
+	// Create 5 works using ntime increment
+	a->current_job_id = next_job_id;
+	work->subid = a->current_job_id;
+	// Get pointer for the request
+	a->my_jobs[a->current_job_id].cgminer_work = work;
+	a->my_jobs[a->current_job_id].state = SPONDWORK_STATE_IN_BUSY;
+	a->my_jobs[a->current_job_id].ntime_clones = 0;
+
+	ntime_clones = (work->drv_rolllimit < MAX_NROLES) ? work->drv_rolllimit : MAX_NROLES;
+	for (i = 0 ; (i < ntime_clones) && (a->works_pending_tx < REQUEST_SIZE) ; i++) {
+		minergate_do_job_req* pkt_job =  &a->mp_next_req->req[a->works_pending_tx];
+		fill_minergate_request(pkt_job, work, i);
+		a->works_in_driver++;
+		a->works_pending_tx++;
+		a->mp_next_req->req_count++;
+		a->my_jobs[a->current_job_id].merkle_root = pkt_job->mrkle_root;
+		a->my_jobs[a->current_job_id].ntime_clones++;
+	}
+
+return_unlock:
+	mutex_unlock(&a->lock);
+
+	return ret;
+}
+
+static void spond_poll_stats(struct cgpu_info *spond, struct spond_adapter *a)
+{
+	FILE *fp = fopen("/var/run/mg_rate_temp", "r");
+
+	if (!fp) {
+		applog(LOG_DEBUG, "SPOND unable to open mg_rate_temp");
+		a->temp_rate = a->rear_temp = a->front_temp = 0;
+	} else {
+		int ret = fscanf(fp, "%d %d %d", &a->temp_rate, &a->rear_temp, &a->front_temp);
+
+		if (ret != 3)
+			a->temp_rate = a->rear_temp = a->front_temp = 0;
+		fclose(fp);
+	}
+	applog(LOG_DEBUG, "SPOND poll_stats rate: %d rear: %d front: %d",
+	       a->temp_rate, a->rear_temp, a->front_temp);
+	/* Use the rear temperature as the dev temperature for now */
+	spond->temp = a->rear_temp;
+}
+
+// Return completed work to submit_nonce() and work_completed() 
+// struct timeval last_force_queue = {0};  
+static int64_t spond_scanhash(struct thr_info *thr)
+{
+	struct cgpu_info *cgpu = thr->cgpu;
+	struct spond_adapter *a = cgpu->device_data;
+	int64_t ghashes = 0;
+	cgtimer_t cgt;
+	time_t now_t;
+
+	cgsleep_prepare_r(&cgt);
+	now_t = time(NULL);
+	/* Poll stats only once per second */
+	if (now_t != a->last_stats) {
+		a->last_stats = now_t;
+		spond_poll_stats(cgpu, a);
+	}
+
+	if (a->parse_resp) {
+		int array_size, i;
+
+		mutex_lock(&a->lock);
+		ghashes = (a->mp_last_rsp->gh_div_10_rate);
+		ghashes = ghashes  * 10000 * REQUEST_PERIOD;
+		array_size = a->mp_last_rsp->rsp_count;
+		for (i = 0; i < array_size; i++) { // walk the jobs
+			int job_id;
+
+			minergate_do_job_rsp* work = a->mp_last_rsp->rsp + i;
+			job_id = work->work_id_in_sw;
+			if ((a->my_jobs[job_id].cgminer_work)) {
+				if (a->my_jobs[job_id].merkle_root == work->mrkle_root) {
+					assert(a->my_jobs[job_id].state == SPONDWORK_STATE_IN_BUSY);
+					a->works_in_minergate_and_pending_tx--;
+					a->works_in_driver--;
+					if (work->winner_nonce) {
+						struct work *cg_work = a->my_jobs[job_id].cgminer_work;
+
+#ifndef SP_NTIME
+						submit_nonce(cg_work->thr, cg_work, work->winner_nonce);
+#else
+						submit_noffset_nonce(cg_work->thr, cg_work, work->winner_nonce, work->ntime_offset);
+#endif
+						a->wins++;
+					}
+					//printf("%d ntime_clones = %d\n",job_id,a->my_jobs[job_id].ntime_clones);
+					if ((--a->my_jobs[job_id].ntime_clones) == 0) {
+						//printf("Done with %d\n", job_id);
+						work_completed(a->cgpu, a->my_jobs[job_id].cgminer_work);
+						a->good++;
+						a->my_jobs[job_id].cgminer_work = NULL;
+						a->my_jobs[job_id].state = SPONDWORK_STATE_EMPTY;
+					}
+				} else {
+					a->bad++;
+					printf("Dropping minergate old job id=%d mrkl=%x my-mrkl=%x\n",
+					       job_id, a->my_jobs[job_id].merkle_root, work->mrkle_root);
+				}
+			} else {
+				a->empty++;
+				printf("No cgminer job (id:%d res:%d)!\n",job_id, work->res);
+			}
+		}
+		mutex_unlock(&a->lock);
+
+		a->parse_resp = 0;
+	}
+	cgsleep_ms_r(&cgt, 40);
+
+	return ghashes;
+}
+
+// Remove all work from queue
+static void spond_flush_work(struct cgpu_info *cgpu)
+{
+	struct spond_adapter *a = cgpu->device_data;
+
+	mutex_lock(&a->lock);
+	a->reset_mg_queue = 2;
+	mutex_unlock(&a->lock);
+}
+
+struct device_drv spondoolies_drv = {
+	.drv_id = DRIVER_spondoolies,
+	.dname = "Spondoolies",
+	.name = "SPN",
+	.drv_detect = spondoolies_detect,
+	.get_api_stats = spondoolies_api_stats,
+	.thread_prepare = spondoolies_prepare,
+	.thread_shutdown = spondoolies_shutdown,
+	.hash_work = hash_queued_work,
+	.queue_full = spondoolies_queue_full,
+	.scanwork = spond_scanhash,
+	.flush_work = spond_flush_work,
+};
diff --git a/driver-spondoolies.h b/driver-spondoolies.h
new file mode 100644
index 0000000..484ce80
--- /dev/null
+++ b/driver-spondoolies.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2014 Con Kolivas <kernel@kolivas.org>
+ * Copyright 2014 Zvi Shteingart - Spondoolies-tech.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.  See COPYING for more details.
+ */
+
+#ifndef SPONDA_HFILE
+#define SPONDA_HFILE
+
+#include "miner.h"
+#include "mg_proto_parser.h"
+
+#define SP_NTIME
+
+typedef enum adapter_state {
+	ADAPTER_STATE_INIT,
+	ADAPTER_STATE_OPERATIONAL,
+} ADAPTER_STATE;
+
+typedef enum spond_work_state {
+	SPONDWORK_STATE_EMPTY,
+	SPONDWORK_STATE_IN_BUSY,
+} SPONDWORK_STATE;
+
+#define MAX_JOBS_IN_MINERGATE MINERGATE_TOTAL_QUEUE // 1.5 sec worth of jobs
+#define MAX_NROLES 50 
+
+typedef struct {
+	struct work      *cgminer_work;
+	SPONDWORK_STATE  state;
+	uint32_t         merkle_root;
+	time_t           start_time;
+	int              job_id[MAX_NROLES];
+	int              ntime_clones;
+} spond_driver_work;
+
+struct spond_adapter {
+	pthread_mutex_t lock;
+	ADAPTER_STATE adapter_state;
+	void *cgpu;
+
+	// Statistics
+	int wins;
+	int good;
+	int empty;
+	int bad;
+	int overflow;
+	// state
+	int works_in_driver;
+	int works_in_minergate_and_pending_tx;
+	int works_pending_tx;
+	int socket_fd;
+	int reset_mg_queue;  // 2=reset, 1=fast send, 0=nada
+	int current_job_id;
+	int parse_resp;
+	minergate_req_packet* mp_next_req;
+	minergate_rsp_packet* mp_last_rsp;
+	spond_driver_work my_jobs[MAX_JOBS_IN_MINERGATE];
+
+	// Temperature statistics
+	int temp_rate;
+	int rear_temp;
+	int front_temp;
+
+	// Last second we polled stats
+	time_t last_stats;
+};
+
+// returns non-zero if needs to change ASICs.
+int spond_one_sec_timer_scaling(struct spond_adapter *a, int t);
+int spond_do_scaling(struct spond_adapter *a);
+
+extern void one_sec_spondoolies_watchdog(int uptime);
+
+#define REQUEST_PERIOD (100000)  //  times per second - in usec
+#define REQUEST_SIZE   100      //  jobs per request
+
+#endif
diff --git a/mg_proto_parser.c b/mg_proto_parser.c
new file mode 100644
index 0000000..d791d64
--- /dev/null
+++ b/mg_proto_parser.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2014 Con Kolivas <kernel@kolivas.org>
+ * Copyright 2014 Zvi (Zvisha) Shteingart - Spondoolies-tech.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.  See COPYING for more details.
+ *
+ * Note that changing this SW will void your miners guaranty
+ */
+
+/*
+	This file holds functions needed for minergate packet parsing/creation
+	by Zvisha Shteingart
+*/
+
+#include "mg_proto_parser.h"
+#include "assert.h"
+//#include "spond_debug.h"
+
+minergate_req_packet *allocate_minergate_packet_req(uint8_t requester_id, uint8_t request_id)
+{
+	minergate_req_packet *p  = (minergate_req_packet*)malloc(sizeof(minergate_req_packet));
+	p->requester_id = requester_id;
+	p->req_count = 0;
+	p->protocol_version = MINERGATE_PROTOCOL_VERSION;
+	p->request_id = request_id;
+	p->magic = 0xcaf4;
+	p->mask |= 0x01; // first packet
+	return p;
+}
+
+minergate_rsp_packet *allocate_minergate_packet_rsp(uint8_t requester_id, uint8_t request_id)
+{
+	minergate_rsp_packet *p  = (minergate_rsp_packet*)malloc(sizeof(minergate_rsp_packet));
+	p->requester_id = requester_id;
+	p->rsp_count = 0;
+	p->protocol_version = MINERGATE_PROTOCOL_VERSION;
+	p->request_id = request_id;
+	p->magic = 0xcaf4;
+	p->gh_div_10_rate = 0;
+	return p;
+}
diff --git a/mg_proto_parser.h b/mg_proto_parser.h
new file mode 100644
index 0000000..a11c1f6
--- /dev/null
+++ b/mg_proto_parser.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2014 Con Kolivas <kernel@kolivas.org>
+ * Copyright 2014 Zvi (Zvisha) Shteingart - Spondoolies-tech.com
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.  See COPYING for more details.
+ *
+ * Note that changing this SW will void your miners guaranty
+ */
+
+#ifndef ____MINERGATE_LIB_H___
+#define ____MINERGATE_LIB_H___
+
+//#include "squid.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/types.h>
+#include <linux/spi/spidev.h>
+#include <netinet/in.h>
+//#include "queue.h"
+//#include "spond_debug.h"
+
+#ifndef passert
+#define passert assert
+#endif
+
+#define MINERGATE_PROTOCOL_VERSION 5
+#define MINERGATE_SOCKET_FILE "/tmp/connection_pipe"
+
+typedef enum {
+	//MINERGATE_DATA_ID_CONNECT = 1,
+	MINERGATE_DATA_ID_DO_JOB_REQ = 2,
+	MINERGATE_DATA_ID_DO_JOB_RSP = 3, 
+
+} MINERGATE_DATA_ID;
+
+typedef struct {
+	uint32_t work_id_in_sw;
+	uint32_t difficulty;
+	uint32_t timestamp;
+	uint32_t mrkle_root;
+	uint32_t midstate[8];
+	uint8_t leading_zeroes;
+	uint8_t ntime_limit;
+	uint8_t ntime_offset;
+	uint8_t resr1;
+} minergate_do_job_req;
+
+#define MAX_REQUESTS 100
+#define MAX_RESPONDS 300
+#define MINERGATE_TOTAL_QUEUE 300
+
+typedef struct {
+	uint32_t work_id_in_sw;
+	uint32_t mrkle_root;     // to validate
+	uint32_t winner_nonce;
+	uint8_t  ntime_offset;
+	uint8_t  res;            // 0 = done, 1 = overflow, 2 = dropped bist
+	uint8_t  resrv1;
+	uint8_t  resrv2;
+} minergate_do_job_rsp;
+
+
+typedef struct {
+	uint8_t requester_id;
+	uint8_t request_id;
+	uint8_t protocol_version;
+	uint8_t mask; // 0x01 = first request, 0x2 = drop old work
+	uint16_t magic; // 0xcafe
+	uint16_t req_count;
+	minergate_do_job_req req[MAX_REQUESTS]; // array of requests
+} minergate_req_packet;
+
+typedef struct {
+	uint8_t requester_id;
+	uint8_t request_id;
+	uint8_t protocol_version;
+	uint8_t gh_div_10_rate; // == 
+	uint16_t magic; // 0xcafe
+	uint16_t rsp_count;
+	minergate_do_job_rsp rsp[MAX_RESPONDS]; // array of responce
+} minergate_rsp_packet;
+
+minergate_req_packet *allocate_minergate_packet_req(uint8_t requester_id, uint8_t request_id);
+minergate_rsp_packet *allocate_minergate_packet_rsp(uint8_t requester_id, uint8_t request_id);
+
+#endif
diff --git a/miner.h b/miner.h
index b687ce3..276e765 100644
--- a/miner.h
+++ b/miner.h
@@ -248,7 +248,8 @@ static inline int fsync (int fd)
 	DRIVER_ADD_COMMAND(minion) \
 	DRIVER_ADD_COMMAND(ants1) \
 	DRIVER_ADD_COMMAND(avalon2) \
-	DRIVER_ADD_COMMAND(avalon)
+	DRIVER_ADD_COMMAND(avalon) \
+	DRIVER_ADD_COMMAND(spondoolies)
 
 #define DRIVER_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \
 	FPGA_PARSE_COMMANDS(DRIVER_ADD_COMMAND) \
diff --git a/usbutils.c b/usbutils.c
index df724cf..6ab114d 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -415,6 +415,19 @@ static struct usb_find_devices find_dev[] = {
 	},
 	{
 		.drv = DRIVER_bitfury,
+		.name = "OSM",
+		.ident = IDENT_OSM,
+		.idVendor = 0x198c,
+		.idProduct = 0xb1f1,
+		.config = 1,
+		.timeout = BITFURY_TIMEOUT_MS,
+		.latency = LATENCY_UNUSED,
+		.iManufacturer = "c-scape",
+		.iProduct = "OneString",
+		INTINFO(bxf_ints)
+	},
+	{
+		.drv = DRIVER_bitfury,
 		.name = "NF1",
 		.ident = IDENT_NF1,
 		.idVendor = 0x04d8,
@@ -1904,10 +1917,9 @@ static int _usb_init(struct cgpu_info *cgpu, struct libusb_device *dev, struct u
 #ifdef WIN32
 			// Windows specific message
 			case LIBUSB_ERROR_NOT_SUPPORTED:
-				applog(LOG_ERR,
-					"USB init, open device failed, err %d, "
-					"you need to install a WinUSB driver for %s",
-					err, devstr);
+				applog(LOG_ERR, "USB init, open device failed, err %d, ", err);
+				applog(LOG_ERR, "You need to install a WinUSB driver for %s", devstr);
+				applog(LOG_ERR, "And associate %s with WinUSB using zadig", devstr);
 				applog(LOG_ERR, "See README.txt file included for help");
 				break;
 #endif
diff --git a/usbutils.h b/usbutils.h
index b05882e..80f7c66 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -158,7 +158,8 @@ enum sub_ident {
 	IDENT_KLN,
 	IDENT_LLT,
 	IDENT_MMQ,
-	IDENT_NF1
+	IDENT_NF1,
+	IDENT_OSM
 };
 
 struct usb_find_devices {
@@ -376,6 +377,8 @@ struct cg_usb_info {
 	USB_ADD_COMMAND(C_BXF_MAXROLL, "BXFMaxRoll") \
 	USB_ADD_COMMAND(C_BXF_FLUSH, "BXFFlush") \
 	USB_ADD_COMMAND(C_BXF_CLOCK, "BXFClock") \
+	USB_ADD_COMMAND(C_BXF_LEDMODE, "BXFLedMode") \
+	USB_ADD_COMMAND(C_BXF_DEBUGMODE, "BXFDebugMode") \
 	USB_ADD_COMMAND(C_BXM_FLUSH, "BXMFlush") \
 	USB_ADD_COMMAND(C_BXM_SRESET, "BXMSReset") \
 	USB_ADD_COMMAND(C_BXM_SETLATENCY, "BXMSetLatency") \
diff --git a/util.c b/util.c
index 05f635c..65692f2 100644
--- a/util.c
+++ b/util.c
@@ -33,7 +33,6 @@
 # include <netinet/tcp.h>
 # include <netdb.h>
 #else
-# include <windows.h>
 # include <winsock2.h>
 # include <ws2tcpip.h>
 # include <mmsystem.h>
@@ -1524,6 +1523,18 @@ static void clear_sock(struct pool *pool)
 	clear_sockbuf(pool);
 }
 
+/* Realloc memory to new size and zero any extra memory added */
+void _recalloc(void **ptr, size_t old, size_t new, const char *file, const char *func, const int line)
+{
+	if (new == old)
+		return;
+	*ptr = realloc(*ptr, new);
+	if (unlikely(!*ptr))
+		quitfrom(1, file, func, line, "Failed to realloc");
+	if (new > old)
+		memset(*ptr + old, 0, new - old);
+}
+
 /* Make sure the pool sockbuf is large enough to cope with any coinbase size
  * by reallocing it to a large enough size rounded up to a multiple of RBUFSIZE
  * and zeroing the new memory */
diff --git a/util.h b/util.h
index f78b015..e9edae1 100644
--- a/util.h
+++ b/util.h
@@ -29,8 +29,8 @@
 		return (errno == EINTR);
 	}
 #elif defined WIN32
-	#include <ws2tcpip.h>
 	#include <winsock2.h>
+	#include <ws2tcpip.h>
 
 	#define SOCKETTYPE SOCKET
 	#define SOCKETFAIL(a) ((int)(a) == SOCKET_ERROR)
@@ -137,6 +137,8 @@ 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);
+void _recalloc(void **ptr, size_t old, size_t new, const char *file, const char *func, const int line);
+#define recalloc(ptr, old, new) _recalloc((void *)&(ptr), old, new, __FILE__, __func__, __LINE__)
 char *recv_line(struct pool *pool);
 bool parse_method(struct pool *pool, char *s);
 bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port);