RP watchdog bug Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
szilveszter
Posts: 12
Joined: Mon Jun 14, 2021 5:42 pm
Has thanked: 9 times
Been thanked: 5 times

RP watchdog bug

Post 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
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: RP watchdog bug

Post 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
szilveszter
Posts: 12
Joined: Mon Jun 14, 2021 5:42 pm
Has thanked: 9 times
Been thanked: 5 times

Re: RP watchdog bug

Post by szilveszter »

Hi,
I am not that familiar with SVN. How and from where could I pull the code ?

Szilveszter
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: RP watchdog bug

Post 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
Attachments
RP_WDG.zip
(2.9 KiB) Downloaded 604 times
szilveszter
Posts: 12
Joined: Mon Jun 14, 2021 5:42 pm
Has thanked: 9 times
Been thanked: 5 times

Re: RP watchdog bug

Post 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.
szilveszter
Posts: 12
Joined: Mon Jun 14, 2021 5:42 pm
Has thanked: 9 times
Been thanked: 5 times

Re: RP watchdog bug

Post 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.
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: RP watchdog bug

Post 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
Attachments
RP_WDG.zip
(3.01 KiB) Downloaded 652 times
szilveszter
Posts: 12
Joined: Mon Jun 14, 2021 5:42 pm
Has thanked: 9 times
Been thanked: 5 times

Re: RP watchdog bug

Post by szilveszter »

It works now as expected. Thank you for the fix.

Szilveszter
User avatar
FXCoder
Posts: 403
Joined: Sun Jun 12, 2016 4:10 am
Has thanked: 188 times
Been thanked: 134 times

Re: RP watchdog bug

Post by FXCoder »

Trunk now updated.
This report can be closed.
Post Reply