Skip to content

Commit

Permalink
gridseed: Document GridSeed specifics with comments and URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
nwoolls committed Jul 24, 2014
1 parent 65a7398 commit f144c1a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 23 deletions.
7 changes: 5 additions & 2 deletions driver-dualminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,11 @@ bool dualminer_job_start(struct thr_info * const thr)
else
gc3355_scrypt_only_reset(fd);

// prevent register corruption
// otherwise device may hang (rare issue)
// See https://github.com/gridseed/gc3355-doc/blob/master/GC3355_DataSheet.pdf
// WAIT: Before start a new transaction, WAIT Cycle must be inserted.
// WAIT Cycle value is programmable register in UART and default wait
// time is UART receive 32 bits time (One DATA Cycle).
// Note: prevents register corruption
cgsleep_ms(100);
}

Expand Down
7 changes: 5 additions & 2 deletions driver-gridseed.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ bool gridseed_prepare_work(struct thr_info __maybe_unused *thr, struct work *wor
gc3355_scrypt_reset(device->device_fd);
gc3355_scrypt_prepare_work(cmd, work);

// prevent register corruption
// otherwise device may hang (rare issue)
// See https://github.com/gridseed/gc3355-doc/blob/master/GC3355_DataSheet.pdf
// WAIT: Before start a new transaction, WAIT Cycle must be inserted.
// WAIT Cycle value is programmable register in UART and default wait
// time is UART receive 32 bits time (One DATA Cycle).
// Note: prevents register corruption
cgsleep_ms(100);

// send work
Expand Down
55 changes: 36 additions & 19 deletions gc3355.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,18 +567,28 @@ void gc3355_scrypt_reset(int fd)

void gc3355_scrypt_prepare_work(unsigned char cmd[156], struct work *work)
{
// See https://github.com/gridseed/gc3355-doc/blob/master/GC3355_Register_Spec.pdf

// command header
cmd[0] = 0x55;
cmd[1] = 0xaa;
cmd[2] = 0x1f;
cmd[3] = 0x00;
cmd[0] = 0x55; // static header
cmd[1] = 0xaa; // static header
cmd[2] = 0x1f; // 0x1 (for Scrypt) | chip_id (0xf for broadcast)
cmd[3] = 0x00; // identifies the following task data, beginning with 0x00
// gc3355 supports sending batches of work at once
// in which case this would be incremented for each batch

// task data
// task data - starts at 0x0 (with 4 byte offset for header)
memcpy(cmd + 4, work->target, 32);
memcpy(cmd + 36, work->midstate, 32);
memcpy(cmd + 68, work->data, 80);

// nonce_max

// nonce min - starts at 0x23 (with 4 byte offset for header)
cmd[144] = 0x00;
cmd[145] = 0x00;
cmd[146] = 0x00;
cmd[147] = 0x00;

// nonce max - starts at 0x24 (with 4 byte offset for header)
cmd[148] = 0xff;
cmd[149] = 0xff;
cmd[150] = 0xff;
Expand All @@ -591,20 +601,27 @@ void gc3355_scrypt_prepare_work(unsigned char cmd[156], struct work *work)

void gc3355_sha2_prepare_work(unsigned char cmd[52], struct work *work)
{
// command header
cmd[0] = 0x55;
cmd[1] = 0xaa;
cmd[2] = 0x0f;
cmd[3] = 0x00; // Scrypt header sig - used by DualMiner in Dual Mode

uint8_t temp_bin[64];
memset(temp_bin, 0, 64);

memcpy(temp_bin, work->midstate, 32);
memcpy(temp_bin + 52, work->data + 64, 12);
// See https://github.com/gridseed/gc3355-doc/blob/master/GC3355_Register_Spec.pdf

// command header
cmd[0] = 0x55; // static header
cmd[1] = 0xaa; // static header
cmd[2] = 0x0f; // 0x0 (for SHA2) | chip_id (0xf for broadcast)
cmd[3] = 0x00; // identifies the following task data, beginning with 0x00
// gc3355 supports sending batches of work at once
// in which case this would be incremented for each batch

// initial nonce - starts at 0x0 (with 4 byte offset for header)
cmd[4] = 0x00;
cmd[5] = 0x00;
cmd[6] = 0x00;
cmd[7] = 0x00;

// task data - starts at 0x1 (with 4 byte offset for header)
memcpy(cmd + 8, work->midstate, 32);
memcpy(cmd + 40, temp_bin + 52, 12);
memcpy(cmd + 40, work->data + 64, 12);

// 0x1e - 0xff are for specific SHA2 unit configs, don't set without reason
}

int64_t gc3355_get_firmware_version(int fd)
Expand Down

0 comments on commit f144c1a

Please sign in to comment.