changeset 670:815c3f8bcff1

fc-loadtool: flash e-program-m0 and e-program-srec implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 08 Mar 2020 01:47:57 +0000
parents ba9523ca6ed8
children e66fafeeb377
files loadtools/flmain.c loadtools/flprogsrec.c
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/flmain.c	Sun Mar 08 01:32:08 2020 +0000
+++ b/loadtools/flmain.c	Sun Mar 08 01:47:57 2020 +0000
@@ -113,6 +113,8 @@
 	{"dump2srec", flashcmd_dump2file},
 	{"erase", flashcmd_erase},
 	{"erase-program-boot", flashcmd_erase_program_boot},
+	{"e-program-m0", flashcmd_program_m0},
+	{"e-program-srec", flashcmd_program_srec},
 	{"geom", flashcmd_geom},
 	{"help", flashcmd_help},
 	{"id", flashcmd_id},
--- a/loadtools/flprogsrec.c	Sun Mar 08 01:32:08 2020 +0000
+++ b/loadtools/flprogsrec.c	Sun Mar 08 01:47:57 2020 +0000
@@ -186,7 +186,7 @@
 	return(0);
 }
 
-flashcmd_progsrec_gen(bank, imgfile, is_m0)
+flashcmd_progsrec_gen(bank, imgfile, is_m0, with_erase)
 	char *imgfile;
 {
 	struct flash_bank_info *bi;
@@ -208,6 +208,13 @@
 				     regions, &nregions, &total_len, &tmpfile);
 	if (rc < 0)
 		return(rc);
+	if (with_erase) {
+		rc = erase_sectors_for_prog(bi, regions, nregions);
+		if (rc < 0) {
+			fclose(tmpfile);
+			return(rc);
+		}
+	}
 	sprintf(shortarg, "%lx", (u_long) bi->base_addr);
 	targv[0] = bi->ops->loadagent_setbase_cmd;
 	targv[1] = shortarg;
@@ -347,7 +354,7 @@
 		fprintf(stderr, "usage: %s %s image.srec\n", argv[0], argv[1]);
 		return(-1);
 	}
-	return flashcmd_progsrec_gen(bank, argv[2], 0);
+	return flashcmd_progsrec_gen(bank, argv[2], 0, argv[1][0] == 'e');
 }
 
 flashcmd_program_m0(argc, argv, bank)
@@ -357,5 +364,5 @@
 		fprintf(stderr, "usage: %s %s image.m0\n", argv[0], argv[1]);
 		return(-1);
 	}
-	return flashcmd_progsrec_gen(bank, argv[2], 1);
+	return flashcmd_progsrec_gen(bank, argv[2], 1, argv[1][0] == 'e');
 }