mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
SendCommandOLD : comms & flash
This commit is contained in:
parent
2ac5482d9c
commit
b68ccfa7b8
3 changed files with 13 additions and 32 deletions
|
@ -259,8 +259,7 @@ fail:
|
|||
|
||||
// Get the state of the proxmark, backwards compatible
|
||||
static int get_proxmark_state(uint32_t *state) {
|
||||
PacketCommandOLD c = {CMD_DEVICE_INFO};
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_DEVICE_INFO, 0, 0, 0, NULL, 0);
|
||||
PacketResponseNG resp;
|
||||
WaitForResponse(CMD_UNKNOWN, &resp); // wait for any response. No timeout.
|
||||
|
||||
|
@ -300,20 +299,16 @@ static int enter_bootloader(char *serial_port_name) {
|
|||
|
||||
if (state & DEVICE_INFO_FLAG_CURRENT_MODE_OS) {
|
||||
fprintf(stdout, _BLUE_("Entering bootloader...") "\n");
|
||||
PacketCommandOLD c;
|
||||
memset(&c, 0, sizeof(c));
|
||||
|
||||
if ((state & DEVICE_INFO_FLAG_BOOTROM_PRESENT)
|
||||
&& (state & DEVICE_INFO_FLAG_OSIMAGE_PRESENT)) {
|
||||
// New style handover: Send CMD_START_FLASH, which will reset the board
|
||||
// and enter the bootrom on the next boot.
|
||||
c.cmd = CMD_START_FLASH;
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_START_FLASH, 0, 0, 0, NULL, 0);
|
||||
fprintf(stdout, "(Press and release the button only to abort)\n");
|
||||
} else {
|
||||
// Old style handover: Ask the user to press the button, then reset the board
|
||||
c.cmd = CMD_HARDWARE_RESET;
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_HARDWARE_RESET, 0, 0, 0, NULL, 0);
|
||||
fprintf(stdout, "Press and hold down button NOW if your bootloader requires it.\n");
|
||||
}
|
||||
msleep(100);
|
||||
|
@ -361,19 +356,13 @@ int flash_start_flashing(int enable_bl_writes, char *serial_port_name) {
|
|||
if (state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) {
|
||||
// This command is stupid. Why the heck does it care which area we're
|
||||
// flashing, as long as it's not the bootloader area? The mind boggles.
|
||||
PacketCommandOLD c = {CMD_START_FLASH};
|
||||
PacketResponseNG resp;
|
||||
|
||||
if (enable_bl_writes) {
|
||||
c.arg[0] = FLASH_START;
|
||||
c.arg[1] = FLASH_END;
|
||||
c.arg[2] = START_FLASH_MAGIC;
|
||||
SendCommandOLD(CMD_START_FLASH, FLASH_START, FLASH_END, START_FLASH_MAGIC, NULL, 0);
|
||||
} else {
|
||||
c.arg[0] = BOOTLOADER_END;
|
||||
c.arg[1] = FLASH_END;
|
||||
c.arg[2] = 0;
|
||||
SendCommandOLD(CMD_START_FLASH,BOOTLOADER_END, FLASH_END, 0, NULL, 0);
|
||||
}
|
||||
SendCommand(&c);
|
||||
return wait_for_ack(&resp);
|
||||
} else {
|
||||
fprintf(stderr, _RED_("Note: Your bootloader does not understand the new START_FLASH command") "\n");
|
||||
|
@ -386,10 +375,8 @@ 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);
|
||||
memcpy(block_buf, data, length);
|
||||
PacketCommandOLD c = {CMD_FINISH_WRITE, {address, 0, 0}};
|
||||
PacketResponseNG resp;
|
||||
memcpy(c.d.asBytes, block_buf, length);
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_FINISH_WRITE, address, 0, 0, block_buf, length);
|
||||
int ret = wait_for_ack(&resp);
|
||||
if (ret && resp.oldarg[0]) {
|
||||
uint32_t lock_bits = resp.oldarg[0] >> 16;
|
||||
|
@ -459,8 +446,7 @@ void flash_free(flash_file_t *ctx) {
|
|||
|
||||
// just reset the unit
|
||||
int flash_stop_flashing(void) {
|
||||
PacketCommandOLD c = {CMD_HARDWARE_RESET};
|
||||
SendCommand(&c);
|
||||
SendCommandOLD(CMD_HARDWARE_RESET, 0, 0, 0, NULL, 0);
|
||||
msleep(100);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue