Skip to content

docs/esp32: Reinitialize watchdog timer with longer timeout. #10901

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/esp32/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ These are working configurations for LAN interfaces of popular boards::
# Olimex ESP32-GATEWAY: power controlled by Pin(5)
# Olimex ESP32 PoE and ESP32-PoE ISO: power controlled by Pin(12)

lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18), power=machine.Pin(5),
lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18), power=machine.Pin(5),
phy_type=network.PHY_LAN8720, phy_addr=0)

# or with dynamic ref_clk pin configuration

lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18), power=machine.Pin(5),
phy_type=network.PHY_LAN8720, phy_addr=0,
ref_clk=machine.Pin(17), ref_clk_mode=machine.Pin.OUT)

Expand Down Expand Up @@ -558,7 +563,7 @@ See :ref:`machine.WDT <machine.WDT>`. ::
from machine import WDT

# enable the WDT with a timeout of 5s (1s is the minimum)
wdt = WDT(timeout=5000)
wdt = WDT(timeout=5000) # timeout in milliseconds
wdt.feed()

.. _Deep_sleep_mode:
Expand Down
1 change: 1 addition & 0 deletions docs/esp32/tutorial/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ to `<https://www.python.org>`__.

intro.rst
pwm.rst
wdt.rst
peripheral_access.rst
43 changes: 43 additions & 0 deletions docs/esp32/tutorial/wdt.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

.. _esp32_wdt:

WDT
===

When the WDT timeout is short, a problem occurs when updating the software:
you don't have enough time to copy the updates to the device.
ESP32 alows reinitialise the watchdog with a longer timeout - like an hour.

More comprehansive example usage::

# Save as 'main.py' and it will run automatically after 'boot.py'

import sys
from time import sleep
from machine import WDT, reset

try:
print('Press Ctrl-C to break the program.')
sleep(5)
print('Enable the WDT with a timeout of 5s.')
wdt = WDT(timeout=5000)

seconds = 1
while True: # infinite work loop
print('Do something useful in less than 5 seconds.')
print(f'Sleep {seconds} seconds.')
if seconds >= 5:
print(f'WDT will reboot the board.')
sleep(seconds)
seconds += 1
wdt.feed()

# 1/0 # uncoment this line to raise an runtime exception, then WDT reboot

# sys.exit() # uncomment this line for planned program exit

except SystemExit:
wdt = WDT(timeout=1000 * 60 * 60) # 1 hour before WDT reboot
print('Now you have 1 hour to update program on the board.')
print('When ready, type reset() on the REPL/WebREPL command line to reboot.')

8 changes: 5 additions & 3 deletions docs/library/machine.WDT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ class WDT -- watchdog timer
===========================

The WDT is used to restart the system when the application crashes and ends
up into a non recoverable state. Once started it cannot be stopped or
reconfigured in any way. After enabling, the application must "feed" the
up into a non recoverable state. Once started it cannot be stopped
in any way. After enabling, the application must "feed" the
watchdog periodically to prevent it from expiring and resetting the system.

Example usage::

from machine import WDT
wdt = WDT(timeout=2000) # enable it with a timeout of 2s
wdt.feed()
while True:
# do something useful in less than 2 seconds
wdt.feed()

Availability of this class: pyboard, WiPy, esp8266, esp32, rp2040, mimxrt.

Expand Down
2 changes: 1 addition & 1 deletion lib/asf4
Submodule asf4 updated 877 files
2 changes: 1 addition & 1 deletion lib/btstack
Submodule btstack updated 2735 files
2 changes: 1 addition & 1 deletion lib/lwip
Submodule lwip updated 63 files
+0 −6 .gitattributes
+1 −1 doc/doxygen/lwip.Doxyfile
+0 −9 doc/doxygen/main_page.h
+1 −1 src/Filelists.cmake
+6 −6 src/api/api_lib.c
+0 −3 src/api/api_msg.c
+3 −6 src/api/netdb.c
+4 −10 src/api/sockets.c
+1 −1 src/api/tcpip.c
+69 −161 src/apps/altcp_tls/altcp_tls_mbedtls.c
+0 −16 src/apps/http/httpd.c
+25 −24 src/apps/mqtt/mqtt.c
+5 −5 src/apps/netbiosns/netbiosns.c
+4 −38 src/apps/sntp/sntp.c
+0 −36 src/core/altcp.c
+9 −43 src/core/altcp_tcp.c
+2 −3 src/core/init.c
+28 −29 src/core/ipv4/dhcp.c
+0 −8 src/core/ipv4/etharp.c
+6 −12 src/core/ipv4/icmp.c
+0 −2 src/core/ipv4/ip4_addr.c
+2 −11 src/core/ipv6/dhcp6.c
+9 −18 src/core/ipv6/icmp6.c
+0 −2 src/core/ipv6/ip6.c
+1 −1 src/core/ipv6/ip6_frag.c
+2 −2 src/core/ipv6/mld6.c
+9 −21 src/core/ipv6/nd6.c
+11 −33 src/core/netif.c
+12 −46 src/core/pbuf.c
+1 −5 src/core/tcp.c
+2 −3 src/core/tcp_in.c
+3 −4 src/core/tcp_out.c
+3 −9 src/core/udp.c
+0 −5 src/include/lwip/altcp.h
+1 −27 src/include/lwip/altcp_tls.h
+2 −40 src/include/lwip/apps/altcp_tls_mbedtls_opts.h
+3 −3 src/include/lwip/apps/sntp.h
+0 −6 src/include/lwip/apps/sntp_opts.h
+3 −1 src/include/lwip/debug.h
+0 −2 src/include/lwip/if_api.h
+1 −1 src/include/lwip/init.h
+1 −5 src/include/lwip/netif.h
+9 −16 src/include/lwip/opt.h
+0 −4 src/include/lwip/pbuf.h
+0 −13 src/include/lwip/priv/altcp_priv.h
+0 −2 src/include/lwip/prot/icmp6.h
+0 −2 src/include/lwip/prot/ip6.h
+0 −7 src/include/netif/ppp/ppp_opts.h
+4 −4 src/include/netif/ppp/pppoe.h
+1 −1 src/netif/lowpan6.c
+1 −1 src/netif/lowpan6_ble.c
+4 −4 src/netif/lowpan6_common.c
+1 −4 src/netif/ppp/ppp.c
+23 −20 src/netif/ppp/pppoe.c
+1 −1 src/netif/zepif.c
+1 −17 test/unit/arch/sys_arch.c
+0 −7 test/unit/arch/sys_arch.h
+2 −56 test/unit/core/test_netif.c
+1 −1 test/unit/dhcp/test_dhcp.c
+1 −39 test/unit/ip6/test_ip6.c
+0 −10 test/unit/lwip_check.h
+0 −1 test/unit/lwipopts.h
+1 −126 test/unit/udp/test_udp.c
2 changes: 1 addition & 1 deletion lib/mbedtls
2 changes: 1 addition & 1 deletion lib/mynewt-nimble
Submodule mynewt-nimble updated 342 files
2 changes: 1 addition & 1 deletion lib/nxp_driver
Submodule nxp_driver updated 2261 files
2 changes: 1 addition & 1 deletion lib/pico-sdk
Submodule pico-sdk updated 415 files
2 changes: 1 addition & 1 deletion lib/stm32lib
Submodule stm32lib updated 1795 files
2 changes: 1 addition & 1 deletion lib/tinyusb
Submodule tinyusb updated 550 files