RP watchdog bug Topic is solved

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

RP watchdog bug

Postby szilveszter » Mon Jan 16, 2023 10:37 am

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: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: RP watchdog bug

Postby FXCoder » Mon Jan 16, 2023 2:18 pm

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
Contact:

Re: RP watchdog bug

Postby szilveszter » Mon Jan 16, 2023 2:30 pm

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

Szilveszter

User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: RP watchdog bug

Postby FXCoder » Mon Jan 16, 2023 2:45 pm

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 108 times

szilveszter
Posts: 12
Joined: Mon Jun 14, 2021 5:42 pm
Has thanked: 9 times
Been thanked: 5 times
Contact:

Re: RP watchdog bug

Postby szilveszter » Wed Jan 18, 2023 10:16 am

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
Contact:

Re: RP watchdog bug

Postby szilveszter » Sat Jan 21, 2023 12:06 pm

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: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: RP watchdog bug

Postby FXCoder » Sun Jan 22, 2023 10:41 am

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 108 times

szilveszter
Posts: 12
Joined: Mon Jun 14, 2021 5:42 pm
Has thanked: 9 times
Been thanked: 5 times
Contact:

Re: RP watchdog bug

Postby szilveszter » Mon Jan 23, 2023 1:56 pm

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

Szilveszter

User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: RP watchdog bug  Topic is solved

Postby FXCoder » Thu Jan 26, 2023 3:52 am

Trunk now updated.
This report can be closed.


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 11 guests