]>
Commit | Line | Data |
---|---|---|
1 | #include <stdio.h> | |
2 | #include <stdlib.h> | |
3 | #include "sleep.h" | |
4 | #include "proxusb.h" | |
5 | #include "flash.h" | |
6 | ||
7 | unsigned int current_command = CMD_UNKNOWN; | |
8 | ||
9 | extern struct partition partitions[]; | |
10 | ||
11 | static void usage(char **argv) | |
12 | { | |
13 | fprintf(stderr, "Usage: %s areas image [image [image]]\n", argv[0]); | |
14 | fprintf(stderr, " areas is a comma-separated list of areas to flash, with no spaces\n"); | |
15 | fprintf(stderr, " Known areas are:"); | |
16 | ||
17 | for (int i = 0; partitions[i].name != NULL; ++i) { | |
18 | fprintf(stderr, " %s", partitions[i].name); | |
19 | } | |
20 | ||
21 | fprintf(stderr, "\n"); | |
22 | fprintf(stderr, " image is the path to the corresponding image\n\n"); | |
23 | fprintf(stderr, "Example: %s os,fpga path/to/osimage.elf path/to/fpgaimage.elf\n", argv[0]); | |
24 | } | |
25 | ||
26 | int main(int argc, char **argv) | |
27 | { | |
28 | if (argc < 2) { | |
29 | usage(argv); | |
30 | exit(-1); | |
31 | } | |
32 | ||
33 | /* Count area arguments */ | |
34 | int areas = 0, offset=-1, length=0; | |
35 | while (find_next_area(argv[1], &offset, &length)) areas++; | |
36 | ||
37 | if (areas != argc - 2) { | |
38 | usage(argv); | |
39 | exit(-1); | |
40 | } | |
41 | ||
42 | usb_init(); | |
43 | ||
44 | fprintf(stderr,"Waiting for Proxmark to appear on USB... "); | |
45 | while (!OpenProxmark(0)) { sleep(1); } | |
46 | fprintf(stderr,"Found.\n"); | |
47 | ||
48 | do_flash(argv); | |
49 | ||
50 | UsbCommand c = {CMD_HARDWARE_RESET}; | |
51 | SendCommand(&c); | |
52 | ||
53 | CloseProxmark(); | |
54 | ||
55 | fprintf(stderr,"Have a nice day!\n"); | |
56 | ||
57 | return 0; | |
58 | } |