]> git.zerfleddert.de Git - proxmark3-svn/blame - client/flasher.c
fix broken formatting in command table
[proxmark3-svn] / client / flasher.c
CommitLineData
6658905f 1#include <usb.h>
2#include <stdio.h>
3#include <unistd.h>
4#include <stdlib.h>
a146075d 5#include <stdint.h>
6#include <stdbool.h>
6658905f 7#include <strings.h>
8#include <string.h>
9#include <errno.h>
10#include <ctype.h>
11
cd00aa30 12#include "prox.h"
6658905f 13#include "proxmark3.h"
6e4d4ee6 14#include "flash.h"
6658905f 15
9b255608 16unsigned int current_command = CMD_UNKNOWN;
17
6e4d4ee6 18extern struct partition partitions[];
a5b1ba20 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:");
6e4d4ee6 26
27 for(i=0; partitions[i].name != NULL; i++) {
a5b1ba20 28 fprintf(stderr, " %s", partitions[i].name);
431ae7e0 29 }
6e4d4ee6 30
a5b1ba20 31 fprintf(stderr, "\n");
32 fprintf(stderr, " image is the path to the corresponding image\n\n");
2cab856f 33 fprintf(stderr, "Example: %s os,fpga path/to/osimage.elf path/to/fpgaimage.elf\n", argv[0]);
a5b1ba20 34}
6658905f 35
a5b1ba20 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
6e4d4ee6 57 do_flash(argv);
a5b1ba20 58
6e4d4ee6 59 UsbCommand c = {CMD_HARDWARE_RESET};
9b255608 60 SendCommand(&c);
6658905f 61
62 CloseProxmark();
63
64 fprintf(stderr,"Have a nice day!\n");
65
66 return 0;
67}
Impressum, Datenschutz