mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
New button behaviour in bootloader mode:
- Keep button pressed when powering to force entering bootloader - Once in bootloader more, you can release the button - When in bootloader mode (no matter how you entered that mode) - One button press to quit bootloader mode and boot main image
This commit is contained in:
parent
ade858b4f5
commit
51e4df533e
2 changed files with 16 additions and 13 deletions
|
@ -220,11 +220,14 @@ void UsbPacketReceived(uint8_t *packet, int len) {
|
||||||
reply_old(CMD_ACK, arg0, 0, 0, 0, 0);
|
reply_old(CMD_ACK, arg0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flash_mode(int externally_entered) {
|
static void flash_mode(void) {
|
||||||
start_addr = 0;
|
start_addr = 0;
|
||||||
end_addr = 0;
|
end_addr = 0;
|
||||||
bootrom_unlocked = 0;
|
bootrom_unlocked = 0;
|
||||||
uint8_t rx[sizeof(PacketCommandOLD)];
|
uint8_t rx[sizeof(PacketCommandOLD)];
|
||||||
|
common_area.command = COMMON_AREA_COMMAND_NONE;
|
||||||
|
if (!common_area.flags.button_pressed && BUTTON_PRESS())
|
||||||
|
common_area.flags.button_pressed = 1;
|
||||||
|
|
||||||
usb_enable();
|
usb_enable();
|
||||||
|
|
||||||
|
@ -241,17 +244,17 @@ static void flash_mode(int externally_entered) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!externally_entered && !BUTTON_PRESS()) {
|
if (common_area.flags.button_pressed && !BUTTON_PRESS()) {
|
||||||
|
common_area.flags.button_pressed = 0;
|
||||||
|
}
|
||||||
|
if (!common_area.flags.button_pressed && BUTTON_PRESS()) {
|
||||||
/* Perform a reset to leave flash mode */
|
/* Perform a reset to leave flash mode */
|
||||||
|
common_area.flags.button_pressed = 1;
|
||||||
usb_disable();
|
usb_disable();
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
AT91C_BASE_RSTC->RSTC_RCR = RST_CONTROL_KEY | AT91C_RSTC_PROCRST;
|
AT91C_BASE_RSTC->RSTC_RCR = RST_CONTROL_KEY | AT91C_RSTC_PROCRST;
|
||||||
for (;;) {};
|
for (;;) {};
|
||||||
}
|
}
|
||||||
if (externally_entered && BUTTON_PRESS()) {
|
|
||||||
/* Let the user's button press override the automatic leave */
|
|
||||||
externally_entered = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,14 +345,13 @@ void BootROM(void) {
|
||||||
}
|
}
|
||||||
common_area.flags.bootrom_present = 1;
|
common_area.flags.bootrom_present = 1;
|
||||||
|
|
||||||
if (common_area.command == COMMON_AREA_COMMAND_ENTER_FLASH_MODE) {
|
if ((common_area.command == COMMON_AREA_COMMAND_ENTER_FLASH_MODE) ||
|
||||||
common_area.command = COMMON_AREA_COMMAND_NONE;
|
(!common_area.flags.button_pressed && BUTTON_PRESS()) ||
|
||||||
flash_mode(1);
|
(_osimage_entry == 0xffffffffU)) {
|
||||||
} else if (BUTTON_PRESS()) {
|
flash_mode();
|
||||||
flash_mode(0);
|
|
||||||
} else if (_osimage_entry == 0xffffffffU) {
|
|
||||||
flash_mode(1);
|
|
||||||
} else {
|
} else {
|
||||||
|
// clear button status, even if button still pressed
|
||||||
|
common_area.flags.button_pressed = 0;
|
||||||
// jump to Flash address of the osimage entry point (LSBit set for thumb mode)
|
// jump to Flash address of the osimage entry point (LSBit set for thumb mode)
|
||||||
__asm("bx %0\n" : : "r"(((int)&_osimage_entry) | 0x1));
|
__asm("bx %0\n" : : "r"(((int)&_osimage_entry) | 0x1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ struct common_area {
|
||||||
struct {
|
struct {
|
||||||
unsigned int bootrom_present: 1; /* Set when a bootrom that is capable of parsing the common area is present */
|
unsigned int bootrom_present: 1; /* Set when a bootrom that is capable of parsing the common area is present */
|
||||||
unsigned int osimage_present: 1; /* Set when a osimage that is capable of parsing the common area is present */
|
unsigned int osimage_present: 1; /* Set when a osimage that is capable of parsing the common area is present */
|
||||||
|
unsigned int button_pressed: 1;
|
||||||
} __attribute__((packed)) flags;
|
} __attribute__((packed)) flags;
|
||||||
int arg1, arg2;
|
int arg1, arg2;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue