comparison loadtools/flprogbin.c @ 673:f67e5ad30324

fc-loadtool: flash e-program-bin implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 08 Mar 2020 04:16:31 +0000
parents 57cb825b505a
children 185c9bf208d3
comparison
equal deleted inserted replaced
672:57cb825b505a 673:f67e5ad30324
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
11 #include <time.h> 11 #include <time.h>
12 #include <unistd.h> 12 #include <unistd.h>
13 #include "flash.h" 13 #include "flash.h"
14 #include "discontig.h"
14 15
15 extern int target_fd; 16 extern int target_fd;
16 17
17 extern struct flash_bank_info flash_bank_info[2]; 18 extern struct flash_bank_info flash_bank_info[2];
18 extern uint32_t crc32_table[]; 19 extern uint32_t crc32_table[];
21 len_given) 22 len_given)
22 u_long flashoff, fileoff, len; 23 u_long flashoff, fileoff, len;
23 char *imgfile; 24 char *imgfile;
24 { 25 {
25 struct flash_bank_info *bi; 26 struct flash_bank_info *bi;
27 struct discontig_prog erase_region;
26 u_long origlen, bytesdone; 28 u_long origlen, bytesdone;
27 u_long crc_base_addr, crc_from_target; 29 u_long crc_base_addr, crc_from_target;
28 uint32_t crcaccum; 30 uint32_t crcaccum;
29 FILE *binf; 31 FILE *binf;
30 struct stat filestat; 32 struct stat filestat;
90 fclose(binf); 92 fclose(binf);
91 return(-1); 93 return(-1);
92 } 94 }
93 95
94 /* finally done with the arg parsing etc, can get to work now */ 96 /* finally done with the arg parsing etc, can get to work now */
97 if (with_erase) {
98 erase_region.start = flashoff;
99 erase_region.end = flashoff + len;
100 i = erase_sectors_for_prog(bi, &erase_region, 1);
101 if (i < 0) {
102 fclose(binf);
103 return(i);
104 }
105 }
95 crc_base_addr = bi->base_addr + flashoff; 106 crc_base_addr = bi->base_addr + flashoff;
96 sprintf(shortarg, "%lx", (u_long) bi->base_addr); 107 sprintf(shortarg, "%lx", (u_long) bi->base_addr);
97 targv[0] = bi->ops->loadagent_setbase_cmd; 108 targv[0] = bi->ops->loadagent_setbase_cmd;
98 targv[1] = shortarg; 109 targv[1] = shortarg;
99 targv[2] = 0; 110 targv[2] = 0;