mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-20 03:48:33 +08:00
Merge pull request #1710 from nemanjan00/reboot-to-bootloader
Reboot to bootloader
This commit is contained in:
commit
95f413d102
4 changed files with 53 additions and 1 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
|||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||
|
||||
## [unreleased][unreleased]
|
||||
- Added `--reboot-to-bootloader` arg to pm3
|
||||
- Changed `hf 14b raw` - now supports selecting Fuji/Xerox tag (@horror)
|
||||
- Added `hf xerox dump` - dump a Fuji/Xerox tag (@horror)
|
||||
- Added `hf xerox info` - read Fuji/Xerox tag (@horror)
|
||||
|
|
|
@ -595,6 +595,11 @@ int flash_start_flashing(int enable_bl_writes, char *serial_port_name, uint32_t
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// Reboot into bootloader
|
||||
int flash_reboot_bootloader(char *serial_port_name) {
|
||||
return enter_bootloader(serial_port_name);
|
||||
}
|
||||
|
||||
static int write_block(uint32_t address, uint8_t *data, uint32_t length) {
|
||||
uint8_t block_buf[BLOCK_SIZE];
|
||||
memset(block_buf, 0xFF, BLOCK_SIZE);
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef struct {
|
|||
int flash_load(flash_file_t *ctx, bool force);
|
||||
int flash_prepare(flash_file_t *ctx, int can_write_bl, int flash_size);
|
||||
int flash_start_flashing(int enable_bl_writes, char *serial_port_name, uint32_t *max_allowed);
|
||||
int flash_reboot_bootloader(char *serial_port_name);
|
||||
int flash_write(flash_file_t *ctx);
|
||||
void flash_free(flash_file_t *ctx);
|
||||
int flash_stop_flashing(void);
|
||||
|
|
|
@ -576,6 +576,7 @@ static void show_help(bool showFullHelp, char *exec_name) {
|
|||
PrintAndLogEx(NORMAL, " --incognito do not use history, prefs file nor log files");
|
||||
PrintAndLogEx(NORMAL, "\nOptions in flasher mode:");
|
||||
PrintAndLogEx(NORMAL, " --flash flash Proxmark3, requires at least one --image");
|
||||
PrintAndLogEx(NORMAL, " --reboot-bootloader reboot Proxmark3 into bootloader mode");
|
||||
PrintAndLogEx(NORMAL, " --unlock-bootloader Enable flashing of bootloader area *DANGEROUS* (need --flash)");
|
||||
PrintAndLogEx(NORMAL, " --force Enable flashing even if firmware seems to not match client version");
|
||||
PrintAndLogEx(NORMAL, " --image <imagefile> image to flash. Can be specified several times.");
|
||||
|
@ -696,6 +697,38 @@ finish2:
|
|||
PrintAndLogEx(INFO, "\nHave a nice day!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int reboot_bootloader_pm3(char *serial_port_name) {
|
||||
|
||||
int ret = PM3_EUNDEF;
|
||||
|
||||
if (serial_port_name == NULL) {
|
||||
PrintAndLogEx(ERR, "You must specify a port.\n");
|
||||
return PM3_EINVARG;
|
||||
}
|
||||
|
||||
if (OpenProxmark(&g_session.current_device, serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
|
||||
PrintAndLogEx(NORMAL, _GREEN_(" found"));
|
||||
} else {
|
||||
PrintAndLogEx(ERR, "Could not find Proxmark3 on " _RED_("%s") ".\n", serial_port_name);
|
||||
ret = PM3_ETIMEOUT;
|
||||
goto finish2;
|
||||
}
|
||||
|
||||
ret = flash_reboot_bootloader(serial_port_name);
|
||||
return ret;
|
||||
|
||||
finish2:
|
||||
if (ret == PM3_SUCCESS)
|
||||
PrintAndLogEx(SUCCESS, _CYAN_("All done"));
|
||||
else if (ret == PM3_EOPABORTED)
|
||||
PrintAndLogEx(FAILED, "Aborted by user");
|
||||
else
|
||||
PrintAndLogEx(ERR, "Aborted on error");
|
||||
PrintAndLogEx(INFO, "\nHave a nice day!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif //LIBPM3
|
||||
|
||||
void pm3_init(void) {
|
||||
|
@ -732,6 +765,7 @@ int main(int argc, char *argv[]) {
|
|||
strncpy(exec_name, basename(argv[0]), sizeof(exec_name) - 1);
|
||||
|
||||
bool flash_mode = false;
|
||||
bool reboot_bootloader_mode = false;
|
||||
bool flash_can_write_bl = false;
|
||||
bool flash_force = false;
|
||||
bool debug_mode_forced = false;
|
||||
|
@ -944,6 +978,12 @@ int main(int argc, char *argv[]) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// go to flash mode
|
||||
if (strcmp(argv[i], "--reboot-to-bootloader") == 0) {
|
||||
reboot_bootloader_mode = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// unlock bootloader area
|
||||
if (strcmp(argv[i], "--unlock-bootloader") == 0) {
|
||||
flash_can_write_bl = true;
|
||||
|
@ -1001,6 +1041,11 @@ int main(int argc, char *argv[]) {
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (reboot_bootloader_mode) {
|
||||
reboot_bootloader_pm3(port);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (script_cmd) {
|
||||
while (script_cmd[strlen(script_cmd) - 1] == ' ')
|
||||
script_cmd[strlen(script_cmd) - 1] = 0x00;
|
||||
|
@ -1043,7 +1088,7 @@ int main(int argc, char *argv[]) {
|
|||
PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") " mode. Check " _YELLOW_("\"%s -h\"") " if it's not what you want.\n", exec_name);
|
||||
|
||||
// ascii art only in interactive client
|
||||
if (!script_cmds_file && !script_cmd && g_session.stdinOnTTY && g_session.stdoutOnTTY && !flash_mode)
|
||||
if (!script_cmds_file && !script_cmd && g_session.stdinOnTTY && g_session.stdoutOnTTY && !flash_mode && !reboot_bootloader_mode)
|
||||
showBanner();
|
||||
|
||||
// Save settings if not loaded from settings json file.
|
||||
|
|
Loading…
Add table
Reference in a new issue