From bd88dfe418b4d3ec06cf283c9af55fef5098e56e Mon Sep 17 00:00:00 2001
From: Pablo Cossutta <pcossutt@itba.edu.ar>
Date: Sat, 27 Apr 2019 19:33:07 -0300
Subject: Add -X option to iceprog

In my setup, in OSX I have problems reading from libftdi but not writing. In case of a failure iceprog exits and leaves the FPGA in an useless state. I think it would be a good option to have the possibility to skip the verification process.
---
 iceprog/iceprog.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'iceprog')

diff --git a/iceprog/iceprog.c b/iceprog/iceprog.c
index f9d1187..bae9e71 100644
--- a/iceprog/iceprog.c
+++ b/iceprog/iceprog.c
@@ -449,6 +449,7 @@ static void help(const char *progname)
 	fprintf(stderr, "\n");
 	fprintf(stderr, "Mode of operation:\n");
 	fprintf(stderr, "  [default]             write file contents to flash, then verify\n");
+	fprintf(stderr, "  -X                    write file contents to flash only\n");	
 	fprintf(stderr, "  -r                    read first 256 kB from flash and write to file\n");
 	fprintf(stderr, "  -R <size in bytes>    read the specified number of bytes from flash\n");
 	fprintf(stderr, "                          (append 'k' to the argument for size in kilobytes,\n");
@@ -517,6 +518,7 @@ int main(int argc, char **argv)
 	bool test_mode = false;
 	bool slow_clock = false;
 	bool disable_protect = false;
+	bool disable_verify = false;
 	const char *filename = NULL;
 	const char *devstr = NULL;
 	int ifnum = 0;
@@ -529,7 +531,7 @@ int main(int argc, char **argv)
 	/* Decode command line parameters */
 	int opt;
 	char *endptr;
-	while ((opt = getopt_long(argc, argv, "d:I:rR:e:o:cbnStvsp", long_options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "d:I:rR:e:o:cbnStvspX", long_options, NULL)) != -1) {
 		switch (opt) {
 		case 'd': /* device string */
 			devstr = optarg;
@@ -616,6 +618,9 @@ int main(int argc, char **argv)
 		case 'p': /* disable flash protect before erase/write */
 			disable_protect = true;
 			break;
+		case 'X': /* disable verification */
+			disable_verify = true;
+			break;
 		case -2:
 			help(argv[0]);
 			return EXIT_SUCCESS;
@@ -921,7 +926,7 @@ int main(int argc, char **argv)
 				flash_read(rw_offset + addr, buffer, 256);
 				fwrite(buffer, read_size - addr > 256 ? 256 : read_size - addr, 1, f);
 			}
-		} else if (!erase_mode) {
+		} else if (!erase_mode && !disable_verify) {
 			fprintf(stderr, "reading..\n");
 			for (int addr = 0; true; addr += 256) {
 				uint8_t buffer_flash[256], buffer_file[256];
-- 
cgit v1.2.3