From 7c92de267cd04ebc486772d1cd397af0e4d7b7a6 Mon Sep 17 00:00:00 2001 From: Clemens Elflein Date: Thu, 31 Oct 2024 00:25:59 +0100 Subject: [PATCH] Feat: Automatically reboot into user program after flashing --- bootloader/.idea/workspace.xml | 2 +- bootloader/main.c | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bootloader/.idea/workspace.xml b/bootloader/.idea/workspace.xml index 729c55d..453a8e8 100644 --- a/bootloader/.idea/workspace.xml +++ b/bootloader/.idea/workspace.xml @@ -167,7 +167,7 @@ - + diff --git a/bootloader/main.c b/bootloader/main.c index 17e40f2..629c9c4 100644 --- a/bootloader/main.c +++ b/bootloader/main.c @@ -164,12 +164,15 @@ int main(void) { #endif } - // prevent bootloader from bootloading - chMtxLock(&reboot_mutex); + while (1) { + // make sure we're not currently updating the software + chMtxLock(&reboot_mutex); - jump_to_user_program(); + jump_to_user_program(); - // allow bootloader to work again, since jumping to user program didn't work - chMtxUnlock(&reboot_mutex); - chThdSleep(TIME_INFINITE); + // allow bootloader to work again, since jumping to user program didn't work + chMtxUnlock(&reboot_mutex); + // Wait a bit + chThdSleep(TIME_MS2I(100)); + } }