]> git.zerfleddert.de Git - proxmark3-svn/blame - client/flasher.c
Client cleanup and restructuring. Stage 1...
[proxmark3-svn] / client / flasher.c
CommitLineData
6658905f 1#include <stdio.h>
7fe9b0b7 2#include "proxusb.h"
6e4d4ee6 3#include "flash.h"
6658905f 4
9b255608 5unsigned int current_command = CMD_UNKNOWN;
6
6e4d4ee6 7extern struct partition partitions[];
a5b1ba20 8
9static void usage(char **argv)
10{
7fe9b0b7 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:");
6e4d4ee6 14
7fe9b0b7 15 for (int i = 0; partitions[i].name != NULL; ++i) {
16 fprintf(stderr, " %s", partitions[i].name);
17 }
6e4d4ee6 18
7fe9b0b7 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]);
a5b1ba20 22}
6658905f 23
7fe9b0b7 24int 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);
a5b1ba20 47
7fe9b0b7 48 UsbCommand c = {CMD_HARDWARE_RESET};
49 SendCommand(&c);
6658905f 50
7fe9b0b7 51 CloseProxmark();
6658905f 52
7fe9b0b7 53 fprintf(stderr,"Have a nice day!\n");
6658905f 54
7fe9b0b7 55 return 0;
6658905f 56}
Impressum, Datenschutz