changeset 98:b3ed63722eb5

fc-loadtool dump2srec: decorate the SREC output file with S0 and S7 records
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 01 Sep 2013 17:20:58 +0000
parents a2e793f6b8c4
children b78db17bfc85
files loadtools/ltdump.c
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/ltdump.c	Sun Sep 01 12:54:42 2013 +0000
+++ b/loadtools/ltdump.c	Sun Sep 01 17:20:58 2013 +0000
@@ -74,6 +74,9 @@
 static u_char dump_binrec[0x86];
 static time_t dump_last_time;
 
+static char dumpsrec_s0_line[] = "S007000044554D50C2\n";
+static char dumpsrec_s7_line[] = "S70500000000FA\n";
+
 static
 dump_receiver(line)
 	char *line;
@@ -115,9 +118,11 @@
 		return(-1);
 	}
 	/* all checks passed - save it */
-	if (dump_save_srec)
+	if (dump_save_srec) {
+		if (!dump_progress_len)
+			fputs(dumpsrec_s0_line, dump_outfile);
 		fprintf(dump_outfile, "%s\n", line);
-	else
+	} else
 		fwrite(dump_binrec + 5, 1, 0x80, dump_outfile);
 	/* update running CRC */
 	for (i = 0; i < 0x80; i++)
@@ -181,22 +186,28 @@
 		return(stat);
 	}
 	stat = tpinterf_capture_output(2, dump_receiver);
-	fclose(dump_outfile);
-	if (stat < 0)
+	if (stat < 0) {
+		fclose(dump_outfile);
 		return(stat);
-	putchar('\n');	/* after lots of dots */
+	}
+	putchar('\n');	/* after last progress line */
 
 	/* sanity checks */
 	if (dump_nextaddr != start_addr + area_len) {
+		fclose(dump_outfile);
 		fprintf(stderr,
 		"error: received dump length does not match expected\n");
 		return(-1);
 	}
 	if (dump_crcaccum != (uint32_t) target_crc_init) {
+		fclose(dump_outfile);
 		fprintf(stderr, "error: CRC mismatch (computed %lX)\n",
 			(u_long) dump_crcaccum);
 		return(-1);
 	}
+	if (fmt_srec)
+		fputs(dumpsrec_s7_line, dump_outfile);
+	fclose(dump_outfile);
 	printf("Requesting another CRC-32 of the area from target...\n");
 	stat = crc32_on_target(start_addr, area_len, &target_crc_fin);
 	if (stat)