comparison loadtools/flprogsrec.c @ 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 51bcfb251b23
children 185c9bf208d3
comparison
equal deleted inserted replaced
669:ba9523ca6ed8 670:815c3f8bcff1
184 *totalp = total_len; 184 *totalp = total_len;
185 *tmpfilep = tmpfile; 185 *tmpfilep = tmpfile;
186 return(0); 186 return(0);
187 } 187 }
188 188
189 flashcmd_progsrec_gen(bank, imgfile, is_m0) 189 flashcmd_progsrec_gen(bank, imgfile, is_m0, with_erase)
190 char *imgfile; 190 char *imgfile;
191 { 191 {
192 struct flash_bank_info *bi; 192 struct flash_bank_info *bi;
193 struct discontig_prog regions[MAX_SREC_REGIONS], *regp; 193 struct discontig_prog regions[MAX_SREC_REGIONS], *regp;
194 unsigned nregions, reg; 194 unsigned nregions, reg;
206 bi = flash_bank_info + bank; 206 bi = flash_bank_info + bank;
207 rc = read_srec_img_for_flash(imgfile, is_m0, bi->geom->total_size, 207 rc = read_srec_img_for_flash(imgfile, is_m0, bi->geom->total_size,
208 regions, &nregions, &total_len, &tmpfile); 208 regions, &nregions, &total_len, &tmpfile);
209 if (rc < 0) 209 if (rc < 0)
210 return(rc); 210 return(rc);
211 if (with_erase) {
212 rc = erase_sectors_for_prog(bi, regions, nregions);
213 if (rc < 0) {
214 fclose(tmpfile);
215 return(rc);
216 }
217 }
211 sprintf(shortarg, "%lx", (u_long) bi->base_addr); 218 sprintf(shortarg, "%lx", (u_long) bi->base_addr);
212 targv[0] = bi->ops->loadagent_setbase_cmd; 219 targv[0] = bi->ops->loadagent_setbase_cmd;
213 targv[1] = shortarg; 220 targv[1] = shortarg;
214 targv[2] = 0; 221 targv[2] = 0;
215 printf("Setting flash base address: %s %s\n", targv[0], targv[1]); 222 printf("Setting flash base address: %s %s\n", targv[0], targv[1]);
345 { 352 {
346 if (argc != 3) { 353 if (argc != 3) {
347 fprintf(stderr, "usage: %s %s image.srec\n", argv[0], argv[1]); 354 fprintf(stderr, "usage: %s %s image.srec\n", argv[0], argv[1]);
348 return(-1); 355 return(-1);
349 } 356 }
350 return flashcmd_progsrec_gen(bank, argv[2], 0); 357 return flashcmd_progsrec_gen(bank, argv[2], 0, argv[1][0] == 'e');
351 } 358 }
352 359
353 flashcmd_program_m0(argc, argv, bank) 360 flashcmd_program_m0(argc, argv, bank)
354 char **argv; 361 char **argv;
355 { 362 {
356 if (argc != 3) { 363 if (argc != 3) {
357 fprintf(stderr, "usage: %s %s image.m0\n", argv[0], argv[1]); 364 fprintf(stderr, "usage: %s %s image.m0\n", argv[0], argv[1]);
358 return(-1); 365 return(-1);
359 } 366 }
360 return flashcmd_progsrec_gen(bank, argv[2], 1); 367 return flashcmd_progsrec_gen(bank, argv[2], 1, argv[1][0] == 'e');
361 } 368 }