Vendor ASIC Drivers
Overview
This area contains vendor-specific ASIC miner drivers that are neither the generic CPU/GPU/FPGA paths nor the Avalon/Bitmain/USB-stick families. Each file registers a struct device_drv and plugs one hardware protocol into the miner core through deviceapi.h and miner.h callbacks: detection (.drv_detect, .lowl_match, .lowl_probe), thread setup, one of the miner loops (minerloop_queue, minerloop_async, hash_queued_work, minerloop_scanhash, or an Icarus-derived loop), work submission, result polling, stats, and optional TUI/RPC --set-device controls.
The common flow is: detect a physical or proxy device, allocate a cgpu_info with one or more logical processors, initialise per-device/per-chip state in .thread_init or .thread_prepare, convert BFGMiner struct work into the vendor wire format, record enough ID/slot/task state to match returned nonces, and call submit_nonce() plus hashes_done2() when results arrive. Drivers use the core queue APIs (get_work(), get_queued(), flush_queue(), HASH_ADD on queued_work, DL_APPEND lists, and thr->queue_full) rather than owning pool selection themselves.
The owned drivers fall into several protocol families:
- driver-aan.c and driver-aan.h implement a shared SPI protocol for AAN/A1-like chips. The shared code handles chip reset/BIST, four-slot job IDs, PLL/difficulty controls, register polling, nonce result parsing, and queue fullness across managed processors. driver-jingtian.c is the concrete board driver: it opens Linux spidev, drives chip-select and reset GPIOs, prepends a Jingtian header before every AAN command, reads two extra temperature bytes after AAN registers, and delegates queueing/polling/API status to the shared AAN callbacks.
- driver-bfsb.c, driver-bfx.c, and driver-metabank.c are Bitfury board wrappers over
libbitfuryand driver-bitfury.h. They differ mainly in low-level bus selection: BFSB banks the system SPI bus withspi_bfsb_select_bank(), BFX opens an FT232H MPSSE device and exposes it as aspi_port, and Metabank scans 32 I2C-controlled slots viatm_i2cbefore routing system SPI to the selected slot. All three reuse Bitfury job preparation, polling, nonce processing, enable/disable, and status reporting. - driver-cairnsmore.c and driver-zeusminer.c customise the Icarus serial protocol from driver-icarus.h. Cairnsmore detects the
Cairnsmore1VCOM product, sets two-FPGA timing defaults, optionally probes dynamic clock support with special 64-byte commands, and then mutates the inheritedicarus_drv. ZeusMiner builds a scrypt-specific golden work probe, derives read timing from the golden nonce, injects the clock/difficulty header inzeusminer_job_prepare(), and also initialises by copyingicarus_drv. - driver-alchemist.c, driver-drillbit.c, driver-hashfast.c, and driver-rockminer.c are direct serial/VCOM protocols. Alchemist requires custom firmware, scans chips/cores using diagnostic golden work, writes 113-byte job/config frames, and uses
minerloop_scanhash. Drillbit exchanges single-letter commands (I,R,C,W,E,T,L) and maps one serial board to many chip processors. HashFast frames messages with an0xaaheader, CRC8, opcodes such asHFOP_USB_INIT,HFOP_HASH,HFOP_NONCE, andHFOP_STATUS, queues one pending work per core, and can change per-chip clocks once cores go idle. Rockminer detects R-BOX/RX-BOX devices with golden work, bisects chip count, then responds to 8-byte nonce/task/request messages while retaining two task slots per chip. - driver-cointerra.c and driver-cointerra.h implement Cointerra GoldStrike USB bulk messaging. Messages are 64-byte
ZZframes with offsets defined in the header. Detection opens libusb interface 0, sends reset-init, requests device info, and creates one processor per reported core. Runtime queueing responds to request-work counts, assigns 16-bit work IDs, records work incgpu->queued_work, parses match/work-done/status/info/debug messages, and exposes detailed telemetry fromstruct cointerra_info. - driver-klondike.c and driver-klondike.h implement a libusb command/reply protocol for Klondike K1/K16/K64. A detached reply thread continuously reads 15-byte
KLINEreplies into a locked free/used list. Queue fullness actively sends work when device work queues have capacity, keeps old work inqueued_workfor nonce matching, handles overheat by aborting and disabling devices, and maintains per-device stats/clock/fan/temperature state. - driver-knc.c is the original KnC SPI/I2C driver. It detects ASICs through
/dev/i2c-2, creates 192 logical cores per chip, opens/dev/spidev1.0, batches submit/flush commands into 4096-byte SPI transactions, matches replies by work ID, and reads temperature/DCDC telemetry from per-die I2C devices. It also disables cores temporarily after repeated hardware errors. - driver-kncasic.c is the newer KnC Jupiter/Neptune transport driver. It depends on knc-asic/knc-transport.h and knc-asic/knc-asic.h, creates cgpus per ASIC/die, runs a dedicated SPI transport thread with ring buffers, tracks per-core work slots, decodes reports, and drives a custom
hash_driver_work()loop that repeatedly calls.scanworkand flushes on work restarts. - driver-titan.c, titan-asic.c, and titan-asic.h implement KnC Titan scrypt ASIC support on top of the same KnC transport primitives. Detection scans ASIC/die combinations,
knc_titan_init()configures per-core nonce ranges and Titan setup parameters, queueing holds a shared local work queue, and polling sends urgent or normal work through per-core or FPGA-parallel helpers in titan-asic.c, processes reports, maintains rolling die hash rate, and periodically reconfigures dies that stop returning shares. - driver-minion.c is a Linux SPI driver for Minion chips. It probes chip signatures over
/dev/spidev0.0, maps each core to a logical processor, programs PLL/core-enable/temperature registers, queues register-format tasks, polls FIFO result records, distributes hash accounting across enabled cores, and reinitialises chips on timeout. - driver-minergate.c is a Unix-domain-socket proxy protocol used by external miner controllers. Detection connects to default sockets such as
/tmp/connection_pipeand/tmp/connection_pipe_sp30, negotiates packet shape by protocol version, queues work into request packets, reads fixed-size response packets, submits noffset nonces, and optionally reads external temperature stats from/var/run/mg_rate_temp.
Coverage
- driver-aan.c
- driver-aan.h
- driver-alchemist.c
- driver-bfsb.c
- driver-bfx.c
- driver-cairnsmore.c
- driver-cointerra.c
- driver-cointerra.h
- driver-drillbit.c
- driver-hashfast.c
- driver-jingtian.c
- driver-klondike.c
- driver-klondike.h
- driver-knc.c
- driver-kncasic.c
knc-asic/**- driver-metabank.c
- driver-minergate.c
- driver-minion.c
- driver-rockminer.c
- driver-titan.c
- titan-asic.c
- titan-asic.h
- driver-zeusminer.c
Coupling
- If
struct worknonce, midstate,data[0x40],nonce_diff, ordevice_id/subidsemantics change, audit every work formatter in this doc. The byte layouts are handwritten in driver-aan.c, driver-alchemist.c, driver-cointerra.c, driver-drillbit.c, driver-hashfast.c, driver-klondike.c, driver-knc.c, driver-kncasic.c, driver-minergate.c, driver-minion.c, driver-rockminer.c, driver-titan.c, titan-asic.c, and driver-zeusminer.c, and most result paths match nonces back by driver-assigned IDs rather than by recomputing full work context. - If low-level SPI buffering in lowl-spi.h changes, verify the drivers that copy or wrap
struct spi_port: driver-bfsb.c, driver-bfx.c, driver-jingtian.c, driver-knc.c, driver-metabank.c, and driver-minion.c. Several comments warn that the struct must be initialised carefully, and the wrappers set customtxrx,userp, chip-select, GPIO, andreprfields before shared protocol code uses it. - If driver-bitfury.h or
libbitfurychanges nonce encoding, chip init, or oscillator controls, update driver-bfsb.c, driver-bfx.c, driver-metabank.c, and the Drillbit nonce adjustment in driver-drillbit.c. The first three directly reuse Bitfury callbacks; Drillbit appliesbitfury_decnonce()andbitfury_fudge_nonce()to serial results beforesubmit_nonce(). - If the Icarus driver callbacks or
struct ICARUS_INFOfields change, check driver-cairnsmore.c and driver-zeusminer.c. Both initialise themselves by copyingicarus_drvand then overriding selected callbacks, so missing a new required Icarus field can silently break detection or scan timing. - If the Cointerra 64-byte message contract changes, update both driver-cointerra.h offsets and the parser/formatter in driver-cointerra.c. Request counts, work IDs, status fields, temperatures, pipe maps, and debug counters are all extracted by raw byte offsets, and queue flow depends on
CTA_RECV_REQWORKchangingrequestedandthr->queue_full. - If the Klondike USB reply size or command set changes, update both driver-klondike.c packet structs and driver-klondike.h state. The detached reply thread, synchronous
GetReply()matching, queued-work lookup bydev*256 + workid, and overheat/recovery logic all assume 15-byteKLINEreplies and stableKLN_CMD_*values. - If KnC transport request/response helpers in knc-asic/knc-transport.h or knc-asic/knc-asic.h change, verify both driver-kncasic.c and titan-asic.c/driver-titan.c. driver-kncasic.c batches async transfers into response descriptors, while Titan uses synchronous per-core and FPGA commands; both decode
struct knc_reportand depend on version-specific request builders. - If miner queue-loop semantics around
thr->queue_full,queue_append,queue_flush, orpollchange, test the queue drivers together: driver-aan.c, driver-cointerra.c, driver-hashfast.c, driver-knc.c, driver-minergate.c, driver-minion.c, driver-rockminer.c, and driver-titan.c. These drivers use queue fullness as device backpressure and often re-enable queueing only after a status/result packet arrives. - If serial open/read timeout behaviour changes in lowl-vcom.h or serial helpers, re-test driver-alchemist.c, driver-cairnsmore.c, driver-drillbit.c, driver-hashfast.c, driver-rockminer.c, and driver-zeusminer.c. Detection often relies on short reads/timeouts to delimit probe responses rather than explicit framing.
Risks
- driver-minergate.c currently rejects every explicit
protoversetting becauseminergate_init_protover()checksif (i != MPV_SP10 || i != MPV_SP30). If a user needs to override protocol version through--set-device, detection cannot accept it even though the rest of the file supports both SP10 and SP30 packet layouts. - driver-titan.c exposes a
dieset-device command, butdie_test_and_add()anddie_disable()mark addition/deletion as TODO/not implemented. If callers expect runtime die enable/disable to take effect, they can receive errors or a reconfigure-only path while the actual die set remains unchanged. - driver-drillbit.c parses chip IDs from result packets in
drillbit_get_work_results()and assignsstruct thr_info *thr = proc->thr[0]before checking whetherdrillbit_find_proc()returned NULL. A malformed or newer firmware result with an out-of-range chip ID can dereference a null processor instead of just counting a hardware error. - driver-aan.c implements shared AAN queueing but leaves
aan_queue_flush()as TODO; driver-jingtian.c wires this flush callback directly. On restart/stale-work events, the hardware queue may continue returning old job IDs until overwritten, increasing bad-job/hardware-error handling inaan_scanwork(). - driver-rockminer.c also has an empty
rockminer_queue_flush(). Combined with two alternating task slots instruct rockminer_chip_data, stale work relies on timeout/resend logic inrockminer_poll()rather than an explicit hardware flush, so lost task-request packets can cause resends or delayed queue recovery.