zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.84k stars 6.6k forks source link

Cannot install watchdog timeout on STM32WB #45112

Closed r2r0 closed 2 years ago

r2r0 commented 2 years ago

Describe the bug iwdg_stm32_install_timeout does not return because it is stuck inside while (LL_IWDG_IsReady(iwdg) == 0) loop. It looks like k_uptime_get_32 returns the same value for every call.

Please also mention any information which could help others to understand the problem you're facing:

To Reproduce Steps to reproduce the behavior: Build with IWDG enabled and with CONFIG_WDT_DISABLE_AT_BOOT configuration option set. Try to run application.

Expected behavior iwdg_stm32_install_timeout should return with -EINVAL error.

Impact showstopper

Logs and console output

Environment (please complete the following information):

Additional context During call to iwdg_stm32_install_timeout the IWDG is disabled because LL_IWDG_Enable was never called before and then LL_IWDG_IsReady will always return 0. LL_IWDG_Enable was not called before because of CONFIG_WDT_DISABLE_AT_BOOT is set. It means that present implementation may be incorrect because LL_IWDG_Enable will be called during wdt_setup which (according to documentation) will happen after call to wdt_install_timeout.

FRASTM commented 2 years ago

@r2r0 could you please check if PR https://github.com/zephyrproject-rtos/zephyr/pull/44972 helps

r2r0 commented 2 years ago

Thanks @FRASTM - in fact this PR removes the trigger of described problem. After applying #44972 CPU leaves the while loop and the timeout hangout is avoided but it is still present.

FRASTM commented 2 years ago

When you build the samples/subsys/task_wdt with CONFIG_WDT_DISABLE_AT_BOOT=n (by default in the prj.conf the CONFIG_WDT_DISABLE_AT_BOOT is 'y') the timeout is installed during the initialisation of the device, with the same sequence as in _installtimeout You get :

*** Booting Zephyr OS build zephyr-v3.0.0-3100-g6c4c7e87f76*
Task watchdog sample application.                                               
Main thread still alive...                                                      
Control thread started.                                                         
Main thread still alive...                                                      
Main thread still alive...                                                      
Main thread still alive...                                                      
Control thread getting stuck...                                                 
Task watchdog channel 1 callback, thread: control                               
Resetting device...
r2r0 commented 2 years ago

Unfortunately blocking of while loop is visible only very rarely when console and debugger (even without breakpoints installed) are connected. When it happens then it looks that also LPTIM ISR is not working. After power cycling problem disappears (usually) for long time. Because I am not able to consistently reproduce problem then I will close this issue for now. BTW> @FRASTM would it be possible to advance merging of the #44972, please.