From 3d0ccbb1d54bac89c5739b609e76530abbc68f39 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sat, 28 Mar 2026 03:31:07 +0100 Subject: [PATCH] Add an `mcu_reset` impl for the kiibohd bootloader. (#25963) * Fixes resetting and split watchdog on the Ergodox Infinity. --- platforms/chibios/bootloaders/kiibohd.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/platforms/chibios/bootloaders/kiibohd.c b/platforms/chibios/bootloaders/kiibohd.c index 09a4d49b78..eb61cd2d0a 100644 --- a/platforms/chibios/bootloaders/kiibohd.c +++ b/platforms/chibios/bootloaders/kiibohd.c @@ -30,4 +30,21 @@ __attribute__((weak)) void bootloader_jump(void) { // request reset SCB->AIRCR = SCB_AIRCR_VECTKEY_WRITEMAGIC | SCB_AIRCR_SYSRESETREQ_Msk; } -__attribute__((weak)) void mcu_reset(void) {} + +__attribute__((weak)) void mcu_reset(void) { + /* Ensure all outstanding memory operations complete */ + __DSB(); + __ISB(); + + /* Request system reset (preserve PRIGROUP) */ + uint32_t aircr = SCB->AIRCR; + aircr &= ~SCB_AIRCR_VECTKEY_Msk; + aircr |= SCB_AIRCR_VECTKEY_WRITEMAGIC; + aircr |= SCB_AIRCR_SYSRESETREQ_Msk; + SCB->AIRCR = aircr; + + /* Wait for reset to occur */ + while (true) { + __NOP(); + } +}