Page 1 of 1

RP watchdog bug

Posted: Mon Jan 16, 2023 10:37 am
by szilveszter
Hi,

I discovered a bug (or at least a not expected behaviour) in rp2040's watchdog driver. At the driver initialization it calculates the LOAD register's value from the config's `lrl` value (delay in ms) with a certain formula coming from the PICO SDK, but at the reseting it directly applies the `lrl` value (delay in ms) and causes inconsistencies. I have a commit which fixes this, I wonder if you accept it somewhere as a PR or rather fix it yourself?
Here is the commit, it helps to understand what I am talking about: https://github.com/ChibiOS/ChibiOS/compare/master...zsigmondszilveszter:ChibiOS:pr/RP-WDG-bugfix

Re: RP watchdog bug

Posted: Mon Jan 16, 2023 2:18 pm
by FXCoder
Hi,
Thanks for the report.
Slightly different fix now applied to trunk on SF.
Please give it a test (don't have a Pico board handy at the moment).

--
Bob

Re: RP watchdog bug

Posted: Mon Jan 16, 2023 2:30 pm
by szilveszter
Hi,
I am not that familiar with SVN. How and from where could I pull the code ?

Szilveszter

Re: RP watchdog bug

Posted: Mon Jan 16, 2023 2:45 pm
by FXCoder
Here you go...
It will turn up on the GIT mirror also (whenever it syncs)

Also note there is now a patch submission site which can be found at…
https://review.chibios.org

Re: RP watchdog bug

Posted: Wed Jan 18, 2023 10:16 am
by szilveszter

Code: Select all

../ChibiOS/os/hal/ports/RP/LLD/WDGv1/hal_wdg_lld.c: In function 'set_wdg_counter':
../ChibiOS/os/hal/ports/RP/LLD/WDGv1/hal_wdg_lld.c:55:19: error: 'wdgp' undeclared (first use in this function); did you mean 'wdgStop'?
   55 |   uint32_t time = wdgp->config->rlr;
      |                   ^~~~
      |                   wdgStop


The 'wdgp' has to be passed to the function or the global 'WDGD1' should be used.

Re: RP watchdog bug

Posted: Sat Jan 21, 2023 12:06 pm
by szilveszter
The watchdog driver also needs to set something in the the PSM's (Power-on State Machine) WDSEL register, otherwise the watchdog doesn't reset anything.
Something like this:

Code: Select all

// reset everything apart from ROSC and XOS
 PSM->WDSEL = _u(0x1FFFC);


Here is my Commit for an example.

Re: RP watchdog bug

Posted: Sun Jan 22, 2023 10:41 am
by FXCoder
Thanks for working on this.
I will find my RP2040s and set up for test soon.
In the mean time here is an updated driver.

--
Bob

Re: RP watchdog bug

Posted: Mon Jan 23, 2023 1:56 pm
by szilveszter
It works now as expected. Thank you for the fix.

Szilveszter

Re: RP watchdog bug  Topic is solved

Posted: Thu Jan 26, 2023 3:52 am
by FXCoder
Trunk now updated.
This report can be closed.