Skip to content

Commit 7c92de2

Browse files
Feat: Automatically reboot into user program after flashing
1 parent bcd7ddb commit 7c92de2

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

bootloader/.idea/workspace.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootloader/main.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,15 @@ int main(void) {
164164
#endif
165165
}
166166

167-
// prevent bootloader from bootloading
168-
chMtxLock(&reboot_mutex);
167+
while (1) {
168+
// make sure we're not currently updating the software
169+
chMtxLock(&reboot_mutex);
169170

170-
jump_to_user_program();
171+
jump_to_user_program();
171172

172-
// allow bootloader to work again, since jumping to user program didn't work
173-
chMtxUnlock(&reboot_mutex);
174-
chThdSleep(TIME_INFINITE);
173+
// allow bootloader to work again, since jumping to user program didn't work
174+
chMtxUnlock(&reboot_mutex);
175+
// Wait a bit
176+
chThdSleep(TIME_MS2I(100));
177+
}
175178
}

0 commit comments

Comments
 (0)