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 //-----------------------------------------------------------------------------
16 static void usage(char *argv0
) {
17 fprintf(stderr
, "Usage: %s [-b] image.elf [image.elf...]\n\n", argv0
);
18 fprintf(stderr
, "\t-b\tEnable flashing of bootloader area (DANGEROUS)\n\n");
19 fprintf(stderr
, "Example: %s path/to/osimage.elf path/to/fpgaimage.elf\n", argv0
);
24 int main(int argc
, char **argv
) {
28 flash_file_t files
[MAX_FILES
];
30 memset(files
, 0, sizeof(files
));
37 for (int i
= 1; i
< argc
; i
++) {
38 if (argv
[i
][0] == '-') {
39 if (!strcmp(argv
[i
], "-b")) {
46 res
= flash_load(&files
[num_files
], argv
[i
], can_write_bl
);
48 fprintf(stderr
, "Error while loading %s\n", argv
[i
]);
51 fprintf(stderr
, "\n");
58 fprintf(stderr
, "Waiting for Proxmark3 to appear on USB...");
59 while (!OpenProxmark(1)) {
64 fprintf(stderr
, " Found.\n");
66 res
= flash_start_flashing(can_write_bl
);
70 fprintf(stderr
, "\nFlashing...\n");
72 for (int i
= 0; i
< num_files
; i
++) {
73 res
= flash_write(&files
[i
]);
76 flash_free(&files
[i
]);
77 fprintf(stderr
, "\n");
80 fprintf(stderr
, "Resetting hardware...\n");
82 res
= flash_stop_flashing();
88 fprintf(stderr
, "All done.\n\n");
89 fprintf(stderr
, "Have a nice day!\n");