FreeCalypso > hg > freecalypso-sw
comparison loadtools/flprogbin.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 |
|---|---|
| 33 return(-1); | 33 return(-1); |
| 34 } | 34 } |
| 35 flashoff = strtoul(argv[2], &strtoul_endp, 16); | 35 flashoff = strtoul(argv[2], &strtoul_endp, 16); |
| 36 if (*strtoul_endp) | 36 if (*strtoul_endp) |
| 37 goto inv; | 37 goto inv; |
| 38 if (flash_get_cfi(bank) < 0) | |
| 39 return(-1); | |
| 38 bi = flash_bank_info + bank; | 40 bi = flash_bank_info + bank; |
| 39 if (flashoff >= bi->total_size) { | 41 if (bi->cfi->cmdset_style != 2) { |
| 42 fprintf(stderr, | |
| 43 "error: this command is currently only implemented for AMD-style flash\n"); | |
| 44 return(-1); | |
| 45 } | |
| 46 if (flashoff >= bi->cfi->total_size) { | |
| 40 fprintf(stderr, | 47 fprintf(stderr, |
| 41 "error: specified flash offset exceeds bank size (0x%lx)\n", | 48 "error: specified flash offset exceeds bank size (0x%lx)\n", |
| 42 (u_long) bi->total_size); | 49 (u_long) bi->cfi->total_size); |
| 43 return(-1); | 50 return(-1); |
| 44 } | 51 } |
| 45 if (flashoff & 1) { | 52 if (flashoff & 1) { |
| 46 fprintf(stderr, "error: flash offset must be even\n"); | 53 fprintf(stderr, "error: flash offset must be even\n"); |
| 47 return(-1); | 54 return(-1); |
| 88 if (!len) { | 95 if (!len) { |
| 89 printf("Length is zero - nothing to do!\n"); | 96 printf("Length is zero - nothing to do!\n"); |
| 90 fclose(binf); | 97 fclose(binf); |
| 91 return(0); | 98 return(0); |
| 92 } | 99 } |
| 93 if (len > bi->total_size - flashoff) { | 100 if (len > bi->cfi->total_size - flashoff) { |
| 94 fprintf(stderr, | 101 fprintf(stderr, |
| 95 "error: specified flash offset+length exceed bank size (0x%lx)\n", | 102 "error: specified flash offset+length exceed bank size (0x%lx)\n", |
| 96 (u_long) bi->total_size); | 103 (u_long) bi->cfi->total_size); |
| 97 fclose(binf); | 104 fclose(binf); |
| 98 return(-1); | 105 return(-1); |
| 99 } | 106 } |
| 100 if (len & 1) { | 107 if (len & 1) { |
| 101 fprintf(stderr, "error: program length must be even\n"); | 108 fprintf(stderr, "error: program length must be even\n"); |
