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