Browse Source

Corrected hash rate estimation for BF1. Only 756 out of 1024 nonces
are scanned.

Andreas Auer 12 years ago
parent
commit
9d9ba2c361
2 changed files with 49 additions and 14 deletions
  1. 39 10
      driver-bf1.c
  2. 10 4
      driver-bf1.h

+ 39 - 10
driver-bf1.c

@@ -1,5 +1,5 @@
 /*
- * Copyright 2013 Andreas Auer
+ * Copyright 2013 DI Andreas Auer
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -8,7 +8,7 @@
  */
 
 /*
- * MiniMiner One with Avalon ASIC
+ * Bitfury BF1 USB miner with Bitfury ASIC
  */
 
 #include "config.h"
@@ -217,7 +217,8 @@ static bool bf1_init(struct thr_info *thr)
 	timer_set_delay(&thr->tv_poll, &tv_now, 1000000);
 
 	info->work = 0;
-	info->prev_work = 0;
+	info->prev_work[0] = 0;
+	info->prev_work[1] = 0;
 
 	return true;
 }
@@ -249,6 +250,8 @@ static void bf1_process_results(struct thr_info *thr, struct work *work)
 	uint32_t ntime = *((uint32_t *)&work->data[68]);
 	uint32_t nbits = *((uint32_t *)&work->data[72]);
 
+	int32_t nonces = (info->rx_len / 7) - 1;
+
 	num_results = 0;
 	for(int i=0; i<info->rx_len; i+=7)
 	{
@@ -266,28 +269,43 @@ static void bf1_process_results(struct thr_info *thr, struct work *work)
 		if(bf1_rehash(work->midstate, m7, ntime, nbits, nonce))
 		{
 			submit_nonce(thr, work, nonce);
+			nonces--;
+			continue;
 		}
 		if(bf1_rehash(work->midstate, m7, ntime, nbits, nonce-0x400000))
 		{
 			submit_nonce(thr, work, nonce-0x400000);
+			nonces--;
+			continue;
 		}
 		if(bf1_rehash(work->midstate, m7, ntime, nbits, nonce-0x800000))
 		{
 			submit_nonce(thr, work, nonce-0x800000);
+			nonces--;
+			continue;
 		}
 		if(bf1_rehash(work->midstate, m7, ntime, nbits, nonce+0x2800000))
 		{
 			submit_nonce(thr, work, nonce+0x2800000);
+			nonces--;
+			continue;
 		}
 		if(bf1_rehash(work->midstate, m7, ntime, nbits, nonce+0x2C00000))
 		{
 			submit_nonce(thr, work, nonce+0x2C00000);
+			nonces--;
+			continue;
 		}
 		if(bf1_rehash(work->midstate, m7, ntime, nbits, nonce+0x400000))
 		{
 			submit_nonce(thr, work, nonce+0x400000);
+			nonces--;
+			continue;
 		}
 	}
+
+	for(int i=0; i<nonces; i++)
+		inc_hw_errors(thr);
 }
 
 //------------------------------------------------------------------------------
@@ -313,7 +331,7 @@ static int64_t bf1_scanwork(struct thr_info *thr)
 	memcpy(sendbuf + 33, info->work->data + 64, 12);
 	write(board->device_fd, sendbuf, sizeof(sendbuf));
 
-	applog(LOG_INFO, "Work Task sending");
+	applog(LOG_INFO, "Work Task sending: %d", info->work->id);
 	while(1)
 	{
 		uint8_t buffer[7];
@@ -332,16 +350,27 @@ static int64_t bf1_scanwork(struct thr_info *thr)
 	}
 	applog(LOG_INFO, "Work Task accepted");
 
-	if(info->prev_work)
+	applog(LOG_INFO, "Nonces sent back: %d", info->rx_len / 7);
+/*
+	if(info->prev_work[1])
+	{
+		applog(LOG_INFO, "PREV[1]");
+		bf1_process_results(thr, info->prev_work[1]);
+		work_completed(board, info->prev_work[1]);
+		info->prev_work[1] = 0;
+	}
+*/
+	if(info->prev_work[0])
 	{
-		bf1_process_results(thr, info->prev_work);
-		work_completed(board, info->prev_work);
-		info->prev_work = 0;
+		applog(LOG_INFO, "PREV[0]");
+		bf1_process_results(thr, info->prev_work[0]);
 	}
-	info->prev_work = info->work;
+	info->prev_work[1] = info->prev_work[0];
+	info->prev_work[0] = info->work;
 	info->work = 0;
 
-	hashes = 0xffffffff;
+	//hashes = 0xffffffff;
+	hashes = 0xBD000000;
 	applog(LOG_INFO, "WORK completed");
 
 	return hashes;

+ 10 - 4
driver-bf1.h

@@ -1,8 +1,14 @@
 /*
- * driver-s6lx75.h
+ * Copyright 2013 DI Andreas Auer
  *
- *  Created on: 09.06.2013
- *      Author: andreas
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.  See COPYING for more details.
+ *
+ *  Created on: 09.10.2013
+ *      Author: DI Andreas Auer
+ *        Mail: aauer1@gmail.com
  */
 
 #ifndef DRIVER_BF1_H_
@@ -36,7 +42,7 @@ struct BF1Info
 
 	struct BF1Identity id;
 	struct work *work;
-	struct work *prev_work;
+	struct work *prev_work[2];
 
 	char rx_buffer[1024];
 	uint32_t rx_len;