Skip to content

Commit

Permalink
Clean up compac driver.
Browse files Browse the repository at this point in the history
  • Loading branch information
ckolivas committed Jan 23, 2017
1 parent 9102e00 commit 842da99
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 38 deletions.
8 changes: 8 additions & 0 deletions ASIC-README
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Currently supported devices include:
- BlackArrow Minion
- Bi*fury USB
- Cointerra
- Compac bitshopperde and GekkoScience
- Hashfast Babyjet and Sierra
- Hashratio
- Hexfury USB
Expand Down Expand Up @@ -111,6 +112,13 @@ line arguments for power settings.
Cointerra USB devices are set up as per the USB ASIC instructions below.


Compac devices

Compac devices need the --enable-icarus option when compiling cgminer.

bitshopperde come up as BSC and GekkoScience as GSC


HASHFAST devices

Hashfast devices need the --enable-hashfast option when compiling cgminer.
Expand Down
2 changes: 2 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ Options for both config file and command line:
--bxm-bits <arg> Set BXM bits for overclocking (default: 54)
--btc-address <arg> Set bitcoin target address when solo mining to bitcoind
--btc-sig <arg> Set signature to add to coinbase when solo mining (optional)
--compac-freq <arg> Set GekkoScience Compac frequency in MHz, range 100-500 (default: 150.0)
--compact Use compact display without per device statistics
--debug|-D Enable debug output
--disable-rejecting Automatically disable pools that continually reject shares
Expand Down Expand Up @@ -420,6 +421,7 @@ ASIC only options:
--bitmine-a1-options <ref_clk>:<sys_clk>:<spi_clk>:<max_chip>
--bxf-temp-target <arg> Set target temperature for BXF devices (default: 82)
--bxm-bits <arg> Set BXM bits for overclocking (default: 50)
--compac-freq <arg> Set GekkoScience Compac frequency in MHz, range 100-500 (default: 150.0)
--hfa-hash-clock <arg> Set hashfast clock speed (default: 550)
--hfa-fail-drop <arg> Set how many MHz to drop clockspeed each failure on an overlocked hashfast device (default: 10)
--hfa-fan <arg> Set fanspeed percentage for hashfast, single value or range (default: 10-85)
Expand Down
8 changes: 5 additions & 3 deletions cgminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,9 +1280,6 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--au3-volt",
set_int_0_to_9999, &opt_show_intval, &opt_au3_volt,
"Set AntminerU3 voltage in mv, range 725-850, 0 to not set"),
OPT_WITH_ARG("--compac-freq",
set_float_100_to_500, &opt_show_floatval, &opt_compac_freq,
"Set GekkoScience Compac frequency in MHz, range 100-500"),
#endif
#ifdef USE_AVALON
OPT_WITHOUT_ARG("--avalon-auto",
Expand Down Expand Up @@ -1619,6 +1616,11 @@ static struct opt_table opt_config_table[] = {
opt_set_charp, NULL, &opt_btc_sig,
"Set signature to add to coinbase when solo mining (optional)"),
#endif
#ifdef USE_ICARUS
OPT_WITH_ARG("--compac-freq",
set_float_100_to_500, &opt_show_floatval, &opt_compac_freq,
"Set GekkoScience Compac frequency in MHz, range 100-500"),
#endif
#ifdef HAVE_CURSES
OPT_WITHOUT_ARG("--compact",
opt_set_bool, &opt_compact,
Expand Down
65 changes: 30 additions & 35 deletions driver-icarus.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,9 @@ struct ICARUS_WORK {
#define ANT_U1_DEFFREQ 200
#define ANT_U3_DEFFREQ 225
#define ANT_U3_MAXFREQ 250
#define COMPAC_DEFFREQ 150
#define COMPAC_DEFFREQ 150
#define COMPAC_MAXFREQ 500

struct {
float freq;
uint16_t hex;
Expand Down Expand Up @@ -1546,46 +1547,42 @@ static struct cgpu_info *compac_detect_one(struct libusb_device *dev, struct usb
{
struct ICARUS_INFO *info;
struct timeval tv_start, tv_finish;
struct cgpu_info *compac = usb_alloc_cgpu(&icarus_drv, 1);

struct cgpu_info *icarus;
icarus = usb_alloc_cgpu(&icarus_drv, 1);

if (!usb_init(icarus, dev, found)) {
icarus = usb_free_cgpu(icarus);
if (!usb_init(compac, dev, found)) {
compac = usb_free_cgpu(compac);
return NULL;
}

info = cgcalloc(1, sizeof(struct ICARUS_INFO));
icarus->device_data = (void *)info;

info->ident = usb_ident(icarus);
compac->device_data = info;

if (info->ident == IDENT_BSC ||
info->ident == IDENT_GSC) {
info->ident = usb_ident(compac);

if (info->ident == IDENT_BSC || info->ident == IDENT_GSC) {
int this_option_offset = ++option_offset;
const uint32_t golden_nonce_val = 0x000187a2;
unsigned char nonce_bin[ICARUS_READ_SIZE];
int baud, uninitialised_var(work_division), uninitialised_var(fpga_count);
uint16_t compac_freq_hex;

applog(LOG_DEBUG, "%s %i: Detected GekkoScience Compac", icarus->drv->name,
icarus->device_id);
applog(LOG_DEBUG, "%s %i: Detected GekkoScience Compac", compac->drv->name,
compac->device_id);

get_options(this_option_offset, icarus, &baud, &work_division, &fpga_count);
get_options(this_option_offset, compac, &baud, &work_division, &fpga_count);

info->compac_ramp_idx = 0;
info->compac_ramp_freq = compacfreqtable[info->compac_ramp_idx].freq;
info->compac_target_freq = opt_compac_freq;

uint16_t compac_freq_hex = compacfreqtable[info->compac_ramp_idx].hex;
compac_freq_hex = compacfreqtable[info->compac_ramp_idx].hex;

if (!set_anu_freq(icarus, info, compac_freq_hex)) {
if (!set_anu_freq(compac, info, compac_freq_hex)) {
applog(LOG_WARNING, "%s %i: Failed to set frequency, too much overclock?",
icarus->drv->name, icarus->device_id);
compac->drv->name, compac->device_id);
}

applog(LOG_DEBUG, "%s %d: Init baud=%d work_division=%d fpga_count=%d",
icarus->drv->name, icarus->device_id, baud, work_division, fpga_count);
compac->drv->name, compac->device_id, baud, work_division, fpga_count);

info->ant = true;
info->compac = true;
Expand All @@ -1595,28 +1592,28 @@ static struct cgpu_info *compac_detect_one(struct libusb_device *dev, struct usb
info->nonce_mask = mask(work_division);
info->nonce_size = ANT_READ_SIZE;

if (add_cgpu(icarus)) {
char *tmp_str;
tmp_str=malloc(50*sizeof(char));
strncpy(tmp_str,icarus->unique_id,11);
strncpy(icarus->unique_id,"\0\0\0\0\0\0\0\0\0\0\0",11);
strncpy(icarus->unique_id,(tmp_str)+3*sizeof(char),8);
if (add_cgpu(compac)) {
char *tmp_str = cgmalloc(50 * sizeof(char));

strncpy(tmp_str,compac->unique_id,11);
strncpy(compac->unique_id,"\0\0\0\0\0\0\0\0\0\0\0",11);
strncpy(compac->unique_id,(tmp_str)+3*sizeof(char),8);

update_usb_stats(icarus);
update_usb_stats(compac);

info->golden_hashes = (golden_nonce_val & info->nonce_mask) * fpga_count;
timersub(&tv_finish, &tv_start, &(info->golden_tv));

set_timing_mode(this_option_offset, icarus);
return icarus;
set_timing_mode(this_option_offset, compac);
return compac;
}
}

usb_uninit(icarus);
usb_uninit(compac);
free(info);
icarus->device_data = NULL;
compac->device_data = NULL;

icarus = usb_free_cgpu(icarus);
compac = usb_free_cgpu(compac);
return NULL;
}

Expand Down Expand Up @@ -2131,17 +2128,15 @@ static int64_t icarus_scanwork(struct thr_info *thr)
int64_t estimate_hashes;
uint8_t workid = 0;

if(info->compac && info->compac_ramp_freq < info->compac_target_freq)
{
if (info->compac && info->compac_ramp_freq < info->compac_target_freq) {
uint16_t compac_freq_hex = compacfreqtable[++info->compac_ramp_idx].hex;

if (!set_anu_freq(icarus, info, compac_freq_hex)) {
applog(LOG_WARNING, "%s %i: Failed to set frequency, too much overclock?",
icarus->drv->name, icarus->device_id);
info->compac_target_freq = info->compac_ramp_freq;
} else {
} else
info->compac_ramp_freq = compacfreqtable[info->compac_ramp_idx].freq;
}
}

if (unlikely(share_work_tdiff(icarus) > info->fail_time)) {
Expand Down

0 comments on commit 842da99

Please sign in to comment.