changeset 673:f67e5ad30324

fc-loadtool: flash e-program-bin implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 08 Mar 2020 04:16:31 +0000
parents 57cb825b505a
children 135de08c5d74
files loadtools/flmain.c loadtools/flprogbin.c
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/flmain.c	Sun Mar 08 04:09:08 2020 +0000
+++ b/loadtools/flmain.c	Sun Mar 08 04:16:31 2020 +0000
@@ -113,6 +113,7 @@
 	{"dump2srec", flashcmd_dump2file},
 	{"erase", flashcmd_erase},
 	{"erase-program-boot", flashcmd_erase_program_boot},
+	{"e-program-bin", flashcmd_progbin_wrap},
 	{"e-program-m0", flashcmd_program_m0},
 	{"e-program-srec", flashcmd_program_srec},
 	{"geom", flashcmd_geom},
--- a/loadtools/flprogbin.c	Sun Mar 08 04:09:08 2020 +0000
+++ b/loadtools/flprogbin.c	Sun Mar 08 04:16:31 2020 +0000
@@ -11,6 +11,7 @@
 #include <time.h>
 #include <unistd.h>
 #include "flash.h"
+#include "discontig.h"
 
 extern int target_fd;
 
@@ -23,6 +24,7 @@
 	char *imgfile;
 {
 	struct flash_bank_info *bi;
+	struct discontig_prog erase_region;
 	u_long origlen, bytesdone;
 	u_long crc_base_addr, crc_from_target;
 	uint32_t crcaccum;
@@ -92,6 +94,15 @@
 	}
 
 	/* finally done with the arg parsing etc, can get to work now */
+	if (with_erase) {
+		erase_region.start = flashoff;
+		erase_region.end = flashoff + len;
+		i = erase_sectors_for_prog(bi, &erase_region, 1);
+		if (i < 0) {
+			fclose(binf);
+			return(i);
+		}
+	}
 	crc_base_addr = bi->base_addr + flashoff;
 	sprintf(shortarg, "%lx", (u_long) bi->base_addr);
 	targv[0] = bi->ops->loadagent_setbase_cmd;