From 46133dac0812f93996da04d4cebc928e039720c2 Mon Sep 17 00:00:00 2001 From: IhorNehrutsa Date: Sat, 11 Sep 2021 00:58:06 +0300 Subject: [PATCH 1/4] docs\esp32\quickref.rst: add comment 'timeout in milliseconds'. --- docs/esp32/quickref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst index f74926c374602..cd5d36262c3b6 100644 --- a/docs/esp32/quickref.rst +++ b/docs/esp32/quickref.rst @@ -577,7 +577,7 @@ See :ref:`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: From 8a7d6fcd37d5637f455656255b81097bbc9ecc2f Mon Sep 17 00:00:00 2001 From: IhorNehrutsa Date: Sat, 11 Sep 2021 01:20:48 +0300 Subject: [PATCH 2/4] docs\machine.WDT.rst: More comprehansive WDT example usage. --- docs/library/machine.WDT.rst | 4 ++-- lib/asf4 | 2 +- lib/axtls | 2 +- lib/btstack | 2 +- lib/lwip | 2 +- lib/mynewt-nimble | 2 +- lib/nxp_driver | 2 +- lib/pico-sdk | 2 +- lib/stm32lib | 2 +- lib/tinyusb | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/library/machine.WDT.rst b/docs/library/machine.WDT.rst index 95893cec36be7..d19cbe19b54ca 100644 --- a/docs/library/machine.WDT.rst +++ b/docs/library/machine.WDT.rst @@ -5,8 +5,8 @@ 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:: diff --git a/lib/asf4 b/lib/asf4 index 84f56af13292d..d270f79aa16dd 160000 --- a/lib/asf4 +++ b/lib/asf4 @@ -1 +1 @@ -Subproject commit 84f56af13292d8f32c40acbd949bde698ddd4507 +Subproject commit d270f79aa16dd8fd4ae3b6c14544283dcb992e9c diff --git a/lib/axtls b/lib/axtls index 531cab9c278c9..43a6e6bd3bbc0 160000 --- a/lib/axtls +++ b/lib/axtls @@ -1 +1 @@ -Subproject commit 531cab9c278c947d268bd4c94ecab9153a961b43 +Subproject commit 43a6e6bd3bbc03dc501e16b89fba0ef042ed3ea0 diff --git a/lib/btstack b/lib/btstack index 1635e36d06821..c8b9823f68c6a 160000 --- a/lib/btstack +++ b/lib/btstack @@ -1 +1 @@ -Subproject commit 1635e36d06821af8b61302509e91bfcc1ade84c4 +Subproject commit c8b9823f68c6af0fa52e2c4e009aba4dbf257232 diff --git a/lib/lwip b/lib/lwip index 6ca936f6b588c..159e31b689577 160000 --- a/lib/lwip +++ b/lib/lwip @@ -1 +1 @@ -Subproject commit 6ca936f6b588cee702c638eee75c2436e6cf75de +Subproject commit 159e31b689577dbf69cf0683bbaffbd71fa5ee10 diff --git a/lib/mynewt-nimble b/lib/mynewt-nimble index 42849560ba790..97ce3eacaaa79 160000 --- a/lib/mynewt-nimble +++ b/lib/mynewt-nimble @@ -1 +1 @@ -Subproject commit 42849560ba7906f023f61e5f7ff3709ba2c1dfca +Subproject commit 97ce3eacaaa79e8ed6cf71717149ced4f5328ee7 diff --git a/lib/nxp_driver b/lib/nxp_driver index fa5a554c7944d..b618cb1d521cc 160000 --- a/lib/nxp_driver +++ b/lib/nxp_driver @@ -1 +1 @@ -Subproject commit fa5a554c7944d2a196626f8d3631e44943f9abcc +Subproject commit b618cb1d521cc9e133bdcd0fca154dee2d925dfe diff --git a/lib/pico-sdk b/lib/pico-sdk index f396d05f8252d..bfcbefafc5d2a 160000 --- a/lib/pico-sdk +++ b/lib/pico-sdk @@ -1 +1 @@ -Subproject commit f396d05f8252d4670d4ea05c8b7ac938ef0cd381 +Subproject commit bfcbefafc5d2a210551a4d9d80b4303d4ae0adf7 diff --git a/lib/stm32lib b/lib/stm32lib index a9f8fee7bb0cb..302c52794d2f5 160000 --- a/lib/stm32lib +++ b/lib/stm32lib @@ -1 +1 @@ -Subproject commit a9f8fee7bb0cb4ac1b4ff719b6b5b285f613f352 +Subproject commit 302c52794d2f579903f4e49cbad1f5d3a7f401ad diff --git a/lib/tinyusb b/lib/tinyusb index 868f2bcda092b..6d3fb7eb98b6c 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 868f2bcda092b0b8d5f7ac55ffaef2c81316d35e +Subproject commit 6d3fb7eb98b6c0960be152b66b653a3062c7db5e From 686908cd2ec4192de605e4ab72fc027d88331744 Mon Sep 17 00:00:00 2001 From: IhorNehrutsa Date: Sun, 19 Sep 2021 02:49:35 +0300 Subject: [PATCH 3/4] docs: Move ESP32 specific WDT to esp32/quickref --- docs/esp32/quickref.rst | 2 +- docs/library/machine.WDT.rst | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst index cd5d36262c3b6..5fb5b3c6a52a6 100644 --- a/docs/esp32/quickref.rst +++ b/docs/esp32/quickref.rst @@ -150,7 +150,7 @@ These are working configurations for LAN interfaces of popular boards:: # or with dynamic ref_clk pin configuration - 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, ref_clk=machine.Pin(17), ref_clk_mode=machine.Pin.OUT) diff --git a/docs/library/machine.WDT.rst b/docs/library/machine.WDT.rst index d19cbe19b54ca..1169febbe86aa 100644 --- a/docs/library/machine.WDT.rst +++ b/docs/library/machine.WDT.rst @@ -5,15 +5,16 @@ 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 -in any way. After enabling, the application must "feed" the +up into a non recoverable state. Once started it cannot be stopped or +reconfigured 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 Availability of this class: pyboard, WiPy, esp8266, esp32, rp2040, mimxrt. From acb263d2d8e3f84f0686baa4939f776025252cd0 Mon Sep 17 00:00:00 2001 From: IhorNehrutsa Date: Thu, 2 Mar 2023 01:35:15 +0200 Subject: [PATCH 4/4] WIP --- docs/esp32/tutorial/wdt.rst | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docs/esp32/tutorial/wdt.rst diff --git a/docs/esp32/tutorial/wdt.rst b/docs/esp32/tutorial/wdt.rst new file mode 100644 index 0000000000000..25a70cb7144ff --- /dev/null +++ b/docs/esp32/tutorial/wdt.rst @@ -0,0 +1,39 @@ +.. _esp32_wdt: + +When the WDT timeout is short, there is a software update issue: +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.') +