first attempt at grouping commands into categories based on what I think they do
[proxmark3-svn] / client / flasher.c
0 / 67 (  0%)
CommitLineData
1#include <usb.h>
2#include <stdio.h>
3#include <unistd.h>
4#include <stdlib.h>
5#include <stdint.h>
6#include <stdbool.h>
7#include <strings.h>
8#include <string.h>
9#include <errno.h>
10#include <ctype.h>
11
12#include "prox.h"
13#include "proxmark3.h"
14#include "flash.h"
15
16unsigned int current_command = CMD_UNKNOWN;
17
18extern struct partition partitions[];
19
20static void usage(char **argv)
21{
22 int i;
23 fprintf(stderr, "Usage: %s areas image [image [image]]\n", argv[0]);
24 fprintf(stderr, " areas is a comma-separated list of areas to flash, with no spaces\n");
25 fprintf(stderr, " Known areas are:");
26
27 for(i=0; partitions[i].name != NULL; i++) {
28 fprintf(stderr, " %s", partitions[i].name);
29 }
30
31 fprintf(stderr, "\n");
32 fprintf(stderr, " image is the path to the corresponding image\n\n");
33 fprintf(stderr, "Example: %s os,fpga path/to/osimage.elf path/to/fpgaimage.elf\n", argv[0]);
34}
35
36int main(int argc, char **argv) {
37 if(argc < 2) {
38 usage(argv);
39 exit(-1);
40 }
41
42 /* Count area arguments */
43 int areas = 0, offset=-1, length=0;
44 while(find_next_area(argv[1], &offset, &length)) areas++;
45
46 if(areas != argc - 2) {
47 usage(argv);
48 exit(-1);
49 }
50
51 usb_init();
52
53 fprintf(stderr,"Waiting for Proxmark to appear on USB... ");
54 while(!(devh=OpenProxmark(0))) { sleep(1); }
55 fprintf(stderr,"Found.\n");
56
57 do_flash(argv);
58
59 UsbCommand c = {CMD_HARDWARE_RESET};
60 SendCommand(&c);
61
62 CloseProxmark();
63
64 fprintf(stderr,"Have a nice day!\n");
65
66 return 0;
67}
Impressum, Datenschutz