changeset 205:cd12d1049f91

fc-loadtool: flash ID check moved into flash info, added to erase and program
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 23 Dec 2013 18:40:04 +0000
parents 61c7480b3c50
children 9539929b3414
files loadtools/flerase.c loadtools/flprogbin.c loadtools/flprogsrec.c loadtools/flutil.c loadtools/ltflash.c
diffstat 5 files changed, 13 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/flerase.c	Mon Dec 23 08:49:38 2013 +0000
+++ b/loadtools/flerase.c	Mon Dec 23 18:40:04 2013 +0000
@@ -97,6 +97,9 @@
 		return(-1);
 	if (get_flash_sector_range(bi, offset, len, &startsec, &endsec) < 0)
 		return(-1);
+	stat = flash_id_check(bank, 0);
+	if (stat)
+		return(stat);
 	printf("Erasing %d sector(s)\n", endsec - startsec);
 	for (sp = startsec; sp < endsec; sp++) {
 		stat = do_sector_erase(bi, sp);
--- a/loadtools/flprogbin.c	Mon Dec 23 08:49:38 2013 +0000
+++ b/loadtools/flprogbin.c	Mon Dec 23 18:40:04 2013 +0000
@@ -104,6 +104,10 @@
 	}
 
 	/* finally done with the arg parsing etc, can get to work now */
+	if (flash_id_check(bank, 0) < 0) {
+		fclose(binf);
+		return(-1);
+	}
 	sprintf(shortarg, "%lx", (u_long) bi->base_addr);
 	targv[0] = "AMFB";
 	targv[1] = shortarg;
--- a/loadtools/flprogsrec.c	Mon Dec 23 08:49:38 2013 +0000
+++ b/loadtools/flprogsrec.c	Mon Dec 23 18:40:04 2013 +0000
@@ -26,6 +26,11 @@
 	resp = open_srec_file(&srr);
 	if (resp < 0)
 		return(resp);
+	resp = flash_id_check(bank, 0);
+	if (resp) {
+		fclose(srr.openfile);
+		return(resp);
+	}
 	bi = flash_bank_info + bank;
 	sprintf(shortarg, "%lx", (u_long) bi->base_addr);
 	targv[0] = "AMFB";
--- a/loadtools/flutil.c	Mon Dec 23 08:49:38 2013 +0000
+++ b/loadtools/flutil.c	Mon Dec 23 18:40:04 2013 +0000
@@ -202,15 +202,3 @@
 	bi->idcheck_done = 1;
 	return(0);
 }
-
-flashcmd_idcheck(argc, argv, bank)
-	char **argv;
-{
-	struct flash_bank_info *bi;
-
-	if (argc > 2) {
-		fprintf(stderr, "error: too many arguments\n");
-		return(-1);
-	}
-	return flash_id_check(bank, 1);
-}
--- a/loadtools/ltflash.c	Mon Dec 23 08:49:38 2013 +0000
+++ b/loadtools/ltflash.c	Mon Dec 23 18:40:04 2013 +0000
@@ -273,6 +273,7 @@
 	printf("Bank %d base address: %08lX\n", bank, (u_long) bi->base_addr);
 	printf("Bank %d total size: %lx\n", bank, (u_long) bi->total_size);
 	printf("Sectors in bank %d: %u\n", bank, bi->nsectors);
+	flash_id_check(bank, 1);
 	if (selected_flash_device->nbanks == 2 && !bank)
 	    printf("\nFlash device has 2 banks; flash2 command available\n");
 	return(0);
@@ -313,7 +314,6 @@
 }
 
 extern int flashcmd_erase();
-extern int flashcmd_idcheck();
 extern int flashcmd_progbin();
 extern int flashcmd_program_m0();
 extern int flashcmd_program_srec();
@@ -328,7 +328,6 @@
 	{"dump2srec", flashcmd_dump2file},
 	{"erase", flashcmd_erase},
 	{"help", flashcmd_help},
-	{"idcheck", flashcmd_idcheck},
 	{"info", flashcmd_info},
 	{"program-bin", flashcmd_progbin},
 	{"program-m0", flashcmd_program_m0},