changeset 60:048329d0888e

fc-loadtool: flash blankchk implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 24 Jun 2013 07:29:53 +0000
parents c3158d30ff0c
children a10491da8c3a
files loadtools/ltflash.c
diffstat 1 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/loadtools/ltflash.c	Mon Jun 24 06:40:55 2013 +0000
+++ b/loadtools/ltflash.c	Mon Jun 24 07:29:53 2013 +0000
@@ -132,8 +132,45 @@
 flashcmd_blankchk(argc, argv, bank)
 	char **argv;
 {
-	printf("To be implemented\n");
-	return(1);
+	struct flash_bank_info *bi;
+	u_long offset, len;
+	char *strtoul_endp;
+	char *targv[4], targ_start[10], targ_len[10];
+
+	if (argc != 4) {
+inv:		fprintf(stderr, "usage: %s %s hex-start-offset hex-length\n",
+			argv[0], argv[1]);
+		return(-1);
+	}
+	offset = strtoul(argv[2], &strtoul_endp, 16);
+	if (*strtoul_endp)
+		goto inv;
+	bi = flash_bank_info + bank;
+	if (offset >= bi->total_size) {
+		fprintf(stderr,
+		"error: specified offset exceeds flash bank size (0x%lx)\n",
+			(u_long) bi->total_size);
+		return(-1);
+	}
+	len = strtoul(argv[3], &strtoul_endp, 16);
+	if (*strtoul_endp)
+		goto inv;
+	if (len > bi->total_size - offset) {
+		fprintf(stderr,
+	"error: specified offset+length exceed flash bank size (0x%lx)\n",
+			(u_long) bi->total_size);
+		return(-1);
+	}
+	sprintf(targ_start, "%lx", (u_long) bi->base_addr + offset);
+	sprintf(targ_len, "%lx", len);
+	targv[0] = "blankchk";
+	targv[1] = targ_start;
+	targv[2] = targ_len;
+	targv[3] = 0;
+	tpinterf_make_cmd(targv);
+	if (tpinterf_send_cmd() < 0)
+		return(-1);
+	return tpinterf_pass_output(10);	/* 10 s timeout */
 }
 
 flashcmd_dump2file(argc, argv, bank)