Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/vthoang/cgminer into vtho…
Browse files Browse the repository at this point in the history
…ang-master
  • Loading branch information
ckolivas committed Jan 23, 2017
2 parents 47397c8 + 68cc5b7 commit 9102e00
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 2 deletions.
17 changes: 17 additions & 0 deletions cgminer.c
Expand Up @@ -233,6 +233,7 @@ char *opt_icarus_options = NULL;
char *opt_icarus_timing = NULL;
float opt_anu_freq = 250;
float opt_au3_freq = 225;
float opt_compac_freq = 150;
int opt_au3_volt = 775;
float opt_rock_freq = 270;
#endif
Expand Down Expand Up @@ -1185,6 +1186,19 @@ static void load_temp_cutoffs()
}
}

static char *set_float_100_to_500(const char *arg, float *i)
{
char *err = opt_set_floatval(arg, i);

if (err)
return err;

if (*i < 100 || *i > 500)
return "Value out of range";

return NULL;
}

static char *set_float_125_to_500(const char *arg, float *i)
{
char *err = opt_set_floatval(arg, i);
Expand Down Expand Up @@ -1266,6 +1280,9 @@ 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
180 changes: 178 additions & 2 deletions driver-icarus.c
Expand Up @@ -72,7 +72,8 @@ ASSERT1(sizeof(uint32_t) == 4);
#define ICA_WAIT_TIMEOUT 100
#define ANT_WAIT_TIMEOUT 10
#define AU3_WAIT_TIMEOUT 1
#define ICARUS_WAIT_TIMEOUT (info->u3 ? AU3_WAIT_TIMEOUT : (info->ant ? ANT_WAIT_TIMEOUT : ICA_WAIT_TIMEOUT))
#define GSC_WAIT_TIMEOUT 1
#define ICARUS_WAIT_TIMEOUT (info->compac ? GSC_WAIT_TIMEOUT : (info->u3 ? AU3_WAIT_TIMEOUT : (info->ant ? ANT_WAIT_TIMEOUT : ICA_WAIT_TIMEOUT)))

#define ICARUS_CMR2_TIMEOUT 1

Expand All @@ -94,6 +95,8 @@ ASSERT1(sizeof(uint32_t) == 4);

#define ANTU3_READ_COUNT_TIMING 100

#define COMPAC_READ_COUNT_TIMING 5000

#define ICARUS_READ_COUNT_MIN ICARUS_WAIT_TIMEOUT
#define SECTOMS(s) ((int)((s) * 1000))
// How many ms below the expected completion time to abort work
Expand All @@ -118,6 +121,8 @@ ASSERT1(sizeof(uint32_t) == 4);
#define ANTMINERUSB_HASH_TIME (ANTMINERUSB_HASH_MHZ / (double)(opt_anu_freq))
#define ANTU3_HASH_MHZ 0.0000000032
#define ANTU3_HASH_TIME (ANTU3_HASH_MHZ / (double)(opt_au3_freq))
#define COMPAC_HASH_MHZ 0.0000000128
#define COMPAC_HASH_TIME (COMPAC_HASH_MHZ / (double)(opt_compac_freq))

#define CAIRNSMORE2_INTS 4

Expand Down Expand Up @@ -334,6 +339,10 @@ struct ICARUS_INFO {
int workid;
bool ant;
bool u3;
bool compac;
float compac_ramp_freq;
float compac_target_freq;
uint16_t compac_ramp_idx;
};

#define ICARUS_MIDSTATE_SIZE 32
Expand Down Expand Up @@ -378,6 +387,8 @@ struct ICARUS_WORK {
#define ANT_U1_DEFFREQ 200
#define ANT_U3_DEFFREQ 225
#define ANT_U3_MAXFREQ 250
#define COMPAC_DEFFREQ 150
#define COMPAC_MAXFREQ 500
struct {
float freq;
uint16_t hex;
Expand All @@ -397,6 +408,68 @@ struct {
{ 243.75, 0x1306 },
{ 250, 0x0982 },
};
struct {
float freq;
uint16_t hex;
} compacfreqtable[] = {
{ 100, 0x0783 },
{ 106.25, 0x0803 },
{ 112.5, 0x0883 },
{ 118.75, 0x0903 },
{ 125, 0x0983 },
{ 131.25, 0x0a03 },
{ 137.5, 0x0a83 },
{ 143.75, 0x1687 },
{ 150, 0x0b83 },
{ 156.25, 0x0c03 },
{ 162.5, 0x0c83 },
{ 168.75, 0x1a87 },
{ 175, 0x0d83 },
{ 181.25, 0x0e83 },
{ 193.75, 0x0f03 },
{ 196.88, 0x1f07 },
{ 200, 0x0782 },
{ 206.25, 0x1006 },
{ 212.5, 0x1086 },
{ 218.75, 0x1106 },
{ 225, 0x0882 },
{ 231.25, 0x1206 },
{ 237.5, 0x1286 },
{ 243.75, 0x1306 },
{ 250, 0x0982 },
{ 256.25, 0x1406 },
{ 262.5, 0x0a02 },
{ 268.75, 0x1506 },
{ 275, 0x0a82 },
{ 281.25, 0x1606 },
{ 287.5, 0x0b02 },
{ 293.75, 0x1706 },
{ 300, 0x0b82 },
{ 306.25, 0x1806 },
{ 312.5, 0x0c02 },
{ 318.75, 0x1906 },
{ 325, 0x0c82 },
{ 331.25, 0x1a06 },
{ 337.5, 0x0d02 },
{ 343.75, 0x1b06 },
{ 350, 0x0d82 },
{ 356.25, 0x1c06 },
{ 362.5, 0x0e02 },
{ 368.75, 0x1d06 },
{ 375, 0x0e82 },
{ 381.25, 0x1e06 },
{ 387.5, 0x0f02 },
{ 393.75, 0x1f06 },
{ 400, 0x0f82 },
{ 412.5, 0x1006 },
{ 425, 0x0801 },
{ 437.5, 0x1105 },
{ 450, 0x0881 },
{ 462.5, 0x1205 },
{ 475, 0x0901 },
{ 487.5, 0x1305 },
{ 500, 0x0981 },
};

#define END_CONDITION 0x0000ffff

Expand Down Expand Up @@ -559,6 +632,8 @@ static void icarus_initialise(struct cgpu_info *icarus, int baud)
case IDENT_AMU:
case IDENT_ANU:
case IDENT_AU3:
case IDENT_BSC:
case IDENT_GSC:
case IDENT_LIN:
// Enable the UART
transfer(icarus, CP210X_TYPE_OUT, CP210X_REQUEST_IFC_ENABLE,
Expand Down Expand Up @@ -726,6 +801,11 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
info->Hs = ANTU3_HASH_TIME;
read_count_timing = ANTU3_READ_COUNT_TIMING;
break;
case IDENT_BSC:
case IDENT_GSC:
info->Hs = COMPAC_HASH_TIME;
read_count_timing = COMPAC_READ_COUNT_TIMING;
break;
default:
quit(1, "Icarus get_options() called with invalid %s ident=%d",
icarus->drv->name, ident);
Expand Down Expand Up @@ -889,6 +969,8 @@ static void get_options(int this_option_offset, struct cgpu_info *icarus, int *b
case IDENT_AMU:
case IDENT_ANU:
case IDENT_AU3:
case IDENT_BSC:
case IDENT_GSC:
*baud = ICARUS_IO_SPEED;
*work_division = 1;
*fpga_count = 1;
Expand Down Expand Up @@ -1460,6 +1542,84 @@ static struct cgpu_info *icarus_detect_one(struct libusb_device *dev, struct usb
return NULL;
}

static struct cgpu_info *compac_detect_one(struct libusb_device *dev, struct usb_find_devices *found)
{
struct ICARUS_INFO *info;
struct timeval tv_start, tv_finish;

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

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

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

info->ident = usb_ident(icarus);

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);

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

get_options(this_option_offset, icarus, &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;

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);
}

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);

info->ant = true;
info->compac = true;
info->baud = baud;
info->work_division = work_division;
info->fpga_count = fpga_count;
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);

update_usb_stats(icarus);

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;
}
}

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

icarus = usb_free_cgpu(icarus);
return NULL;
}

static int64_t rock_scanwork(struct thr_info *thr);

static void rock_statline_before(char *buf, size_t bufsiz, struct cgpu_info *cgpu)
Expand Down Expand Up @@ -1709,6 +1869,7 @@ static struct cgpu_info *rock_detect_one(struct libusb_device *dev, struct usb_f
static void icarus_detect(bool __maybe_unused hotplug)
{
usb_detect(&icarus_drv, rock_detect_one);
usb_detect(&icarus_drv, compac_detect_one);
usb_detect(&icarus_drv, icarus_detect_one);
}

Expand Down Expand Up @@ -1970,6 +2131,19 @@ 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)
{
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 {
info->compac_ramp_freq = compacfreqtable[info->compac_ramp_idx].freq;
}
}

if (unlikely(share_work_tdiff(icarus) > info->fail_time)) {
if (info->failing) {
if (share_work_tdiff(icarus) > info->fail_time + 60) {
Expand Down Expand Up @@ -2379,7 +2553,9 @@ static void icarus_statline_before(char *buf, size_t bufsiz, struct cgpu_info *c
struct ICARUS_INFO *info = (struct ICARUS_INFO *)(cgpu->device_data);

if (info->ant) {
if (info->u3)
if (info->compac)
tailsprintf(buf, bufsiz, "%3.0fMHz", info->compac_ramp_freq);
else if (info->u3)
tailsprintf(buf, bufsiz, "%3.0fMHz %3dmV", opt_au3_freq, opt_au3_volt);
else
tailsprintf(buf, bufsiz, "%3.0fMHz", opt_anu_freq);
Expand Down
1 change: 1 addition & 0 deletions miner.h
Expand Up @@ -1010,6 +1010,7 @@ extern char *opt_icarus_options;
extern char *opt_icarus_timing;
extern float opt_anu_freq;
extern float opt_au3_freq;
extern float opt_compac_freq;
extern int opt_au3_volt;
extern float opt_rock_freq;
#endif
Expand Down
24 changes: 24 additions & 0 deletions usbutils.c
Expand Up @@ -803,6 +803,30 @@ static struct usb_find_devices find_dev[] = {
.timeout = ICARUS_TIMEOUT_MS,
.latency = LATENCY_UNUSED,
INTINFO(ica1_ints) },
{
.drv = DRIVER_icarus,
.name = "BSC",
.ident = IDENT_BSC,
.idVendor = 0x10c4,
.idProduct = 0xea60,
.iManufacturer = "bitshopperde",
.iProduct = "Compac BM1384 Bitcoin Miner",
.config = 1,
.timeout = ICARUS_TIMEOUT_MS,
.latency = LATENCY_UNUSED,
INTINFO(amu_ints) },
{
.drv = DRIVER_icarus,
.name = "GSC",
.ident = IDENT_GSC,
.idVendor = 0x10c4,
.idProduct = 0xea60,
.iManufacturer = "GekkoScience",
.iProduct = "Compac BM1384 Bitcoin Miner",
.config = 1,
.timeout = ICARUS_TIMEOUT_MS,
.latency = LATENCY_UNUSED,
INTINFO(amu_ints) },
{
.drv = DRIVER_icarus,
.name = "AMU",
Expand Down
2 changes: 2 additions & 0 deletions usbutils.h
Expand Up @@ -160,13 +160,15 @@ enum sub_ident {
IDENT_BFL,
IDENT_BLT,
IDENT_BMA,
IDENT_BSC,
IDENT_BTB,
IDENT_BXF,
IDENT_BXM,
IDENT_CMR1,
IDENT_CMR2,
IDENT_CTA,
IDENT_DRB,
IDENT_GSC,
IDENT_HFA,
IDENT_HRO,
IDENT_ICA,
Expand Down

0 comments on commit 9102e00

Please sign in to comment.