天天看點

ESP32中斷看門狗,esp32無法重新開機,interrupt watchdog,Task Watchdog Timer(中斷看門狗,任務看門狗的使用)

因為原本是在github提的issues,中文機翻的英文,問題已解決,就懶得翻譯回來了。

有的時候esp32看門狗生效後,裝置不能重新開機,卡死在啟動引導程式部分。這是個大問題,很難用于生産線使用。

遇到的問題:Sometimes after the watchdog takes effect, esp32 cannot start the program(Unable to restart) · Issue #5665 · espressif/arduino-esp32 · GitHub

ESP32中斷看門狗,esp32無法重新開機,interrupt watchdog,Task Watchdog Timer(中斷看門狗,任務看門狗的使用)

https://github.com/espressif/arduino-esp32/issues/5665

Sometimes after the watchdog takes effect, esp32 cannot start the program(Unable to restart)

DOIT esp32 DEVKIT V1

deepin/windows 10

arduino-esp32_1.0.6

Library used:https://github.com/adafruit/Adafruit_SleepyDog

When the conditions are met, the program feeds the dog regularly, otherwise it does not feed the dog.

But sometimes after the watchdog restarts the device, the program cannot be loaded.

The logs printed during normal loading and abnormal loading are the same.

After the watchdog restarts the program:

E (1690215) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (1690215) task_wdt: - loopTask (CPU 1)
E (1690215) task_wdt: Tasks currently running:
E (1690215) task_wdt: CPU 0: IDLE0
E (1690215) task_wdt: CPU 1: loopTask
E (1690215) task_wdt: Aborting.
abort() was called at PC 0x40158874 on core 0

ELF file SHA256: 0000000000000000

Backtrace: 0x40088944:0x3ffbfa20 0x40088bc1:0x3ffbfa40 0x40158874:0x3ffbfa60 0x40087279:0x3ffbfa80 0x4016c563:0x3ffbc100 0x4015a123:0x3ffbc120 0x4008b381:0x3ffbc140 0x40089bd2:0x3ffbc160

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
//houyawei
#Now enter the program
           

Sometimes the program cannot be loaded,The same log is printed。

E (410181) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (410181) task_wdt: - loopTask (CPU 1)
E (410181) task_wdt: - Task1 (CPU 0)
E (410181) task_wdt: Tasks currently running:
E (410181) task_wdt: CPU 0: IDLE0
E (410181) task_wdt: CPU 1: loopTask
E (410181) task_wdt: Aborting.
abort() was called at PC 0x40158874 on core 0

ELF file SHA256: 0000000000000000

Backtrace: 0x40088944:0x3ffbfa20 0x40088bc1:0x3ffbfa40 0x40158874:0x3ffbfa60 0x40087279:0x3ffbfa80 0x4016c563:0x3ffbc100 0x4015a123:0x3ffbc120 0x4008b381:0x3ffbc140 0x40089bd2:0x3ffbc160

Rebooting...
ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5856
entry 0x400806a8
//houyawei
#The device freezes here and will not output anything unless it is powered on again
           

測試發現,當有wifi,而wifi沒有網絡時極易出現此問題:

After testing, turn off the power of the router directly, and turn on the power of the router the next day. All esp32 are connected to the network normally.

Keep the router's wifi turned on and unplug the router's lan port network cable. Many esp32 will freeze and cannot be restored unless they are powered on again.

解決辦法是不要用任務狗,使用中斷狗 RTC watchdog,并重置esp32系統以及RTC。

RTC_WDT_STAGE_ACTION_OFF = RTC_WDT_STG_SEL_OFF, 
/*!< 禁用。 此階段不會對系統産生任何影響。 */
     RTC_WDT_STAGE_ACTION_INTERRUPT = RTC_WDT_STG_SEL_INT, 
/*!< 觸發中斷。 當階段到期時,會觸發中斷。 */
     RTC_WDT_STAGE_ACTION_RESET_CPU = RTC_WDT_STG_SEL_RESET_CPU, 
/*!< 重置 CPU 核心。 */
     RTC_WDT_STAGE_ACTION_RESET_SYSTEM = RTC_WDT_STG_SEL_RESET_SYSTEM, 
/*!< 複位主系統包括CPU和所有外設。 RTC 是一個例外,它不會被重置。 */
     RTC_WDT_STAGE_ACTION_RESET_RTC = RTC_WDT_STG_SEL_RESET_RTC 
/*!< 複位主系統和RTC。 */
//   houyawei
           

測試使用的四種狗,前三種都是任務狗,無法徹底複位,不能解決問題,第四種是中斷狗用法:

/first/
// esp_task_wdt_init(WDT_TIMEOUT, true); //enable panic so ESP32 restarts
// esp_task_wdt_add(NULL); //add current thread to WDT watch
// esp_task_wdt_reset();

/second/
//enableCore0WDT();
//enableCore1WDT();
//enableLoopWDT();

/third/
//https://github.com/adafruit/Adafruit_SleepyDog
//Watchdog.enable(4000);milliseconds
// Watchdog.reset();
//houaywei

/fourth/
//#include "soc/rtc_wdt.h"
// rtc_wdt_set_length_of_reset_signal(RTC_WDT_SYS_RESET_SIG, RTC_WDT_LENGTH_3_2us);
// rtc_wdt_set_stage(RTC_WDT_STAGE0, RTC_WDT_STAGE_ACTION_RESET_RTC);
// rtc_wdt_set_time(RTC_WDT_STAGE0, 2000);
// rtc_wdt_feed();
           

測試用例:

https://github.com/houyawei-NO1/esp32watchdog

ESP32中斷看門狗,esp32無法重新開機,interrupt watchdog,Task Watchdog Timer(中斷看門狗,任務看門狗的使用)

https://github.com/houyawei-NO1/esp32watchdog參考:

Watchdogs - ESP32 - — ESP-IDF 程式設計指南 latest 文檔

ESP32中斷看門狗,esp32無法重新開機,interrupt watchdog,Task Watchdog Timer(中斷看門狗,任務看門狗的使用)

https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-reference/system/wdts.html網上多是介紹任務狗的文章,有關中斷狗的用法也多是翻譯官方配置文檔,不夠全面,且任務狗無法滿足複雜的生産環境。這裡建議是使用中斷看門狗。

                                                                                                        ------houyawei  2021.09.16

繼續閱讀