FreeCalypso > hg > freecalypso-sw
comparison loadtools/flprogsrec.c @ 400:f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 15 Jun 2014 20:05:54 +0000 |
parents | cd12d1049f91 |
children | a212b4968b29 |
comparison
equal
deleted
inserted
replaced
399:d26a9e3de626 | 400:f027c6fbe37e |
---|---|
20 struct srecreader srr; | 20 struct srecreader srr; |
21 char *targv[4], shortarg[10], longarg[513]; | 21 char *targv[4], shortarg[10], longarg[513]; |
22 int resp; | 22 int resp; |
23 unsigned long rec_count; | 23 unsigned long rec_count; |
24 | 24 |
25 if (flash_get_cfi(bank) < 0) | |
26 return(-1); | |
27 bi = flash_bank_info + bank; | |
28 if (bi->cfi->cmdset_style != 2) { | |
29 fprintf(stderr, | |
30 "error: this command is currently only implemented for AMD-style flash\n"); | |
31 return(-1); | |
32 } | |
25 srr.filename = imgfile; | 33 srr.filename = imgfile; |
26 resp = open_srec_file(&srr); | 34 resp = open_srec_file(&srr); |
27 if (resp < 0) | 35 if (resp < 0) |
28 return(resp); | 36 return(resp); |
29 resp = flash_id_check(bank, 0); | 37 resp = flash_id_check(bank, 0); |
30 if (resp) { | 38 if (resp) { |
31 fclose(srr.openfile); | 39 fclose(srr.openfile); |
32 return(resp); | 40 return(resp); |
33 } | 41 } |
34 bi = flash_bank_info + bank; | |
35 sprintf(shortarg, "%lx", (u_long) bi->base_addr); | 42 sprintf(shortarg, "%lx", (u_long) bi->base_addr); |
36 targv[0] = "AMFB"; | 43 targv[0] = "AMFB"; |
37 targv[1] = shortarg; | 44 targv[1] = shortarg; |
38 targv[2] = 0; | 45 targv[2] = 0; |
39 printf("Setting flash base address: %s %s\n", targv[0], targv[1]); | 46 printf("Setting flash base address: %s %s\n", targv[0], targv[1]); |
89 "%s line %d: violates word alignment requirement\n", | 96 "%s line %d: violates word alignment requirement\n", |
90 srr.filename, srr.lineno); | 97 srr.filename, srr.lineno); |
91 fclose(srr.openfile); | 98 fclose(srr.openfile); |
92 return(-1); | 99 return(-1); |
93 } | 100 } |
94 srr.addr &= bi->total_size - 1; | 101 srr.addr &= bi->cfi->total_size - 1; |
95 if (srr.addr + srr.datalen > bi->total_size) { | 102 if (srr.addr + srr.datalen > bi->cfi->total_size) { |
96 fprintf(stderr, | 103 fprintf(stderr, |
97 "%s line %d: goes past the end of the flash bank\n", | 104 "%s line %d: goes past the end of the flash bank\n", |
98 srr.filename, srr.lineno); | 105 srr.filename, srr.lineno); |
99 fclose(srr.openfile); | 106 fclose(srr.openfile); |
100 return(-1); | 107 return(-1); |