USB Stick and BitFury Drivers
Overview
This area owns the small USB/serial miners that either speak a simple stick-miner protocol directly or wrap a BitFury/GC3355 ASIC protocol behind HID, USB bulk, MCP2210 SPI, or virtual COM transport.
The shared BitFury path is split between libbitfury.c/libbitfury.h and the concrete drivers. libbitfury.c is the low-level BitFury SPI protocol library: it formats work into struct bitfury_payload, derives the address-translated vector with bitfury_payload_to_atrvec, emits reinitialise/shutdown/frequency SPI sequences, probes chains with libbitfury_detectChips1, decodes chip nonces with bitfury_decnonce, and verifies/fudges candidate nonces with bitfury_fudge_nonce. driver-bitfury.c is the direct GPIO/SPI BitFury driver: detection calls spi_init and libbitfury_detectChips1, thread init allocates one struct bitfury_device per processor, and bitfury_do_io is the common asynchronous poller that walks all managed chips, emits spi_emit_break/spi_emit_fasync/spi_emit_data, rotates the 16-word nonce ring, handles job transitions, submits decoded nonces, tracks frequency, and reinitialises chips after desync or error bursts.
Several USB BitFury products reuse that common lifecycle while supplying only the transport and board controls:
- driver-littlefury.c wraps BitFury SPI in a framed serial packet protocol (
0xabcd, opcode, payload length, CRC). It probes with a version packet, powers chips throughLFOP_REGPWR, implementslittlefury_txrxas thespi_portbackend, then delegates work preparation, polling, nonce accounting, and API/TUI clock controls to driver-bitfury.c. - driver-nanofury.c talks to an MCP2210 USB-to-SPI bridge. It toggles GPIOs for LED, SCK override, and power, configures MCP2210 SPI mode/speed, chunks transfers at 60 bytes, then creates BitFury chip records whose
spi_port.txrxisnanofury_spi_txrx. Its poll path adds LED identify handling aroundbitfury_do_io. - driver-hashbuster.c uses HID reports with 64-byte command/response frames. It detects the board with command
0xfe, maps BitFury SPI operations to commands0x01/0x02/0x03, limits transfers to 62 bytes, and reads temperature with command0x04while mining through the common BitFury async loop. - driver-hashbusterusb.c is the USB bulk variant. It opens endpoint pair
0x81/0x01, works around corrupt0xffresponses by retrying, detects/starts PSU and serial number through board commands, maps SPI to commands0x01/0x02/0x03, and layers PSU voltage, VRM lock/unlock, RGB identify, and stats over the common BitFury loop. - driver-bifury.c is BitFury-family but firmware-driven rather than raw SPI. Detection opens the virtual COM port, sends
version, parses firmware/hardware/chip count, and mining usesminerloop_queue:bifury_queue_appendsends textwork <76-byte-header-hex> <jobid>,bifury_pollreads newline-delimitedsubmit,job,temp,hwerror, andneedworkmessages, andbifury_send_clocksends per-chip oscillator assignments. - driver-twinfury.c is another firmware protocol. Commands are prefixed with
0xDEADBEEF; detection sendsIandR, init optionally queries voltage withV,twinfury_job_preparefills a 46-byte work buffer with midstate and header tail,twinfury_job_startsends commandW, andtwinfury_pollqueries each chip withQ, decodes BitFury nonces withbitfury_decnonce/bitfury_fudge_nonce, handles LED flash and temperature commands, and supports voltage adjustment for newer firmware.
The Icarus-style stick path is centered in driver-icarus.c. icarus_detect_custom probes a serial port by sending a golden 64-byte work item, expecting a known nonce, optionally probing work division, then creates a multi-processor cgpu_info. At runtime, icarus_prepare allocates per-thread state, icarus_init opens the serial device and prepares timing/work division, icarus_job_prepare serialises work as 32-byte midstate + 20 filler bytes + 12 header bytes, icarus_job_start writes it, and icarus_scanhash waits for a fixed-size nonce reply or timeout/restart. It estimates hashes from elapsed time and calibrated Hs, keeps the last two work items for late nonces, reopens flaky serial ports according to the configured reopen mode, and supports timing calibration through the timing set-device option. driver-erupter.c reuses this driver by copying icarus_drv at init and overriding detection metadata, low-level matching, device names (BES/BEE), and identify behavior.
The GC3355/GridSeed/DualMiner path uses serial commands with 0x55aa headers. gc3355.c/gc3355.h hold the command tables and helpers for reset, PLL configuration, SHA-2 gating, scrypt init/reset, work packing, firmware detection, and throttled serial I/O. driver-gridseed.c is a scrypt minerloop_scanhash driver: detection reads firmware via gc3355_get_firmware_version, infers chip count, calls gc3355_init_miner, sends prepared scrypt work after gc3355_scrypt_reset, polls 12-byte responses, and accounts hashes from elapsed time and configured frequency. driver-dualminer.c adapts the Icarus lifecycle for DualMiner hardware: it uses icarus_detect_custom with DualMiner golden work/nonce, selects SHA-2 or scrypt mode from build/runtime settings, initialises the GC3355 through gc3355_init_dualminer, prepares work through gc3355_sha2_prepare_work or gc3355_scrypt_prepare_work, and tears down serial control lines on shutdown.
driver-hashbusteravalon.c is a small product-specific wrapper rather than part of the BitFury helper stack. It matches HashBuster Avalon USB devices, seeds a klondike_info with defaults, and delegates probing/runtime to the Klondike driver by replacing hashbusteravalon_drv from klondike_drv during driver init.
Coverage
Owned globs:
- driver-bitfury.c
- driver-bitfury.h
- libbitfury.c
- libbitfury.h
- driver-bifury.c
- driver-littlefury.c
- driver-nanofury.c
- driver-twinfury.c
- driver-twinfury.h
- driver-erupter.c
- driver-icarus.c
- driver-hashbuster.c
- driver-hashbusterusb.c
- driver-hashbusteravalon.c
- driver-dualminer.c
- driver-gridseed.c
- gc3355.c
- gc3355.h
Coupling
- If
struct bitfury_deviceorstruct bitfury_payloadchanges in libbitfury.h, update all BitFury transport drivers that allocate or preseed these structs: driver-bitfury.c, driver-littlefury.c, driver-nanofury.c, driver-hashbuster.c, and driver-hashbusterusb.c. These drivers initialise only selected fields before calling shared helpers, so new required fields will otherwise remain zeroed silently. - If libbitfury.c changes SPI command order, response sizes, nonce decoding, or
bitfury_payload_to_atrvec, verify everyspi_port.txrxadapter in driver-littlefury.c, driver-nanofury.c, driver-hashbuster.c, and driver-hashbusterusb.c. The shared poller in driver-bitfury.c assumes a0x11word response fromspi_emit_data(..., 19 * 4)and transport-specific chunking must preserve that byte stream exactly. - If
bitfury_do_ioin driver-bitfury.c changes processor ordering assumptions, verify detection/init paths in the BitFury transport drivers. The poller assumes chips on the same SPI bus are grouped and in sequentialfasyncorder; drivers such as driver-nanofury.c and driver-hashbusterusb.c assignfasyncfrom processor IDs during init/probe. - If driver-icarus.c changes
ICARUS_INFOsemantics, job preparation, or shutdown expectations, check subclasses that copy or call it: driver-erupter.c copiesicarus_drv, and driver-dualminer.c usesicarus_detect_custom,icarus_job_start,do_icarus_close, andstruct icarus_statefields directly. - If GC3355 command formats or delay constants change in gc3355.c, verify both driver-gridseed.c and driver-dualminer.c. GridSeed sends scrypt work directly with
gc3355_scrypt_prepare_work, while DualMiner depends on both SHA-2 and scrypt preparation plus serial control-line setup. - If low-level serial/HID/USB timeout behavior changes, recheck probe functions in driver-icarus.c, driver-bifury.c, driver-twinfury.c, driver-littlefury.c, driver-hashbuster.c, driver-hashbusterusb.c, and driver-gridseed.c; most probes send active work/configuration to candidate ports and decide identity from one short response window.
Risks
- driver-bitfury.c is fragile around nonce-ring synchronisation.
bitfury_do_iorotates 16-word buffers based onactive, treats previous-nonce mismatches as hardware errors, and forces reinitialisation after repeated desync; if response ordering orfasyncsequencing changes, valid nonces can be discarded or counted as hardware errors. - gc3355.c intentionally sleeps after every
gc3355_writebecause comments note reproducible register corruption on Linux when writes are too close together. Removing or shorteningGC3355_WRITE_DELAY_MScan corrupt GC3355 registers in driver-gridseed.c and driver-dualminer.c even if it appears fine on slower serial stacks. - driver-icarus.c sends golden work during detection to arbitrary serial scan targets and has comments warning that other devices must tolerate it. Changing the golden payload or probe flow can disturb non-Icarus devices on
--scan-serialpaths or cause false claims beforeserial_claim_v.