Closed ehughes closed 3 years ago
Yep, this looks like a bug and an appropriate fix, thanks a lot for reporting!
I wonder why the hard fault didn't happen during my testing with the nrf52840dk_nrf52840
a while ago. For STM32, which I mainly use, feeding the watchdog before calling wdt_setup()
doesn't seem to be an issue.
I'll double-check in the next days and afterwards create a PR.
So, the hardfault is happening with the Segger Ozone Debugger attached. There may be other details of why the assert is triggering it. Either way, I found this out while scanning the Nordic Devzone while trying to get the Task WDT to work and thought I would at least post the information and the patch.
I will also be testing on the NRF91 soon as well. I'll keep an eye out of the pull request.
Definitely good to post the bug here. I was not aware of the discussion in the Nordic Devzone, otherwise the fix would have made it into 2.7 release.
I was able to reproduce the issue. See linked PR with the fix.
Describe the bug
On the NRF52840 (and likely other NRF variants), the CPU will hardfault when calling
task_wdt_add()
The underlying issue is documented here:
https://devzone.nordicsemi.com/f/nordic-q-a/75112/assertion-fail-m_cb-p_instance--drv_inst_idx-state-nrfx_drv_state_powered_0
The fix is simple. Move task_wdt_feed(id); after the wdt_setup call like this:
To Reproduce
Run the sample in samples/subsys/task_wdt with the nrf52840dk_nrf52840 board.
Expected behavior
When the call is made to task_wdt_feed, the CPU will hardfault. I believe there is an asset being triggered.
Impact
Annoying. For the time being, I will be manually patching but this should be in the main zephyr tree.
Environment (please complete the following information):