mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-27 17:43:07 +08:00
Introduce SendCommandBL
This commit is contained in:
parent
e93b4e3c61
commit
4fd520c6d4
3 changed files with 15 additions and 7 deletions
|
@ -57,6 +57,13 @@ static uint64_t timeout_start_time;
|
||||||
|
|
||||||
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
|
static bool dl_it(uint8_t *dest, uint32_t bytes, uint32_t start_index, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd);
|
||||||
|
|
||||||
|
// Simple alias to track usages linked to the Bootloader, these commands must not be migrated.
|
||||||
|
// - commands sent to enter bootloader mode as we might have to talk to old firmwares
|
||||||
|
// - commands sent to the bootloader as it only supports OLD frames (which will always be the case for old BL)
|
||||||
|
void SendCommandBL(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
||||||
|
SendCommandOLD(cmd, arg0, arg1, arg2, data, len);
|
||||||
|
}
|
||||||
|
|
||||||
void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
|
||||||
PacketCommandOLD c = {CMD_UNKNOWN, {0, 0, 0}, {{0}}};
|
PacketCommandOLD c = {CMD_UNKNOWN, {0, 0, 0}, {{0}}};
|
||||||
c.cmd = cmd;
|
c.cmd = cmd;
|
||||||
|
|
|
@ -56,6 +56,7 @@ typedef struct {
|
||||||
extern communication_arg_t conn;
|
extern communication_arg_t conn;
|
||||||
|
|
||||||
void *uart_receiver(void *targ);
|
void *uart_receiver(void *targ);
|
||||||
|
void SendCommandBL(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||||
void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||||
void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len);
|
void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len);
|
||||||
void SendCommandMIX(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
void SendCommandMIX(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len);
|
||||||
|
|
|
@ -259,7 +259,7 @@ fail:
|
||||||
|
|
||||||
// Get the state of the proxmark, backwards compatible
|
// Get the state of the proxmark, backwards compatible
|
||||||
static int get_proxmark_state(uint32_t *state) {
|
static int get_proxmark_state(uint32_t *state) {
|
||||||
SendCommandOLD(CMD_DEVICE_INFO, 0, 0, 0, NULL, 0);
|
SendCommandBL(CMD_DEVICE_INFO, 0, 0, 0, NULL, 0);
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
WaitForResponse(CMD_UNKNOWN, &resp); // wait for any response. No timeout.
|
WaitForResponse(CMD_UNKNOWN, &resp); // wait for any response. No timeout.
|
||||||
|
|
||||||
|
@ -304,11 +304,11 @@ static int enter_bootloader(char *serial_port_name) {
|
||||||
&& (state & DEVICE_INFO_FLAG_OSIMAGE_PRESENT)) {
|
&& (state & DEVICE_INFO_FLAG_OSIMAGE_PRESENT)) {
|
||||||
// New style handover: Send CMD_START_FLASH, which will reset the board
|
// New style handover: Send CMD_START_FLASH, which will reset the board
|
||||||
// and enter the bootrom on the next boot.
|
// and enter the bootrom on the next boot.
|
||||||
SendCommandOLD(CMD_START_FLASH, 0, 0, 0, NULL, 0);
|
SendCommandBL(CMD_START_FLASH, 0, 0, 0, NULL, 0);
|
||||||
PrintAndLogEx(SUCCESS, "(Press and release the button only to " _YELLOW_("abort") ")");
|
PrintAndLogEx(SUCCESS, "(Press and release the button only to " _YELLOW_("abort") ")");
|
||||||
} else {
|
} else {
|
||||||
// Old style handover: Ask the user to press the button, then reset the board
|
// Old style handover: Ask the user to press the button, then reset the board
|
||||||
SendCommandOLD(CMD_HARDWARE_RESET, 0, 0, 0, NULL, 0);
|
SendCommandBL(CMD_HARDWARE_RESET, 0, 0, 0, NULL, 0);
|
||||||
PrintAndLogEx(SUCCESS, "Press and hold down button NOW if your bootloader requires it.");
|
PrintAndLogEx(SUCCESS, "Press and hold down button NOW if your bootloader requires it.");
|
||||||
}
|
}
|
||||||
msleep(100);
|
msleep(100);
|
||||||
|
@ -358,9 +358,9 @@ int flash_start_flashing(int enable_bl_writes, char *serial_port_name) {
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
|
|
||||||
if (enable_bl_writes) {
|
if (enable_bl_writes) {
|
||||||
SendCommandOLD(CMD_START_FLASH, FLASH_START, FLASH_END, START_FLASH_MAGIC, NULL, 0);
|
SendCommandBL(CMD_START_FLASH, FLASH_START, FLASH_END, START_FLASH_MAGIC, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
SendCommandOLD(CMD_START_FLASH, BOOTLOADER_END, FLASH_END, 0, NULL, 0);
|
SendCommandBL(CMD_START_FLASH, BOOTLOADER_END, FLASH_END, 0, NULL, 0);
|
||||||
}
|
}
|
||||||
return wait_for_ack(&resp);
|
return wait_for_ack(&resp);
|
||||||
} else {
|
} else {
|
||||||
|
@ -375,7 +375,7 @@ static int write_block(uint32_t address, uint8_t *data, uint32_t length) {
|
||||||
memset(block_buf, 0xFF, BLOCK_SIZE);
|
memset(block_buf, 0xFF, BLOCK_SIZE);
|
||||||
memcpy(block_buf, data, length);
|
memcpy(block_buf, data, length);
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
SendCommandOLD(CMD_FINISH_WRITE, address, 0, 0, block_buf, length);
|
SendCommandBL(CMD_FINISH_WRITE, address, 0, 0, block_buf, length);
|
||||||
int ret = wait_for_ack(&resp);
|
int ret = wait_for_ack(&resp);
|
||||||
if (ret && resp.oldarg[0]) {
|
if (ret && resp.oldarg[0]) {
|
||||||
uint32_t lock_bits = resp.oldarg[0] >> 16;
|
uint32_t lock_bits = resp.oldarg[0] >> 16;
|
||||||
|
@ -444,7 +444,7 @@ void flash_free(flash_file_t *ctx) {
|
||||||
|
|
||||||
// just reset the unit
|
// just reset the unit
|
||||||
int flash_stop_flashing(void) {
|
int flash_stop_flashing(void) {
|
||||||
SendCommandOLD(CMD_HARDWARE_RESET, 0, 0, 0, NULL, 0);
|
SendCommandBL(CMD_HARDWARE_RESET, 0, 0, 0, NULL, 0);
|
||||||
msleep(100);
|
msleep(100);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue