2010-02-21 08:47:22 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
|
|
|
// at your option, any later version. See the LICENSE.txt file for the text of
|
|
|
|
// the license.
|
|
|
|
//-----------------------------------------------------------------------------
|
2010-02-26 22:03:43 +08:00
|
|
|
// Flasher frontend tool
|
2010-02-21 08:47:22 +08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2009-04-09 14:43:20 +08:00
|
|
|
#include <stdio.h>
|
2010-02-06 17:33:17 +08:00
|
|
|
#include <stdlib.h>
|
2010-02-26 22:03:43 +08:00
|
|
|
#include <string.h>
|
2010-02-21 07:35:09 +08:00
|
|
|
#include "sleep.h"
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
#include "proxusb.h"
|
2010-01-04 13:11:08 +08:00
|
|
|
#include "flash.h"
|
2009-04-09 14:43:20 +08:00
|
|
|
|
2010-02-26 22:03:43 +08:00
|
|
|
static void usage(char *argv0)
|
2009-09-01 22:35:13 +08:00
|
|
|
{
|
2010-02-26 22:03:43 +08:00
|
|
|
fprintf(stderr, "Usage: %s [-b] image.elf [image.elf...]\n\n", argv0);
|
|
|
|
fprintf(stderr, "\t-b\tEnable flashing of bootloader area (DANGEROUS)\n\n");
|
|
|
|
fprintf(stderr, "Example: %s path/to/osimage.elf path/to/fpgaimage.elf\n", argv0);
|
2009-09-01 22:35:13 +08:00
|
|
|
}
|
2009-04-09 14:43:20 +08:00
|
|
|
|
2010-02-26 22:03:43 +08:00
|
|
|
#define MAX_FILES 4
|
|
|
|
|
Client cleanup and restructuring. Stage 1...
Next Step is refactoring some of the giant functions which are
just copy/paste of some other ones with just a few line changes,
removing unnecessary 'goto' etc.
The MS Windows version is broken with this commit but will be fixed
soon. Everything can't be done all at once :P
The commands are now hierarchical, for example:
"hf 14a read" vs. "hf 14b read".
You can also request help:
"hf help", "data help", "hf 15 help" etc.
Indents are now space-based, not tab-based anymore. Hopefully
no one will be trolling about it, considering the suicide-prone work
being done here ;)
client/cmdhw.c, client/proxusb.c, client/cmdhw.h, client/proxusb.h,
client/cmdmain.c, client/cmdlfhid.c, client/cmdmain.h, client/cmdlfhid.h,
client/data.c, client/data.h, client/cmdhf.c, client/cmdlf.c,
client/cmdhf.h, client/cmdhf15.c, client/cmdhf14b.c, client/cmdlf.h,
client/cmdhf15.h, client/cmdhf14b.h, client/cmddata.c, client/cmddata.h,
client/ui.c, client/cmdparser.c, client/cmdlfti.c, client/ui.h,
client/cmdlfem4x.c, client/cmdparser.h, client/cmdlfti.h, client/cmdlfem4x.h,
client/graph.c, client/graph.h, client/cmdhf14a.c, client/cmdhf14a.h,
client/cmdhflegic.c, client/cmdhflegic.c: New files.
client/cli.c, client/flasher.c, client/snooper.c, client/proxmark3.c,
client/proxmark3.h, client/Makefile: Update accordingly.
client/flash.h, client/flash.c, client/proxgui.cpp: Cosmetic changes.
client/translate.h, client/command.c, client/gui.c,
client/usb.c, client/prox.h: Remove.
include/usb_cmd.h (CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM): Remove dead cmd.
common/crc16.h: New file.
common/crc16.c: Modify accordingly.
common/iso14443crc.h: New file.
common/iso14443_crc.c: Rename to
common/iso14443crc.c: and modify accordingly.
armsrc/lfops.c, armsrc/iso14443.c,
armsrc/iso14443a.c: include .h files from
the common directory instead of including the c files.
common/Makefile.common, armsrc/Makefile: Modify accordingly.
2010-02-04 09:27:07 +08:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2010-02-26 22:03:43 +08:00
|
|
|
int can_write_bl = 0;
|
|
|
|
int num_files = 0;
|
|
|
|
int res;
|
|
|
|
flash_file_t files[MAX_FILES];
|
|
|
|
|
|
|
|
memset(files, 0, sizeof(files));
|
|
|
|
|
|
|
|
if (argc < 2) {
|
|
|
|
usage(argv[0]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 1; i < argc; i++) {
|
|
|
|
if (argv[i][0] == '-') {
|
|
|
|
if (!strcmp(argv[i], "-b")) {
|
|
|
|
can_write_bl = 1;
|
|
|
|
} else {
|
|
|
|
usage(argv[0]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
res = flash_load(&files[num_files], argv[i], can_write_bl);
|
|
|
|
if (res < 0) {
|
|
|
|
fprintf(stderr, "Error while loading %s\n", argv[i]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
num_files++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_init();
|
|
|
|
|
|
|
|
fprintf(stderr, "Waiting for Proxmark to appear on USB...");
|
|
|
|
while (!OpenProxmark(0)) {
|
|
|
|
sleep(1);
|
|
|
|
fprintf(stderr, ".");
|
|
|
|
}
|
|
|
|
fprintf(stderr, " Found.\n");
|
|
|
|
|
|
|
|
res = flash_start_flashing(can_write_bl);
|
|
|
|
if (res < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
fprintf(stderr, "\nFlashing...\n");
|
|
|
|
|
|
|
|
for (int i = 0; i < num_files; i++) {
|
|
|
|
res = flash_write(&files[i]);
|
|
|
|
if (res < 0)
|
|
|
|
return -1;
|
|
|
|
flash_free(&files[i]);
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr, "Resetting hardware...\n");
|
|
|
|
|
|
|
|
res = flash_stop_flashing();
|
|
|
|
if (res < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
CloseProxmark();
|
|
|
|
|
|
|
|
fprintf(stderr, "All done.\n\n");
|
|
|
|
fprintf(stderr, "Have a nice day!\n");
|
|
|
|
|
|
|
|
return 0;
|
2009-04-09 14:43:20 +08:00
|
|
|
}
|