Browse Source

Merge commit '4a88fd2' into bfgminer-2.6.x

Luke Dashjr 13 years ago
parent
commit
254379a03c
3 changed files with 36 additions and 15 deletions
  1. 18 0
      FPGA-README
  2. 2 1
      Makefile.am
  3. 16 14
      bitforce-firmware-flash.c

+ 18 - 0
FPGA-README

@@ -1,6 +1,7 @@
 
 
 This README contains extended details about FPGA mining with cgminer
 This README contains extended details about FPGA mining with cgminer
 
 
+
 Bitforce
 Bitforce
 
 
 --bfl-range         Use nonce range on bitforce devices if supported
 --bfl-range         Use nonce range on bitforce devices if supported
@@ -18,6 +19,23 @@ you can change the bitstream firmware on BitFORCE Singles. It is untested with
 other devices. Use at your own risk! Windows users may use Butterfly Labs
 other devices. Use at your own risk! Windows users may use Butterfly Labs
 EasyMiner to change firmware.
 EasyMiner to change firmware.
 
 
+To compile:
+ make bitforce-firmware-flash
+To flash your BFL, specify the BFL port and the flash file e.g.:
+ sudo ./bitforce-firmware-flash /dev/ttyUSB0 alphaminer_832.bfl
+It takes a bit under 3 minutes to flash a BFL and shows a progress % counter
+Once it completes, you may also need to wait about 15 seconds,
+then power the BFL off and on again
+
+If you get an error at the end of the BFL flash process stating:
+ "Error reading response from ZBX"
+it may have worked successfully anyway.
+Test mining on it to be sure if it worked or not.
+
+You need to give cgminer about 10 minutes mining with the BFL to be sure of
+the MH/s value reported with the changed firmware - and the MH/s reported
+will be less than the firmware speed since you lose work on every block change.
+
 
 
 Icarus
 Icarus
 
 

+ 2 - 1
Makefile.am

@@ -10,7 +10,8 @@ endif
 EXTRA_DIST	= example.conf m4/gnulib-cache.m4 linux-usb-bfgminer \
 EXTRA_DIST	= example.conf m4/gnulib-cache.m4 linux-usb-bfgminer \
 		  api-example.php miner.php	\
 		  api-example.php miner.php	\
 		  API.class API.java api-example.c windows-build.txt \
 		  API.class API.java api-example.c windows-build.txt \
-		  bitstreams/* API-README FPGA-README SCRYPT-README
+		  bitstreams/* API-README FPGA-README SCRYPT-README \
+		  bitforce-firmware-flash.c
 
 
 SUBDIRS		= lib compat ccan
 SUBDIRS		= lib compat ccan
 
 

+ 16 - 14
bitforce-firmware-flash.c

@@ -18,9 +18,9 @@
 #define BFL_FILE_MAGIC   "BFLDATA"
 #define BFL_FILE_MAGIC   "BFLDATA"
 #define BFL_UPLOAD_MAGIC "NGH-STREAM"
 #define BFL_UPLOAD_MAGIC "NGH-STREAM"
 
 
-#define myassert(expr, n, ...)  do {  \
-	if (!(expr))  \
-	{  \
+#define myassert(expr, n, ...) \
+do {  \
+	if (!(expr)) {  \
 		fprintf(stderr, __VA_ARGS__);  \
 		fprintf(stderr, __VA_ARGS__);  \
 		return n;  \
 		return n;  \
 	}  \
 	}  \
@@ -28,13 +28,14 @@
 
 
 #define ERRRESP(buf)  buf, (buf[strlen(buf)-1] == '\n' ? "" : "\n")
 #define ERRRESP(buf)  buf, (buf[strlen(buf)-1] == '\n' ? "" : "\n")
 
 
-#define WAITFOROK(n, msg)  do {  \
+#define WAITFOROK(n, msg) \
+do {  \
 	myassert(fgets(buf, sizeof(buf), BFL), n, "Error reading response from " msg "\n");  \
 	myassert(fgets(buf, sizeof(buf), BFL), n, "Error reading response from " msg "\n");  \
 	myassert(!strcmp(buf, "OK\n"), n, "Invalid response from " msg ": %s%s", ERRRESP(buf));  \
 	myassert(!strcmp(buf, "OK\n"), n, "Invalid response from " msg ": %s%s", ERRRESP(buf));  \
 } while(0)
 } while(0)
 
 
-int
-main(int argc, char**argv) {
+int main(int argc, char**argv)
+{
 	myassert(argc == 3, 1, "Usage: %s <serialdev> <firmware.bfl>\n", argv[0]);
 	myassert(argc == 3, 1, "Usage: %s <serialdev> <firmware.bfl>\n", argv[0]);
 	setbuf(stdout, NULL);
 	setbuf(stdout, NULL);
 	
 	
@@ -79,15 +80,14 @@ main(int argc, char**argv) {
 	printf("OK, sending...\n");
 	printf("OK, sending...\n");
 	
 	
 	// Actual firmware upload
 	// Actual firmware upload
-	for (long i = 0, j = 0; i < FWlen; ++i)
-	{
+	long i, j;
+	for (i = 0, j = 0; i < FWlen; ++i) {
 		myassert(1 == fread(&n8, sizeof(n8), 1, FW), 0x30, "Error reading data from firmware file\n");
 		myassert(1 == fread(&n8, sizeof(n8), 1, FW), 0x30, "Error reading data from firmware file\n");
 		if (5 == i % 6)
 		if (5 == i % 6)
 			continue;
 			continue;
 		n8 ^= 0x2f;
 		n8 ^= 0x2f;
 		myassert(1 == fwrite(&n8, sizeof(n8), 1, BFL), 0x31, "Error sending data to device\n");
 		myassert(1 == fwrite(&n8, sizeof(n8), 1, BFL), 0x31, "Error sending data to device\n");
-		if (!(++j % 0x400))
-		{
+		if (!(++j % 0x400)) {
 			myassert(1 == fwrite(">>>>>>>>", 8, 1, BFL), 0x32, "Error sending block-finish to device\n");
 			myassert(1 == fwrite(">>>>>>>>", 8, 1, BFL), 0x32, "Error sending block-finish to device\n");
 			printf("\r%5.2f%% complete", (double)i * 100. / (double)FWlen);
 			printf("\r%5.2f%% complete", (double)i * 100. / (double)FWlen);
 			WAITFOROK(0x32, "block-finish");
 			WAITFOROK(0x32, "block-finish");
@@ -95,12 +95,14 @@ main(int argc, char**argv) {
 	}
 	}
 	printf("\r100%% complete :)\n");
 	printf("\r100%% complete :)\n");
 	myassert(1 == fwrite(">>>>>>>>", 8, 1, BFL), 0x3f, "Error sending upload-finished to device\n");
 	myassert(1 == fwrite(">>>>>>>>", 8, 1, BFL), 0x3f, "Error sending upload-finished to device\n");
-	myassert(fgets(buf, sizeof(buf), BFL), 0x3f, "Error reading response from upload-finished\n");  \
-	myassert(!strcmp(buf, "DONE\n"), 0x3f, "Invalid response from upload-finished: %s%s", ERRRESP(buf));  \
-	
+	myassert(fgets(buf, sizeof(buf), BFL), 0x3f, "Error reading response from upload-finished\n");
+	myassert(!strcmp(buf, "DONE\n"), 0x3f, "Invalid response from upload-finished: %s%s", ERRRESP(buf));
+
 	// ZBX: Finish programming
 	// ZBX: Finish programming
 	printf("Waiting for device... ");
 	printf("Waiting for device... ");
 	myassert(1 == fwrite("ZBX", 3, 1, BFL), 0x40, "Failed to issue ZBX command\n");
 	myassert(1 == fwrite("ZBX", 3, 1, BFL), 0x40, "Failed to issue ZBX command\n");
 	WAITFOROK(0x40, "ZBX");
 	WAITFOROK(0x40, "ZBX");
-	printf("ALL DONE!\n");
+	printf("All done! Try mining to test the flash succeeded.\n");
+
+	return 0;
 }
 }