RIOT icon indicating copy to clipboard operation
RIOT copied to clipboard

sys/auto_init: control the wdt thread

Open mariemC opened this issue 1 year ago • 5 comments

Contribution description

This enables the user to stop the watchdog thread at any time, the use case I had is that due to a power glitch the board hangs before reaching main, so the idea was to add the module auto_init_wdt_thread to enable early resets in case the board hangs (workaround ^^) But I don't want the thread to continue working becasue it can interfere with the behavior of the software and can lead to unwanted resets, therefore I wanted to add a "wdt_stop_thread" to stop the watchdog thread once main is reached.

Testing procedure

For testing, I have used the gnrc_networking example and I added the module auto init wdt:

USEMODULE += auto_init_wdt_thread
CFLAGS += -DCONFIG_PERIPH_WDT_WIN_MAX_MS=16384 /* feel free to change this  or not add it ;) */

and in main I added: wdt_thread_stop();

output, no wdt thread:

ps
2024-11-21 15:52:10,060 # ps
2024-11-21 15:52:10,063 # 	pid | name                 | state    Q | pri | stack  ( used) ( free) | base addr  | current     
2024-11-21 15:52:10,076 # 	  - | isr_stack            | -        - |   - |    512 (  240) (  272) | 0x20000000 | 0x200001c8
2024-11-21 15:52:10,083 # 	  1 | main                 | running  Q |   7 |   1536 (  700) (  836) | 0x20000b58 | 0x20000fac 
2024-11-21 15:52:10,093 # 	  3 | pktdump              | bl rx    _ |   6 |   1472 (  176) ( 1296) | 0x20005324 | 0x20005834 
2024-11-21 15:52:10,097 # 	  4 | 6lo                  | bl rx    _ |   3 |    960 (  356) (  604) | 0x20006348 | 0x200065bc 
2024-11-21 15:52:10,109 # 	  5 | ipv6                 | bl rx    _ |   4 |    960 (  400) (  560) | 0x200012b4 | 0x20001524 
2024-11-21 15:52:10,116 # 	  6 | udp                  | bl rx    _ |   5 |    448 (  192) (  256) | 0x2000674c | 0x2000684c 
2024-11-21 15:52:10,125 # 	  7 | at86rf215 [sub GHz]  | bl anyfl _ |   2 |    896 (  376) (  520) | 0x20001ad0 | 0x20001d8c 
2024-11-21 15:52:10,126 # 	  8 | at86rf215 [2.4 GHz]  | bl anyfl _ |   2 |    896 (  376) (  520) | 0x20001e50 | 0x2000210c 
2024-11-21 15:52:10,140 # 	  9 | atwinc15x0           | bl anyfl _ |   2 |    896 (  700) (  196) | 0x200028ec | 0x20002bac 
2024-11-21 15:52:10,156 # 	 10 | slipdev              | bl anyfl _ |   2 |    896 (  264) (  632) | 0x20002e68 | 0x2000312c 
2024-11-21 15:52:10,157 # 	    | SUM                  |            |     |   9472 ( 3780) ( 5692)

mariemC avatar Nov 21 '24 15:11 mariemC

But for your application: do you even need the thread? When you set the WDT interval so high and disable it right away in main(), you could also just

USEMODULE += periph_wdt_auto_start

and call wdt_stop() in main()

benpicco avatar Nov 21 '24 15:11 benpicco

But for your application: do you even need the thread? When you set the WDT interval so high and disable it right away in main(), The max window in the application will be the default 1024ms!

mariemC avatar Nov 21 '24 15:11 mariemC

Hm but still high...

mariemC avatar Nov 21 '24 15:11 mariemC

No need for this then, I drop it

mariemC avatar Nov 21 '24 16:11 mariemC

No need for this then, I drop it

So, this PR is no longer needed and should be closed?

maribu avatar Dec 13 '24 08:12 maribu