Browse Source

erupter: New icarus-based driver to handle autodetection of Block Erupter devices

Luke Dashjr 12 years ago
parent
commit
d7f76515e1
5 changed files with 89 additions and 2 deletions
  1. 1 0
      Makefile.am
  2. 0 2
      driver-cairnsmore.c
  3. 84 0
      driver-erupter.c
  4. 2 0
      icarus-common.h
  5. 2 0
      miner.c

+ 1 - 0
Makefile.am

@@ -179,6 +179,7 @@ endif
 if HAS_ICARUS
 if HAS_ICARUS
 bfgminer_SOURCES += driver-icarus.c icarus-common.h
 bfgminer_SOURCES += driver-icarus.c icarus-common.h
 bfgminer_SOURCES += driver-cairnsmore.c
 bfgminer_SOURCES += driver-cairnsmore.c
+bfgminer_SOURCES += driver-erupter.c
 endif
 endif
 
 
 if HAS_AVALON
 if HAS_AVALON

+ 0 - 2
driver-cairnsmore.c

@@ -196,8 +196,6 @@ static bool cairnsmore_identify(struct cgpu_info *cm1)
 	return true;
 	return true;
 }
 }
 
 
-extern struct device_drv icarus_drv;
-
 static void cairnsmore_drv_init()
 static void cairnsmore_drv_init()
 {
 {
 	cairnsmore_drv = icarus_drv;
 	cairnsmore_drv = icarus_drv;

+ 84 - 0
driver-erupter.c

@@ -0,0 +1,84 @@
+/*
+ * Copyright 2013 Luke Dashjr
+ *
+ * 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.
+ */
+
+#include "fpgautils.h"
+#include "icarus-common.h"
+
+#define ERUPTER_IO_SPEED 1500000
+#define ERUPTER_HASH_TIME 0.0000000029761
+
+extern struct device_drv erupter_drv;
+extern struct device_drv erupter_drv_emerald;
+
+static bool _erupter_detect_one(const char *devpath, struct device_drv *drv)
+{
+	struct ICARUS_INFO *info = calloc(1, sizeof(struct ICARUS_INFO));
+	if (unlikely(!info))
+		quit(1, "Failed to malloc ICARUS_INFO");
+
+	*info = (struct ICARUS_INFO){
+		.baud = ERUPTER_IO_SPEED,
+		.Hs = ERUPTER_HASH_TIME,
+		.timing_mode = MODE_DEFAULT,
+	};
+
+	if (!icarus_detect_custom(devpath, drv, info)) {
+		free(info);
+		return false;
+	}
+	return true;
+}
+
+static bool erupter_emerald_detect_one(const char *devpath)
+{
+	return _erupter_detect_one(devpath, &erupter_drv_emerald);
+}
+
+static bool erupter_detect_one(const char *devpath)
+{
+	return _erupter_detect_one(devpath, &erupter_drv);
+}
+
+static int erupter_emerald_detect_auto(void)
+{
+	return serial_autodetect(erupter_emerald_detect_one, "Block", "Erupter", "Emerald");
+}
+
+static int erupter_detect_auto(void)
+{
+	return serial_autodetect(erupter_detect_one, "Block", "Erupter");
+}
+
+static void erupter_drv_init();
+
+static void erupter_detect()
+{
+	erupter_drv_init();
+	// Actual serial detection is handled by Icarus driver
+	serial_detect_auto_byname(&erupter_drv_emerald, erupter_emerald_detect_one, erupter_emerald_detect_auto);
+	serial_detect_auto_byname(&erupter_drv, erupter_detect_one, erupter_detect_auto);
+}
+
+static void erupter_drv_init()
+{
+	erupter_drv = icarus_drv;
+	erupter_drv.dname = "erupter";
+	erupter_drv.name = "BES";
+	erupter_drv.drv_detect = erupter_detect;
+	
+	erupter_drv_emerald = erupter_drv;
+	erupter_drv_emerald.name = "BEE";
+}
+
+struct device_drv erupter_drv = {
+	// Needed to get to erupter_drv_init at all
+	.drv_detect = erupter_detect,
+};
+
+struct device_drv erupter_drv_emerald;

+ 2 - 0
icarus-common.h

@@ -35,6 +35,8 @@
 // keeping a ongoing average of recent data
 // keeping a ongoing average of recent data
 #define INFO_HISTORY 10
 #define INFO_HISTORY 10
 
 
+extern struct device_drv icarus_drv;
+
 struct ICARUS_HISTORY {
 struct ICARUS_HISTORY {
 	struct timeval finish;
 	struct timeval finish;
 	double sumXiTi;
 	double sumXiTi;

+ 2 - 0
miner.c

@@ -8603,6 +8603,7 @@ extern struct device_drv bitforce_drv;
 
 
 #ifdef USE_ICARUS
 #ifdef USE_ICARUS
 extern struct device_drv cairnsmore_drv;
 extern struct device_drv cairnsmore_drv;
+extern struct device_drv erupter_drv;
 extern struct device_drv icarus_drv;
 extern struct device_drv icarus_drv;
 #endif
 #endif
 
 
@@ -8701,6 +8702,7 @@ void drv_detect_all()
 	if (!opt_scrypt)
 	if (!opt_scrypt)
 	{
 	{
 		cairnsmore_drv.drv_detect();
 		cairnsmore_drv.drv_detect();
+		erupter_drv.drv_detect();
 		icarus_drv.drv_detect();
 		icarus_drv.drv_detect();
 	}
 	}
 #endif
 #endif