Skip to content

FAQ Section Updated about Watchdog resets #2533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

pasko-zh
Copy link

Added a FAQ section about watchdogs:

  • A picture showing how they work
  • Explanation how and when to feed the watchdogs
  • A simple code showing how to disable the SW watchdog

FAQ section updated with an explanation why the wdt bites and how feed
them and how to disable the software wdt.
@codecov-io
Copy link

codecov-io commented Sep 17, 2016

Current coverage is 27.80% (diff: 100%)

Merging #2533 into master will not change coverage

@@             master      #2533   diff @@
==========================================
  Files            20         20          
  Lines          3625       3625          
  Methods         335        335          
  Messages          0          0          
  Branches        656        656          
==========================================
  Hits           1008       1008          
  Misses         2441       2441          
  Partials        176        176          

Powered by Codecov. Last update 4897e00...a54f573

Copy link
Contributor

@krzychb krzychb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pasko-zh,

Very nice!
I am happy to welcome a new contributor 😄

I propose to shorten "and the watchdog reset will stop your sketch" to "and the watchdog will reset your sketch"

Sneaking a little bit of bare metal assembler programming is great!

@pasko-zh
Copy link
Author

pasko-zh commented Sep 18, 2016

@krzychb thanks and will document more if needed 😄

That's fine with me, I am not a native english speaker/writer.

@kgero
Copy link

kgero commented Sep 21, 2016

I do not find this clear. In the example, you stop the software watchdog but continue to feed the hardware watchdog with the function named system_soft_wdt_feed(), which according to its name I would assume feeds the software watchdog. In addition, you do not explain why we need to manually feed the hardware watchdog when the software watchdog is stopped. Can you clear this up for me and anyone else in the future using this documentation?

@pasko-zh
Copy link
Author

@krzychb : Sentence shortened.
@kgero : Is it clearer now how and when these dogs 🐶 bite? See here.

@kgero
Copy link

kgero commented Sep 24, 2016

Yes, thank you!

### I'm getting these Watchdog Resets "wdt reset"�How can I avoid them?
The esp8266 is equipped with two watchdog timers: A software watchdog and a hardware watchdog. If you don't understand why microcontrollers need a watchdog (timer), you may first read [here](http://www.embedded.com/electronics-blogs/beginner-s-corner/4023849/Introduction-to-Watchdog-Timers).

When your sketch is running�either in the `setup` or during the `loop`�you have to make sure to feed the watchdog periodically. Otherwise "it will bite" and the watchdog reset will stop your sketch. The basic operation is illustrated in the following picture:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pasko-zh, I think my comment was not to the point. Sorry, and let me be more specific. I would rephrase:

Otherwise "it will bite" and the watchdog reset will stop your sketch.

to:
Otherwise "it will bite" and the watchdog will reset your sketch.
or:
Otherwise "it will bite" and the watchdog will restart your module.

I think that "stop sketch" may confuse people, while "restart" or "reset" better explains what the watchdog does if not fed.

Thank you again for contributing to FAQ 👍

Krzysztof

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey... I will change it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went for "restart" your sketch, which explains it better than stop your sketch

Watchdog will RESTART your sketch, is better/more precise than STOP your
sketch.
Copy link
Contributor

@krzychb krzychb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for update!

- `system_soft_wdt_feed()`
- `system_soft_wdt_restart()`

The name of the function `system_soft_wdt_feed()` is bit confusing: In general it will feed **both** watchdogs, i.e. the software **and** hardware watchdog. If you disable the software watchdog by calling `system_soft_wdt_stop()` and then call `system_soft_wdt_feed()` afterwards, it will still feed both watchdogs. However, since you have just disabled the software watchdog before, it will have no effect on the software watchdog (timer) and will only affect the hardware watchdog (timer). Thus, from an "End-User's" perspective, this looks like `system_soft_wdt_feed()` feeds the hardware watchdog only.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I think is in part a bug, in part bad design. Maybe we should rather document how to feed the hardware watchdog via a register?

system_soft_wdt_feed(); // Feed Hardware Watchdog
for (j = 1; j < 20; j++) {
a = micros();
busy_1second();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be replaced with a more intuitive delayMicroseconds(1000000);?

From the perspective of your Arduino sketch, the basic feeding is implicit: Everytime an iteration of your main loop starts again, i.e. it hits the `loop` statement both watchdogs are fed; cf. (1) in the figure above. Esp8266 Arduino libraries, especially core libraries like for instance the `ESP8266WiFi` library take care of feeding the watchdogs, too. Thus, normally you don't have to feed them explicitly.

**When and why should I feed the watchdog(s) explicitly?**
The software watchdog bites exactly every 3.2 seconds, the hardware watchdog every 7�8 seconds. If your sketch contains code which could exceed running for 3.2 seconds you must feed the watchdogs. I.e. you have to feed them explicitly by calling (cf. (1) in the figure above):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably worth noting that feeding the watchdog is not the only problem if some code runs for more that a second straight. WiFi and TCP/IP stack will not work as expected after this: station mode wifi will disconnect due to beacon timeout, and TCP stack may get flooded with packets.

@earlephilhower earlephilhower added merge-conflict PR has a merge conflict that needs manual correction waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. labels Oct 1, 2019
@earlephilhower
Copy link
Collaborator

Thanks for your PR, but the core and libraries have changed enough that this PR now has a merge conflict.

Could you merge it manually with the latest core, so we can consider it for future releases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-conflict PR has a merge conflict that needs manual correction waiting for feedback Waiting on additional info. If it's not received, the issue may be closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants