]> cvs.zerfleddert.de Git - proxmark3-svn/blame - client/flasher.c
Some random cleanup
[proxmark3-svn] / client / flasher.c
CommitLineData
6658905f 1#include <stdio.h>
83a9b236 2#include <stdlib.h>
4cd41f34 3#include "sleep.h"
7fe9b0b7 4#include "proxusb.h"
6e4d4ee6 5#include "flash.h"
6658905f 6
9b255608 7unsigned int current_command = CMD_UNKNOWN;
8
6e4d4ee6 9extern struct partition partitions[];
a5b1ba20 10
11static void usage(char **argv)
12{
7fe9b0b7 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:");
6e4d4ee6 16
7fe9b0b7 17 for (int i = 0; partitions[i].name != NULL; ++i) {
18 fprintf(stderr, " %s", partitions[i].name);
19 }
6e4d4ee6 20
7fe9b0b7 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]);
a5b1ba20 24}
6658905f 25
7fe9b0b7 26int 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);
a5b1ba20 49
7fe9b0b7 50 UsbCommand c = {CMD_HARDWARE_RESET};
51 SendCommand(&c);
6658905f 52
7fe9b0b7 53 CloseProxmark();
6658905f 54
7fe9b0b7 55 fprintf(stderr,"Have a nice day!\n");
6658905f 56
7fe9b0b7 57 return 0;
6658905f 58}
Impressum, Datenschutz