]>
git.zerfleddert.de Git - proxmark3-svn/blob - client/flasher.c
1 //-----------------------------------------------------------------------------
2 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
3 // at your option, any later version. See the LICENSE.txt file for the text of
5 //-----------------------------------------------------------------------------
6 // Flasher frontend tool
7 //-----------------------------------------------------------------------------
14 #include "proxmark3.h"
16 #include "util_posix.h"
22 void cmd_debug(UsbCommand
* UC
) {
24 printf("UsbCommand length[len=%zd]\n",sizeof(UsbCommand
));
25 printf(" cmd[len=%zd]: %016" PRIx64
"\n",sizeof(UC
->cmd
),UC
->cmd
);
26 printf(" arg0[len=%zd]: %016" PRIx64
"\n",sizeof(UC
->arg
[0]),UC
->arg
[0]);
27 printf(" arg1[len=%zd]: %016" PRIx64
"\n",sizeof(UC
->arg
[1]),UC
->arg
[1]);
28 printf(" arg2[len=%zd]: %016" PRIx64
"\n",sizeof(UC
->arg
[2]),UC
->arg
[2]);
29 printf(" data[len=%zd]: ",sizeof(UC
->d
.asBytes
));
30 for (size_t i
=0; i
<16; i
++) {
31 printf("%02x",UC
->d
.asBytes
[i
]);
36 static void usage(char *argv0
)
38 fprintf(stderr
, "Usage: %s <port> [-b] image.elf [image.elf...]\n\n", argv0
);
39 fprintf(stderr
, "\t-b\tEnable flashing of bootloader area (DANGEROUS)\n\n");
40 fprintf(stderr
, "\nExample:\n\n\t %s "SERIAL_PORT_H
" armsrc/obj/fullimage.elf\n", argv0
);
42 fprintf(stderr
, "\nNote (Linux): if the flasher gets stuck at 'Waiting for Proxmark to reappear',\n");
43 fprintf(stderr
, " you may need to blacklist proxmark for modem-manager. v1.4.14 and later\n");
44 fprintf(stderr
, " include this configuration patch already. The change can be found at:\n");
45 fprintf(stderr
, " https://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=6e7ff47\n\n");
51 int main(int argc
, char **argv
)
53 int can_write_bl
= false;
56 flash_file_t files
[MAX_FILES
];
58 memset(files
, 0, sizeof(files
));
65 for (int i
= 2; i
< argc
; i
++) {
66 if (argv
[i
][0] == '-') {
67 if (!strcmp(argv
[i
], "-b")) {
74 res
= flash_load(&files
[num_files
], argv
[i
], can_write_bl
);
76 fprintf(stderr
, "Error while loading %s\n", argv
[i
]);
79 fprintf(stderr
, "\n");
84 char* serial_port_name
= argv
[1];
86 if (!OpenProxmark(serial_port_name
, true, 120)) { // wait for 2 minutes
87 fprintf(stderr
, "Could not find Proxmark on %s.\n\n", serial_port_name
);
90 fprintf(stderr
," Found.\n");
93 res
= flash_start_flashing(can_write_bl
, serial_port_name
);
97 fprintf(stderr
, "\nFlashing...\n");
99 for (int i
= 0; i
< num_files
; i
++) {
100 res
= flash_write(&files
[i
]);
103 flash_free(&files
[i
]);
104 fprintf(stderr
, "\n");
107 fprintf(stderr
, "Resetting hardware...\n");
109 res
= flash_stop_flashing();
113 // Stop the command thread.
116 fprintf(stderr
, "All done.\n\n");
117 fprintf(stderr
, "Have a nice day!\n");