diff --git a/platforms/nuttx/src/canbootloader/CMakeLists.txt b/platforms/nuttx/src/canbootloader/CMakeLists.txt index 38b386c107..5703458716 100644 --- a/platforms/nuttx/src/canbootloader/CMakeLists.txt +++ b/platforms/nuttx/src/canbootloader/CMakeLists.txt @@ -48,4 +48,5 @@ target_compile_options(canbootloader PRIVATE -Wno-error) target_link_libraries(canbootloader PRIVATE drivers_bootloaders + arch_watchdog_iwdg ) diff --git a/platforms/nuttx/src/canbootloader/uavcan/main.c b/platforms/nuttx/src/canbootloader/uavcan/main.c index 01ef8ceb92..a327c405a1 100644 --- a/platforms/nuttx/src/canbootloader/uavcan/main.c +++ b/platforms/nuttx/src/canbootloader/uavcan/main.c @@ -57,6 +57,7 @@ #include "random.h" #include +#include #include //#define DEBUG_APPLICATION_INPLACE 1 /* Never leave defined */ @@ -108,7 +109,7 @@ bootloader_t bootloader; const uint8_t debug_log_source[uavcan_byte_count(LogMessage, source)] = {'B', 'o', 'o', 't'}; /**************************************************************************** - * Name: start_the_watch_dog + * Name: early_start_the_watch_dog * * Description: * This function will start the hardware watchdog. Once stated the code must @@ -122,11 +123,32 @@ const uint8_t debug_log_source[uavcan_byte_count(LogMessage, source)] = {'B', 'o * ****************************************************************************/ -static inline void start_the_watch_dog(void) +static inline void early_start_the_watch_dog(void) { #ifdef OPT_ENABLE_WD #endif } + +/**************************************************************************** + * Name: app_start_the_watch_dog + * + * Description: + * This function will start the hardware watchdog. Once stated the code must + * kick it before it time out a reboot will occur. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +static inline void app_start_the_watch_dog(void) +{ + watchdog_init(); + watchdog_pet(); +} /**************************************************************************** * Name: kick_the_watch_dog * @@ -943,6 +965,7 @@ static void application_run(size_t fw_image_size, bootloader_app_shared_t *commo putreg32(APPLICATION_LOAD_ADDRESS, NVIC_VECTAB); __asm volatile("dsb"); /* extract the stack and entrypoint from the app vector table and go */ + app_start_the_watch_dog(); do_jump(fw_image[0], fw_image[1]); } } @@ -1014,7 +1037,7 @@ __EXPORT int main(int argc, char *argv[]) flash_error_t status; bootloader_app_shared_t common; - start_the_watch_dog(); + early_start_the_watch_dog(); /* Begin with all data zeroed */ memset((void *)&bootloader, 0, sizeof(bootloader));