mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
searchFile for firmwares
This commit is contained in:
parent
f7624a7767
commit
6385ee960f
4 changed files with 42 additions and 14 deletions
|
@ -956,7 +956,10 @@ static int searchFinalFile(char **foundpath, const char *pm3dir, const char *sea
|
||||||
}
|
}
|
||||||
// try pm3 dirs in current repo workdir (dev mode)
|
// try pm3 dirs in current repo workdir (dev mode)
|
||||||
if ((exec_path != NULL) &&
|
if ((exec_path != NULL) &&
|
||||||
((strcmp(TRACES_SUBDIR, pm3dir) == 0))) {
|
((strcmp(TRACES_SUBDIR, pm3dir) == 0) ||
|
||||||
|
(strcmp(FIRMWARES_SUBDIR, pm3dir) == 0) ||
|
||||||
|
(strcmp(BOOTROM_SUBDIR, pm3dir) == 0) ||
|
||||||
|
(strcmp(FULLIMAGE_SUBDIR, pm3dir) == 0))) {
|
||||||
char *above = "../";
|
char *above = "../";
|
||||||
char *path = calloc(strlen(exec_path) + strlen(above) + strlen(pm3dir) + strlen(filename) + 1, sizeof(char));
|
char *path = calloc(strlen(exec_path) + strlen(above) + strlen(pm3dir) + strlen(filename) + 1, sizeof(char));
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
|
|
|
@ -330,17 +330,40 @@ static int flash_pm3(char *serial_port_name, uint8_t num_files, char *filenames[
|
||||||
int ret = PM3_EUNDEF;
|
int ret = PM3_EUNDEF;
|
||||||
flash_file_t files[FLASH_MAX_FILES];
|
flash_file_t files[FLASH_MAX_FILES];
|
||||||
memset(files, 0, sizeof(files));
|
memset(files, 0, sizeof(files));
|
||||||
|
char *filepaths[FLASH_MAX_FILES];
|
||||||
|
|
||||||
if (serial_port_name == NULL) {
|
if (serial_port_name == NULL) {
|
||||||
PrintAndLogEx(ERR, "You must specify a port.\n");
|
PrintAndLogEx(ERR, "You must specify a port.\n");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0 ; i < num_files; ++i) {
|
||||||
|
char *path;
|
||||||
|
ret = searchFile(&path, FIRMWARES_SUBDIR, filenames[i], ".elf", true);
|
||||||
|
if (ret != PM3_SUCCESS) {
|
||||||
|
ret = searchFile(&path, BOOTROM_SUBDIR, filenames[i], ".elf", true);
|
||||||
|
}
|
||||||
|
if (ret != PM3_SUCCESS) {
|
||||||
|
// Last try, let the error msg be displayed if not found
|
||||||
|
ret = searchFile(&path, FULLIMAGE_SUBDIR, filenames[i], ".elf", false);
|
||||||
|
}
|
||||||
|
if (ret != PM3_SUCCESS) {
|
||||||
|
goto finish2;
|
||||||
|
}
|
||||||
|
filepaths[i] = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintAndLogEx(SUCCESS, "About to use the following file%s:", num_files > 1 ? "s" : "");
|
||||||
|
for (int i = 0 ; i < num_files; ++i) {
|
||||||
|
PrintAndLogEx(SUCCESS, " %s", filepaths[i]);
|
||||||
|
}
|
||||||
|
|
||||||
if (OpenProxmark(serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
if (OpenProxmark(serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||||
PrintAndLogEx(NORMAL, _GREEN_("Found"));
|
PrintAndLogEx(NORMAL, _GREEN_("Found"));
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(ERR, "Could not find Proxmark3 on " _RED_("%s") ".\n", serial_port_name);
|
PrintAndLogEx(ERR, "Could not find Proxmark3 on " _RED_("%s") ".\n", serial_port_name);
|
||||||
return PM3_ETIMEOUT;
|
ret = PM3_ETIMEOUT;
|
||||||
|
goto finish2;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t max_allowed = 0;
|
uint32_t max_allowed = 0;
|
||||||
|
@ -353,7 +376,7 @@ static int flash_pm3(char *serial_port_name, uint8_t num_files, char *filenames[
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
for (int i = 0 ; i < num_files; ++i) {
|
for (int i = 0 ; i < num_files; ++i) {
|
||||||
ret = flash_load(&files[i], filenames[i], can_write_bl, max_allowed * ONE_KB);
|
ret = flash_load(&files[i], filepaths[i], can_write_bl, max_allowed * ONE_KB);
|
||||||
if (ret != PM3_SUCCESS) {
|
if (ret != PM3_SUCCESS) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
@ -373,9 +396,12 @@ static int flash_pm3(char *serial_port_name, uint8_t num_files, char *filenames[
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
ret = flash_stop_flashing();
|
ret = flash_stop_flashing();
|
||||||
|
|
||||||
CloseProxmark();
|
CloseProxmark();
|
||||||
|
finish2:
|
||||||
|
for (int i = 0 ; i < num_files; ++i) {
|
||||||
|
if (filepaths[i] != NULL)
|
||||||
|
free(filepaths[i]);
|
||||||
|
}
|
||||||
if (ret == PM3_SUCCESS)
|
if (ret == PM3_SUCCESS)
|
||||||
PrintAndLogEx(SUCCESS, _BLUE_("All done."));
|
PrintAndLogEx(SUCCESS, _BLUE_("All done."));
|
||||||
else
|
else
|
||||||
|
@ -599,6 +625,9 @@ int main(int argc, char *argv[]) {
|
||||||
if (speed == 0)
|
if (speed == 0)
|
||||||
speed = USART_BAUD_RATE;
|
speed = USART_BAUD_RATE;
|
||||||
|
|
||||||
|
// set global variables
|
||||||
|
set_my_executable_path();
|
||||||
|
|
||||||
if (flash_mode) {
|
if (flash_mode) {
|
||||||
flash_pm3(port, flash_num_files, flash_filenames, flash_can_write_bl);
|
flash_pm3(port, flash_num_files, flash_filenames, flash_can_write_bl);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
@ -629,9 +658,6 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set global variables
|
|
||||||
set_my_executable_path();
|
|
||||||
|
|
||||||
// try to open USB connection to Proxmark
|
// try to open USB connection to Proxmark
|
||||||
if (port != NULL) {
|
if (port != NULL) {
|
||||||
OpenProxmark(port, waitCOMPort, 20, false, speed);
|
OpenProxmark(port, waitCOMPort, 20, false, speed);
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
#define LUA_SCRIPTS_SUBDIR "luascripts" PATHSEP
|
#define LUA_SCRIPTS_SUBDIR "luascripts" PATHSEP
|
||||||
#define RESOURCES_SUBDIR "resources" PATHSEP
|
#define RESOURCES_SUBDIR "resources" PATHSEP
|
||||||
#define TRACES_SUBDIR "traces" PATHSEP
|
#define TRACES_SUBDIR "traces" PATHSEP
|
||||||
|
#define FIRMWARES_SUBDIR "firmware" PATHSEP
|
||||||
|
#define BOOTROM_SUBDIR "bootrom/obj" PATHSEP
|
||||||
|
#define FULLIMAGE_SUBDIR "armsrc/obj" PATHSEP
|
||||||
|
|
||||||
#define PACKED __attribute__((packed))
|
#define PACKED __attribute__((packed))
|
||||||
|
|
||||||
|
|
8
pm3
8
pm3
|
@ -3,21 +3,17 @@
|
||||||
# Usage: run option -h to get help
|
# Usage: run option -h to get help
|
||||||
|
|
||||||
PM3PATH=$(dirname "$0")
|
PM3PATH=$(dirname "$0")
|
||||||
|
FULLIMAGE="fullimage.elf"
|
||||||
|
BOOTIMAGE="bootrom.elf"
|
||||||
# try pm3 dirs in current repo workdir
|
# try pm3 dirs in current repo workdir
|
||||||
if [ -d "$PM3PATH/client/" ]; then
|
if [ -d "$PM3PATH/client/" ]; then
|
||||||
CLIENT="$PM3PATH/client/proxmark3"
|
CLIENT="$PM3PATH/client/proxmark3"
|
||||||
FULLIMAGE="$PM3PATH/armsrc/obj/fullimage.elf"
|
|
||||||
BOOTIMAGE="$PM3PATH/bootrom/obj/bootrom.elf"
|
|
||||||
# try install dir
|
# try install dir
|
||||||
elif [ -x "$PM3PATH/proxmark3" ]; then
|
elif [ -x "$PM3PATH/proxmark3" ]; then
|
||||||
CLIENT="$PM3PATH/proxmark3"
|
CLIENT="$PM3PATH/proxmark3"
|
||||||
FULLIMAGE="$PM3PATH/../share/proxmark3/firmware/fullimage.elf"
|
|
||||||
BOOTIMAGE="$PM3PATH/../share/proxmark3/firmware/bootrom.elf"
|
|
||||||
else
|
else
|
||||||
# hope it's installed somehow, still not sure where fw images are...
|
# hope it's installed somehow, still not sure where fw images are...
|
||||||
CLIENT="proxmark3"
|
CLIENT="proxmark3"
|
||||||
FULLIMAGE="$PM3PATH/../share/proxmark3/firmware/fullimage.elf"
|
|
||||||
BOOTIMAGE="$PM3PATH/../share/proxmark3/firmware/bootrom.elf"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function wait4proxmark_Linux {
|
function wait4proxmark_Linux {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue