赞
踩
因为原本是在github提的issues,中文机翻的英文,问题已解决,就懒得翻译回来了。
有的时候esp32看门狗生效后,设备不能重启,卡死在启动引导程序部分。这是个大问题,很难用于生产线使用。
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_protect_off();
- // 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/esp32watchdoghttps://github.com/houyawei-NO1/esp32watchdog参考:
Watchdogs - ESP32 - — ESP-IDF 编程指南 latest 文档https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-reference/system/wdts.html网上多是介绍任务狗的文章,有关中断狗的用法也多是翻译官方配置文档,不够全面,且任务狗无法满足复杂的生产环境。这里建议是使用中断看门狗。
------houyawei 2021.09.16
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。