Hello,
I've encountered a condition where k_sleep(K_SECONDS(1)) never returns. Here is minimal example, reproduces both on nrf9160 and nrf9161:
#include <zephyr/kernel.h>
#include <zephyr/task_wdt/task_wdt.h>
void wd_cb(int cid, void* user_data) {
printk("WATCHDOG\n");
}
int main(void) {
task_wdt_init(NULL);
printk("AAAA\n");
k_sleep(K_SECONDS(1));
int wdc = task_wdt_add(3000,
wd_cb, NULL);
// k_sleep(K_SECONDS(1));
for(;;){
printk("BBBB\n");
k_sleep(K_SECONDS(1));
}
}
Hangs up after printing AAAA. If k_sleep runs after task_wdt_add (or before task_wdt_init), it prints BBBB indefinitely as it should.
This is somewhat strange sequence (normally one would not sleep before setting up the watchdog), but on nrf9161 a similar condition may sometimes trigger if one calls nrf_modem_lib_init between task_wdt_init and task_wdt_add. I was unable to reproduce it in a minimal example, seems it's timing-dependent.