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