changeset 617:97fe41e9242a

fc-loadtool: added operation time reporting to flash program-m0
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 25 Feb 2020 07:01:28 +0000
parents 4be92bcd1535
children 6824c4d55848
files loadtools/flprogsrec.c
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/flprogsrec.c	Tue Feb 25 02:43:05 2020 +0000
+++ b/loadtools/flprogsrec.c	Tue Feb 25 07:01:28 2020 +0000
@@ -7,6 +7,7 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <time.h>
 #include "flash.h"
 #include "srecreader.h"
 
@@ -20,6 +21,8 @@
 	char *targv[4], shortarg[10], longarg[513];
 	int resp;
 	unsigned long rec_count;
+	time_t start_time, finish_time;
+	unsigned duration, mm, ss;
 
 	if (flash_detect(bank, 0) < 0)
 		return(-1);
@@ -64,9 +67,10 @@
 	"Warning: S0 record found in line %d of %s (expected in line 1 only)\n",
 				srr.lineno, srr.filename);
 			continue;
-		} else if (srr.record_type == '7')
+		} else if (srr.record_type == '7') {
+			time(&finish_time);
 			break;
-		else if (srr.record_type != '3') {
+		} else if (srr.record_type != '3') {
 			fprintf(stderr,
 		"Warning: unsupported S%c record type in line %d of %s\n",
 				srr.record_type, srr.lineno, srr.filename);
@@ -99,8 +103,10 @@
 			fclose(srr.openfile);
 			return(-1);
 		}
-		if (!rec_count)
+		if (!rec_count) {
 		    printf("Programming flash, each \'.\' is 100 S-records\n");
+			time(&start_time);
+		}
 		sprintf(shortarg, "%lx", (u_long) srr.addr);
 		build_flashw_hex_string(srr.record + 5, longarg,
 					srr.datalen >> 1, is_m0);
@@ -128,7 +134,10 @@
 			srr.filename, srr.lineno);
 		return(-1);
 	}
-	printf("\nProgramming complete\n");
+	duration = finish_time - start_time;
+	mm = duration / 60;
+	ss = duration - mm * 60;
+	printf("\nOperation completed in %um%us\n", mm, ss);
 	return(0);
 }