mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-17 18:50:32 +08:00
--reboot-to-bootloader
This commit is contained in:
parent
9407be8ea8
commit
0d41ed0bba
3 changed files with 55 additions and 1 deletions
|
@ -595,6 +595,15 @@ 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) {
|
||||
int ret;
|
||||
|
||||
ret = enter_bootloader(serial_port_name);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -696,6 +696,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 +764,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 +977,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 +1040,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 +1087,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…
Reference in a new issue