Provide an hfa-dfu-boot option for resetting hashfast devices for reprogramming.
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
diff --git a/cgminer.c b/cgminer.c
index 9a064c0..690afa6 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -77,6 +77,7 @@ char *curly = ":D";
int opt_hfa_ntime_roll;
int opt_hfa_hash_clock;
bool opt_hfa_pll_bypass;
+bool opt_hfa_dfu_boot;
#endif
#if defined(USE_BITFORCE) || defined(USE_ICARUS) || defined(USE_AVALON) || defined(USE_MODMINER)
@@ -1199,12 +1200,15 @@ static struct opt_table opt_config_table[] = {
"Override avalon-options for BitBurner Fury boards baud:miners:asic:timeout:freq"),
#endif
#ifdef USE_HASHFAST
- OPT_WITH_ARG("--hfa-ntime-roll",
- opt_set_intval, NULL, &opt_hfa_ntime_roll,
- opt_hidden),
+ OPT_WITHOUT_ARG("--hfa-dfu-boot",
+ opt_set_bool, &opt_hfa_dfu_boot,
+ opt_hidden),
OPT_WITH_ARG("--hfa-hash-clock",
opt_set_intval, NULL, &opt_hfa_hash_clock,
opt_hidden),
+ OPT_WITH_ARG("--hfa-ntime-roll",
+ opt_set_intval, NULL, &opt_hfa_ntime_roll,
+ opt_hidden),
OPT_WITHOUT_ARG("--hfa-pll-bypass",
opt_set_bool, &opt_hfa_pll_bypass,
opt_hidden),
diff --git a/driver-hashfast.c b/driver-hashfast.c
index f77b259..6ca59ae 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -84,7 +84,7 @@ static const struct hfa_cmd hfa_cmds[] = {
{OP_GET_TRACE, "OP_GET_TRACE", C_NULL},
{OP_LOOPBACK_USB, "OP_LOOPBACK_USB", C_NULL},
{OP_LOOPBACK_UART, "OP_LOOPBACK_UART", C_NULL},
- {OP_DFU, "OP_DFU", C_NULL},
+ {OP_DFU, "OP_DFU", C_HF_DFU},
{OP_USB_SHUTDOWN, "OP_USB_SHUTDOWN", C_NULL},
{OP_DIE_STATUS, "OP_DIE_STATUS", C_HF_DIE_STATUS}, // 24
{OP_GWQ_STATUS, "OP_GWQ_STATUS", C_HF_GWQ_STATUS},
@@ -433,6 +433,15 @@ static bool hfa_initialise(struct cgpu_info *hashfast)
return (err == 7);
}
+static void hfa_dfu_boot(struct cgpu_info *hashfast)
+{
+ bool ret;
+
+ ret = hfa_send_frame(hashfast, HF_USB_CMD(OP_DFU), 0, NULL, 0);
+ applog(LOG_WARNING, "HFA %d %03d:%03d DFU Boot %s", hashfast->device_id, hashfast->usbinfo.bus_number,
+ hashfast->usbinfo.device_address, ret ? "Succeeded" : "Failed");
+}
+
static struct cgpu_info *hfa_detect_one(libusb_device *dev, struct usb_find_devices *found)
{
struct cgpu_info *hashfast;
@@ -452,7 +461,11 @@ static struct cgpu_info *hfa_detect_one(libusb_device *dev, struct usb_find_devi
hashfast = usb_free_cgpu(hashfast);
return NULL;
}
-
+ if (opt_hfa_dfu_boot) {
+ hfa_dfu_boot(hashfast);
+ hashfast = usb_free_cgpu(hashfast);
+ return NULL;
+ }
if (!hfa_detect_common(hashfast)) {
usb_uninit(hashfast);
hashfast = usb_free_cgpu(hashfast);
diff --git a/driver-hashfast.h b/driver-hashfast.h
index 5ce7234..c6cc46e 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -19,6 +19,8 @@
int opt_hfa_ntime_roll;
int opt_hfa_hash_clock;
bool opt_hfa_pll_bypass;
+bool opt_hfa_dfu_boot;
+
#define HASHFAST_MINER_THREADS 1
// Matching fields for hf_statistics, but large #s for local accumulation, per-die
diff --git a/usbutils.h b/usbutils.h
index 5b996fc..a83f164 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -359,6 +359,7 @@ struct cg_usb_info {
USB_ADD_COMMAND(C_HF_STATISTICS, "HFStatistics") \
USB_ADD_COMMAND(C_HF_CLOCKGATE, "HFClockGate") \
USB_ADD_COMMAND(C_HF_USB_INIT, "HFUSBInit") \
+ USB_ADD_COMMAND(C_HF_DFU, "HFDFU") \
USB_ADD_COMMAND(C_HF_DIE_STATUS, "HFDieStatus") \
USB_ADD_COMMAND(C_HF_GWQ_STATUS, "HFGWQStatus") \
USB_ADD_COMMAND(C_HF_WORK_RESTART, "HFWorkRestart") \