FreeCalypso > hg > freecalypso-sw
comparison loadtools/ltflash.c @ 60:048329d0888e
fc-loadtool: flash blankchk implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 24 Jun 2013 07:29:53 +0000 |
parents | 1f9302b6f342 |
children | a10491da8c3a |
comparison
equal
deleted
inserted
replaced
59:c3158d30ff0c | 60:048329d0888e |
---|---|
130 } | 130 } |
131 | 131 |
132 flashcmd_blankchk(argc, argv, bank) | 132 flashcmd_blankchk(argc, argv, bank) |
133 char **argv; | 133 char **argv; |
134 { | 134 { |
135 printf("To be implemented\n"); | 135 struct flash_bank_info *bi; |
136 return(1); | 136 u_long offset, len; |
137 char *strtoul_endp; | |
138 char *targv[4], targ_start[10], targ_len[10]; | |
139 | |
140 if (argc != 4) { | |
141 inv: fprintf(stderr, "usage: %s %s hex-start-offset hex-length\n", | |
142 argv[0], argv[1]); | |
143 return(-1); | |
144 } | |
145 offset = strtoul(argv[2], &strtoul_endp, 16); | |
146 if (*strtoul_endp) | |
147 goto inv; | |
148 bi = flash_bank_info + bank; | |
149 if (offset >= bi->total_size) { | |
150 fprintf(stderr, | |
151 "error: specified offset exceeds flash bank size (0x%lx)\n", | |
152 (u_long) bi->total_size); | |
153 return(-1); | |
154 } | |
155 len = strtoul(argv[3], &strtoul_endp, 16); | |
156 if (*strtoul_endp) | |
157 goto inv; | |
158 if (len > bi->total_size - offset) { | |
159 fprintf(stderr, | |
160 "error: specified offset+length exceed flash bank size (0x%lx)\n", | |
161 (u_long) bi->total_size); | |
162 return(-1); | |
163 } | |
164 sprintf(targ_start, "%lx", (u_long) bi->base_addr + offset); | |
165 sprintf(targ_len, "%lx", len); | |
166 targv[0] = "blankchk"; | |
167 targv[1] = targ_start; | |
168 targv[2] = targ_len; | |
169 targv[3] = 0; | |
170 tpinterf_make_cmd(targv); | |
171 if (tpinterf_send_cmd() < 0) | |
172 return(-1); | |
173 return tpinterf_pass_output(10); /* 10 s timeout */ | |
137 } | 174 } |
138 | 175 |
139 flashcmd_dump2file(argc, argv, bank) | 176 flashcmd_dump2file(argc, argv, bank) |
140 char **argv; | 177 char **argv; |
141 { | 178 { |