Hello everyone,
Three years ago we were unsure of the correct way of using sl_Stop in our hibernate cycle routine (see related post from 2015). We ended up calling sl_Stop(0) before actually issuing the hibernate cycle in order to shut down the NWP before rebooting. This seemed to work flawlessly until today. The most recent hibernate routine is as follows:
void app_utils_hibernate_cycle (bool slstop, bool signal_fatal_error) { if (signal_fatal_error) { // Signal fatal error LED_set_sys_flag(LED_sys_flags_fatal_error, true); vTaskDelay(2000 / portTICK_PERIOD_MS); LED_set_sys_flag(LED_sys_flags_off, true); } taskDISABLE_INTERRUPTS(); if (slstop) { sl_Stop(0); // Stop network processing } Utils_TriggerHibCycle(); // REBOOT ! taskENABLE_INTERRUPTS(); // Should never reach this line }
Note that we always set slstop parameter to true if sl_Start has been called previously.
We recently added the call to taskDISABLE_INTERRUPTS in order to prevent IRQs from hitting after a hibernate cycle is issued, as this also seemed to hangthe system for some reason. At first it seemed to solve the problem, but lately we've been experiencing a lot of system hangs right after we call app_utils_hibernate_cycle.
What is very strange is that the watchdog does not reset when this happens.
After a little debugging we realized that the problem might be the call to sl_Stop(0). We even tried the following:
void app_utils_hibernate_cycle (bool slstop, bool signal_fatal_error) { if (signal_fatal_error) { // Signal fatal error LED_set_sys_flag(LED_sys_flags_fatal_error, true); vTaskDelay(2000 / portTICK_PERIOD_MS); LED_set_sys_flag(LED_sys_flags_off, true); } taskDISABLE_INTERRUPTS(); if (slstop) { sl_Stop(0); // Stop network processing } while(1) { UARTCharPut(UARTA0_BASE,'\n'); UtilsDelay(80000); } Utils_TriggerHibCycle(); // REBOOT ! taskENABLE_INTERRUPTS(); // Should never reach this line }
A few newlines are printed and then the system hangs for indefinite time.
We suspect that if Utils_TriggerHibCycle is reached directly after calling sl_Stop(0) the hibernate cycle works fine, but it there anything delays it (an interrupt or anything else) we reach this condition where the system hangs and the WDT cannot recover it.
We are inclined to remove the call so sl_Stop altogether, since apparently the hibernate cycle puts the NWP in a reset state. Do we really need to shut down the NWP before hibernating?