-static void usage(char **argv)
-{
- int i;
- fprintf(stderr, "Usage: %s areas image [image [image]]\n", argv[0]);
- fprintf(stderr, " areas is a comma-separated list of areas to flash, with no spaces\n");
- fprintf(stderr, " Known areas are:");
- for(i=0; i<(sizeof(partitions)/sizeof(partitions[0])); i++) {
- fprintf(stderr, " %s", partitions[i].name);
- }
- fprintf(stderr, "\n");
- fprintf(stderr, " image is the path to the corresponding image\n\n");
- fprintf(stderr, "Example: %s os,fpga path/to/osimage.s19 path/to/fpgaimage.s19\n", argv[0]);
-}
-
-/* On first call, have *offset = -1, *length = 0; */
-static int find_next_area(const char *str, int *offset, int *length)
-{
- if(*str == '\0') return 0;
- if((*offset >= 0) && str[*offset + *length] == '\0') return 0;
- *offset += 1 + *length;
-
- char *next_comma = strchr(str + *offset, ',');
- if(next_comma == NULL) {
- *length = strlen(str) - *offset;
- } else {
- *length = next_comma-(str+*offset);
- }
- return 1;
-}
-
-int main(int argc, char **argv) {
- if(argc < 2) {
- usage(argv);
- exit(-1);
- }
-
- /* Count area arguments */
- int areas = 0, offset=-1, length=0;
- while(find_next_area(argv[1], &offset, &length)) areas++;
-
- if(areas != argc - 2) {
- usage(argv);
- exit(-1);
- }
-
- usb_init();