# HG changeset patch # User Michael Spacefalcon # Date 1378056058 0 # Node ID b3ed63722eb507df82d097c1951f20dcdf7b6b09 # Parent a2e793f6b8c4c57f2ee0bf884c8675b415e458e8 fc-loadtool dump2srec: decorate the SREC output file with S0 and S7 records diff -r a2e793f6b8c4 -r b3ed63722eb5 loadtools/ltdump.c --- 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)