remove stale bootloader magic jump; 0xd1 jumps directly

This commit is contained in:
comma
2026-08-28 09:21:55 +08:00
parent 2feb6b0b28
commit e2a010020b
3 changed files with 8 additions and 19 deletions
+6 -15
View File
@@ -33,15 +33,10 @@ void early_initialization(void) {
// Init register and interrupt tables
init_registers();
// after it's been in the bootloader, things are initted differently, so we reset
if ((enter_bootloader_mode != BOOT_NORMAL) &&
(enter_bootloader_mode != ENTER_BOOTLOADER_MAGIC) &&
(enter_bootloader_mode != ENTER_SOFTLOADER_MAGIC)) {
enter_bootloader_mode = BOOT_NORMAL;
// NOTE: no NVIC_SystemReset here - a stale RAM value during a plain
// hardware-reset boot was observed to hang before USB init on this board.
// Just clear the stale value and continue.
}
// Always clear any bootloader magic left in RAM. A stale value from a
// previous bootloader/DFU session would otherwise send us back into the ROM
// bootloader on a plain hardware reset (which then does not enumerate USB).
enter_bootloader_mode = BOOT_NORMAL;
// if wrong chip, reboot
volatile unsigned int id = DBGMCU->IDCODE;
@@ -57,10 +52,6 @@ void early_initialization(void) {
detect_board_type();
if (enter_bootloader_mode == ENTER_BOOTLOADER_MAGIC) {
led_init();
current_board->init_bootloader();
led_set(LED_GREEN, 1);
jump_to_bootloader();
}
// Bootloader entry is done directly by the 0xd1 comms handler via
// jump_to_bootloader(), not through a magic RAM value (which can be stale).
}
+1 -2
View File
@@ -71,8 +71,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
switch (req->param1) {
case 0:
print("-> entering bootloader\n");
enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC;
NVIC_SystemReset();
jump_to_bootloader();
break;
case 1:
print("-> entering softloader\n");
+1 -2
View File
@@ -180,8 +180,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
// only allow bootloader entry on debug builds
#ifdef ALLOW_DEBUG
print("-> entering bootloader\n");
enter_bootloader_mode = ENTER_BOOTLOADER_MAGIC;
NVIC_SystemReset();
jump_to_bootloader();
#endif
break;
case 1: