Skip to content

Commit

Permalink
Improvements to support for BitBurner boards
Browse files Browse the repository at this point in the history
--bitburner-fury-options allows avalon-options to be overridden for
BitBurner Fury Boards, facilitating simultanous use of BitBurner XX
and BitBurner Fury boards

More sensible defaults for BitBurner boards, so cgminer should do something
sensible without any command line args
  • Loading branch information
roybadami committed Oct 19, 2013
1 parent eed0afc commit c69a130
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 10 deletions.
8 changes: 6 additions & 2 deletions ASIC-README
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ ASIC SPECIFIC COMMANDS
--avalon-options <arg> Set avalon options baud:miners:asic:timeout:freq
--avalon-temp <arg> Set avalon target temperature (default: 50)
--bflsc-overheat <arg> Set overheat temperature where BFLSC devices throttle, 0 to disable (default: 90)
--bitburner-voltage <arg> Set BitBurner core voltage, in millivolts
--bitburner-fury-options <arg> Override avalon-options for BitBurner Fury boards baud:miners:asic:timeout:freq
--bitburner-fury-voltage <arg> Set BitBurner Fury core voltage, in millivolts
--bitburner-voltage <arg> Set BitBurner (Avalon) core voltage, in millivolts
--klondike-options <arg> Set klondike options clock:temp1:temp2:fan


Expand All @@ -126,7 +128,9 @@ Avalon commands:
--avalon-freq <arg> Set frequency range for avalon-auto, single value or range
--avalon-options <arg> Set avalon options baud:miners:asic:timeout:freq
--avalon-temp <arg> Set avalon target temperature (default: 50)
--bitburner-voltage <arg> Set BitBurner core voltage, in millivolts
--bitburner-fury-options <arg> Override avalon-options for BitBurner Fury boards baud:miners:asic:timeout:freq
--bitburner-fury-voltage <arg> Set BitBurner Fury core voltage, in millivolts
--bitburner-voltage <arg> Set BitBurner (Avalon) core voltage, in millivolts


Avalon auto will enable dynamic overclocking gradually increasing and
Expand Down
4 changes: 3 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ ASIC only options:
--avalon-options <arg> Set avalon options baud:miners:asic:timeout:freq
--avalon-temp <arg> Set avalon target temperature (default: 50)
--bflsc-overheat <arg> Set overheat temperature where BFLSC devices throttle, 0 to disable (default: 90)
--bitburner-voltage <arg> Set BitBurner core voltage, in millivolts
--bitburner-fury-options <arg> Override avalon-options for BitBurner Fury boards baud:miners:asic:timeout:freq
--bitburner-fury-voltage <arg> Set BitBurner Fury core voltage, in millivolts
--bitburner-voltage <arg> Set BitBurner (Avalon) core voltage, in millivolts

See ASIC-README for more information regarding these.

Expand Down
11 changes: 11 additions & 0 deletions cgminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ char *opt_icarus_timing = NULL;
bool opt_worktime;
#ifdef USE_AVALON
char *opt_avalon_options = NULL;
char *opt_bitburner_fury_options = NULL;
#endif
#ifdef USE_KLONDIKE
char *opt_klondike_options = NULL;
Expand Down Expand Up @@ -1035,6 +1036,13 @@ static char *set_avalon_options(const char *arg)

return NULL;
}

static char *set_bitburner_fury_options(const char *arg)
{
opt_set_charp(arg, &opt_bitburner_fury_options);

return NULL;
}
#endif

#ifdef USE_KLONDIKE
Expand Down Expand Up @@ -1254,6 +1262,9 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--bitburner-fury-voltage",
opt_set_intval, NULL, &opt_bitburner_fury_core_voltage,
"Set BitBurner Fury core voltage, in millivolts"),
OPT_WITH_ARG("--bitburner-fury-options",
set_bitburner_fury_options, NULL, NULL,
"Override avalon-options for BitBurner Fury boards baud:miners:asic:timeout:freq"),
#endif
#ifdef USE_KLONDIKE
OPT_WITH_ARG("--klondike-options",
Expand Down
29 changes: 22 additions & 7 deletions driver-avalon.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ int opt_bitburner_fury_core_voltage = BITBURNER_FURY_DEFAULT_CORE_VOLTAGE;
bool opt_avalon_auto;

static int option_offset = -1;
static int bbf_option_offset = -1;

static int avalon_init_task(struct avalon_task *at,
uint8_t reset, uint8_t ff, uint8_t fan,
Expand Down Expand Up @@ -400,18 +401,18 @@ static int avalon_calc_timeout(int frequency)
}

static bool get_options(int this_option_offset, int *baud, int *miner_count,
int *asic_count, int *timeout, int *frequency)
int *asic_count, int *timeout, int *frequency, char *options)
{
char buf[BUFSIZ+1];
char *ptr, *comma, *colon, *colon2, *colon3, *colon4;
bool timeout_default;
size_t max;
int i, tmp;

if (opt_avalon_options == NULL)
if (options == NULL)
buf[0] = '\0';
else {
ptr = opt_avalon_options;
ptr = options;
for (i = 0; i < this_option_offset; i++) {
comma = strchr(ptr, ',');
if (comma == NULL)
Expand Down Expand Up @@ -754,7 +755,7 @@ static void bitburner_get_version(struct cgpu_info *avalon)
static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found)
{
int baud, miner_count, asic_count, timeout, frequency;
int this_option_offset = ++option_offset;
int this_option_offset;
struct avalon_info *info;
struct cgpu_info *avalon;
bool configured;
Expand All @@ -768,12 +769,14 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
timeout = AVALON_DEFAULT_TIMEOUT;
frequency = AVALON_DEFAULT_FREQUENCY;

configured = get_options(this_option_offset, &baud, &miner_count,
&asic_count, &timeout, &frequency);

if (!usb_init(avalon, dev, found))
goto shin;

this_option_offset = usb_ident(avalon) == IDENT_BBF ? ++bbf_option_offset : ++option_offset;
configured = get_options(this_option_offset, &baud, &miner_count,
&asic_count, &timeout, &frequency,
(usb_ident(avalon) == IDENT_BBF && opt_bitburner_fury_options != NULL) ? opt_bitburner_fury_options : opt_avalon_options);

/* Even though this is an FTDI type chip, we want to do the parsing
* all ourselves so set it to std usb type */
avalon->usbdev->usb_type = USB_TYPE_STD;
Expand All @@ -794,6 +797,18 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
info->asic_count = asic_count;
info->timeout = timeout;
info->frequency = frequency;
} else if (usb_ident(avalon) == IDENT_BTB) {
info->baud = AVALON_IO_SPEED;
info->miner_count = BITBURNER_XX_DEFAULT_MINER_NUM;
info->asic_count = BITBURNER_DEFAULT_ASIC_NUM;
info->timeout = AVALON_DEFAULT_TIMEOUT;
info->frequency = AVALON_DEFAULT_FREQUENCY;
} else if (usb_ident(avalon) == IDENT_BBF) {
info->baud = AVALON_IO_SPEED;
info->miner_count = BITBURNER_FURY_DEFAULT_MINER_NUM;
info->asic_count = BITBURNER_DEFAULT_ASIC_NUM;
info->timeout = BITBURNER_FURY_DEFAULT_TIMEOUT;
info->frequency = BITBURNER_FURY_DEFAULT_FREQUENCY;
} else {
info->baud = AVALON_IO_SPEED;
info->miner_count = AVALON_DEFAULT_MINER_NUM;
Expand Down
6 changes: 6 additions & 0 deletions driver-avalon.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
#define AVALON_MAX_MINER_NUM 0x100
#define AVALON_DEFAULT_ASIC_NUM 0xA

#define BITBURNER_XX_DEFAULT_MINER_NUM 16
#define BITBURNER_FURY_DEFAULT_MINER_NUM 128
#define BITBURNER_DEFAULT_ASIC_NUM 10
#define BITBURNER_FURY_DEFAULT_FREQUENCY 256
#define BITBURNER_FURY_DEFAULT_TIMEOUT 50

#define AVALON_AUTO_CYCLE 1024

#define AVALON_FTDI_READSIZE 510
Expand Down
1 change: 1 addition & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,7 @@ extern char *opt_icarus_timing;
extern bool opt_worktime;
#ifdef USE_AVALON
extern char *opt_avalon_options;
extern char *opt_bitburner_fury_options;
#endif
#ifdef USE_KLONDIKE
extern char *opt_klondike_options;
Expand Down

1 comment on commit c69a130

@ckolivas
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementing a new option like this allows you to not try and maintain backward compatibility with the --avalon-options parameters. Since some of them are irrelevant to these new boards you could make --bitburner-fury-options not need to take the baud, asic and timeout values since baud is ignored, asic is constant and timeout can just be set to D.

When you're doing more than 2 else if {} statements it would be cleaner to use a switch {} statement.

Please sign in to comment.