Browse Source

Merge pull request #525 from nwoolls/task/gridseed-comments

gridseed: Document GridSeed specifics with comments and URLs
Luke-Jr 11 years ago
parent
commit
e21566e50a
3 changed files with 46 additions and 23 deletions
  1. 5 2
      driver-dualminer.c
  2. 5 2
      driver-gridseed.c
  3. 36 19
      gc3355.c

+ 5 - 2
driver-dualminer.c

@@ -192,8 +192,11 @@ bool dualminer_job_start(struct thr_info * const thr)
 		else
 		else
 			gc3355_scrypt_only_reset(fd);
 			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);
 		cgsleep_ms(100);
 	}
 	}
 
 

+ 5 - 2
driver-gridseed.c

@@ -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_reset(device->device_fd);
 	gc3355_scrypt_prepare_work(cmd, work);
 	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);
 	cgsleep_ms(100);
 	
 	
 	// send work
 	// send work

+ 36 - 19
gc3355.c

@@ -567,18 +567,28 @@ void gc3355_scrypt_reset(int fd)
 
 
 void gc3355_scrypt_prepare_work(unsigned char cmd[156], struct work *work)
 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
 	// 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 + 4, work->target, 32);
 	memcpy(cmd + 36, work->midstate, 32);
 	memcpy(cmd + 36, work->midstate, 32);
 	memcpy(cmd + 68, work->data, 80);
 	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[148] = 0xff;
 	cmd[149] = 0xff;
 	cmd[149] = 0xff;
 	cmd[150] = 0xff;
 	cmd[150] = 0xff;
@@ -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)
 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 + 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)
 int64_t gc3355_get_firmware_version(int fd)