1
0
Fork 0

boards: Extend the watchdog to cover the bootloader too

If the bootloader fails for any reason we'd like to be able to restart
it! This is approach is a bit of a cheat... we are feeding the dog from
a periodic interrupt and there are plenty of ways to the system to fail
that leave periodic interrupts still ticking. However since we test the
user button and reboot from the ISR then this is OK... either the SysTick
stops and we reboot or the SysTick is running and the reboot switch will
still work.
wasp-os-next
Daniel Thompson 2020-01-19 11:57:21 +00:00
parent fb03ef1dda
commit 20f5764f64
2 changed files with 12 additions and 3 deletions

View File

@ -63,6 +63,10 @@ bool button_pressed(uint32_t pin)
void board_init(void)
{
// the watchdog has a long timeout and, when we are running in bootloader
// mode, will be fed by the systick handler
wdt_init();
// stop LF clock just in case we jump from application without reset
NRF_CLOCK->TASKS_LFCLKSTOP = 1UL;
@ -135,6 +139,14 @@ void SysTick_Handler(void)
led_tick();
#endif
/*
* Feed the dog... this is a backstop. The *only* reason we are running
* the watchdog is to help us recover if the bootloader crashes in some
* way that makes it impossible for us to reboot using the button test
* code below. This is OK to feed it from a periodic interrupt.
*/
nrf_wdt_reload_request_set(NRF_WDT, 0);
/*
* Detect a long press of the DFU button. When found try to launch the
* application regardless of the DFU button state.

View File

@ -273,9 +273,6 @@ int main(void)
// Jump to application if valid
if (bootloader_app_is_valid(DFU_BANK_0_REGION_START) && !bootloader_dfu_sd_in_progress())
{
// Set the watchdog running before we start the payload
wdt_init();
// MBR must be init before start application
if ( !sd_inited ) softdev_mbr_init();