Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Add Reboot keycode to core #15990

Merged
merged 20 commits into from
May 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix stuff
  • Loading branch information
drashna committed May 4, 2022
commit b849051fe8a272c4f04818e5a073959e82261bdf
4 changes: 3 additions & 1 deletion platforms/avr/bootloaders/bootloadhid.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ __attribute__((weak)) void bootloader_jump(void) {
eeprom_write_byte((uint8_t *)1, 0x00);

// watchdog reset
mcu_reset();
wdt_enable(WDTO_250MS);
for (;;)
;
}

__attribute__((weak)) void mcu_reset(void) {
Expand Down
7 changes: 6 additions & 1 deletion platforms/avr/bootloaders/caterina.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ __attribute__((weak)) void bootloader_jump(void) {

*bootKeyPtr = bootKey;

mcu_reset();
// setup watchdog timeout
wdt_enable(WDTO_60MS);

// wait for watchdog timer to trigger
while (1) {
}
}

__attribute__((weak)) void mcu_reset(void) {
Expand Down
5 changes: 4 additions & 1 deletion platforms/avr/bootloaders/dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ __attribute__((weak)) void bootloader_jump(void) {
_delay_ms(5); // 5 seems to work fine

reset_key = BOOTLOADER_RESET_KEY;
mcu_reset();
// watchdog reset
wdt_enable(WDTO_250MS);
for (;;)
;
}

__attribute__((weak)) void mcu_reset(void) {
Expand Down
2 changes: 1 addition & 1 deletion platforms/chibios/bootloaders/custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
#include "bootloader.h"

__attribute__((weak)) void bootloader_jump(void) {}
__attribute__((weak)) void mcu_reset(void) { NVIC_SystemReset(); }
__attribute__((weak)) void mcu_reset(void) {}

__attribute__((weak)) void enter_bootloader_mode_if_requested(void) {}
4 changes: 1 addition & 3 deletions platforms/chibios/bootloaders/gd32v_dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ __attribute__((weak)) void bootloader_jump(void) {
*DBGMCU_CMD = DBGMCU_CMD_RESET;
}

__attribute__((weak)) void mcu_reset(void) {
*DBGMCU_CMD = DBGMCU_CMD_RESET;
}
__attribute__((weak)) void mcu_reset(void) { *DBGMCU_CMD = DBGMCU_CMD_RESET; }

/* Jumping to bootloader is not possible from user code. */
void enter_bootloader_mode_if_requested(void) {}
10 changes: 3 additions & 7 deletions platforms/chibios/bootloaders/stm32_dfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ __attribute__((weak)) void bootloader_jump(void) {
mcu_reset();
}

__attribute__((weak)) void mcu_reset(void) {
NVIC_SystemReset();
}
__attribute__((weak)) void mcu_reset(void) { NVIC_SystemReset(); }
// not needed at all, but if anybody attempts to invoke it....
void enter_bootloader_mode_if_requested(void) {}

Expand All @@ -76,13 +74,11 @@ void enter_bootloader_mode_if_requested(void) {}

__attribute__((weak)) void bootloader_jump(void) {
*MAGIC_ADDR = BOOTLOADER_MAGIC; // set magic flag => reset handler will jump into boot loader
mcu_reset();
}

__attribute__((weak)) void mcu_reset(void) {
NVIC_SystemReset();
}

__attribute__((weak)) void mcu_reset(void) { NVIC_SystemReset(); }

void enter_bootloader_mode_if_requested(void) {
unsigned long *check = MAGIC_ADDR;
if (*check == BOOTLOADER_MAGIC) {
Expand Down
2 changes: 1 addition & 1 deletion platforms/chibios/bootloaders/stm32duino.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
#include <ch.h>

__attribute__((weak)) void bootloader_jump(void) { mcu_reset(); }
__attribute__((weak)) void mcu_reset(void) { NVIC_SystemReset(); }
__attribute__((weak)) void mcu_reset(void) {}
6 changes: 2 additions & 4 deletions platforms/chibios/bootloaders/tinyuf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
extern uint32_t _board_dfu_dbl_tap[];
#define DBL_TAP_REG _board_dfu_dbl_tap[0]

__attribute__((weak)) void mcu_reset(void) {
NVIC_SystemReset();
}
__attribute__((weak)) void mcu_reset(void) { NVIC_SystemReset(); }

__attribute__((weak)) void bootloader_jump(void) {
DBL_TAP_REG = DBL_TAP_MAGIC;
mcu_reset();
NVIC_SystemReset();
}

/* not needed, no two-stage reset */
Expand Down