diff loadtools/flprogsrec.c @ 400:f027c6fbe37e

fc-loadtool flash: first round of refactoring for CFI
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 15 Jun 2014 20:05:54 +0000
parents cd12d1049f91
children a212b4968b29
line wrap: on
line diff
--- a/loadtools/flprogsrec.c	Sun Jun 15 00:47:06 2014 +0000
+++ b/loadtools/flprogsrec.c	Sun Jun 15 20:05:54 2014 +0000
@@ -22,6 +22,14 @@
 	int resp;
 	unsigned long rec_count;
 
+	if (flash_get_cfi(bank) < 0)
+		return(-1);
+	bi = flash_bank_info + bank;
+	if (bi->cfi->cmdset_style != 2) {
+		fprintf(stderr,
+"error: this command is currently only implemented for AMD-style flash\n");
+		return(-1);
+	}
 	srr.filename = imgfile;
 	resp = open_srec_file(&srr);
 	if (resp < 0)
@@ -31,7 +39,6 @@
 		fclose(srr.openfile);
 		return(resp);
 	}
-	bi = flash_bank_info + bank;
 	sprintf(shortarg, "%lx", (u_long) bi->base_addr);
 	targv[0] = "AMFB";
 	targv[1] = shortarg;
@@ -91,8 +98,8 @@
 			fclose(srr.openfile);
 			return(-1);
 		}
-		srr.addr &= bi->total_size - 1;
-		if (srr.addr + srr.datalen > bi->total_size) {
+		srr.addr &= bi->cfi->total_size - 1;
+		if (srr.addr + srr.datalen > bi->cfi->total_size) {
 			fprintf(stderr,
 			"%s line %d: goes past the end of the flash bank\n",
 				srr.filename, srr.lineno);