当前位置:   article > 正文

ESP32中断看门狗,esp32无法重启,interrupt watchdog,Task Watchdog Timer(中断看门狗,任务看门狗的使用)_esp32 rtc_wdt_stg_sel_off

esp32 rtc_wdt_stg_sel_off

因为原本是在github提的issues,中文机翻的英文,问题已解决,就懒得翻译回来了。

有的时候esp32看门狗生效后,设备不能重启,卡死在启动引导程序部分。这是个大问题,很难用于生产线使用。

遇到的问题:Sometimes after the watchdog takes effect, esp32 cannot start the program(Unable to restart) · Issue #5665 · espressif/arduino-esp32 · GitHubhttps://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:

  1. E (1690215) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
  2. E (1690215) task_wdt: - loopTask (CPU 1)
  3. E (1690215) task_wdt: Tasks currently running:
  4. E (1690215) task_wdt: CPU 0: IDLE0
  5. E (1690215) task_wdt: CPU 1: loopTask
  6. E (1690215) task_wdt: Aborting.
  7. abort() was called at PC 0x40158874 on core 0
  8. ELF file SHA256: 0000000000000000
  9. Backtrace: 0x40088944:0x3ffbfa20 0x40088bc1:0x3ffbfa40 0x40158874:0x3ffbfa60 0x40087279:0x3ffbfa80 0x4016c563:0x3ffbc100 0x4015a123:0x3ffbc120 0x4008b381:0x3ffbc140 0x40089bd2:0x3ffbc160
  10. Rebooting...
  11. ets Jun 8 2016 00:22:57
  12. rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  13. configsip: 0, SPIWP:0xee
  14. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  15. mode:DIO, clock div:1
  16. load:0x3fff0018,len:4
  17. load:0x3fff001c,len:1044
  18. load:0x40078000,len:10124
  19. load:0x40080400,len:5856
  20. entry 0x400806a8
  21. //houyawei
  22. #Now enter the program

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

  1. E (410181) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
  2. E (410181) task_wdt: - loopTask (CPU 1)
  3. E (410181) task_wdt: - Task1 (CPU 0)
  4. E (410181) task_wdt: Tasks currently running:
  5. E (410181) task_wdt: CPU 0: IDLE0
  6. E (410181) task_wdt: CPU 1: loopTask
  7. E (410181) task_wdt: Aborting.
  8. abort() was called at PC 0x40158874 on core 0
  9. ELF file SHA256: 0000000000000000
  10. Backtrace: 0x40088944:0x3ffbfa20 0x40088bc1:0x3ffbfa40 0x40158874:0x3ffbfa60 0x40087279:0x3ffbfa80 0x4016c563:0x3ffbc100 0x4015a123:0x3ffbc120 0x4008b381:0x3ffbc140 0x40089bd2:0x3ffbc160
  11. Rebooting...
  12. ets Jun 8 2016 00:22:57
  13. rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  14. configsip: 0, SPIWP:0xee
  15. clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
  16. mode:DIO, clock div:1
  17. load:0x3fff0018,len:4
  18. load:0x3fff001c,len:1044
  19. load:0x40078000,len:10124
  20. load:0x40080400,len:5856
  21. entry 0x400806a8
  22. //houyawei
  23. #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。

  1. RTC_WDT_STAGE_ACTION_OFF = RTC_WDT_STG_SEL_OFF,
  2. /*!< 禁用。 此阶段不会对系统产生任何影响。 */
  3. RTC_WDT_STAGE_ACTION_INTERRUPT = RTC_WDT_STG_SEL_INT,
  4. /*!< 触发中断。 当阶段到期时,会触发中断。 */
  5. RTC_WDT_STAGE_ACTION_RESET_CPU = RTC_WDT_STG_SEL_RESET_CPU,
  6. /*!< 重置 CPU 内核。 */
  7. RTC_WDT_STAGE_ACTION_RESET_SYSTEM = RTC_WDT_STG_SEL_RESET_SYSTEM,
  8. /*!< 复位主系统包括CPU和所有外设。 RTC 是一个例外,它不会被重置。 */
  9. RTC_WDT_STAGE_ACTION_RESET_RTC = RTC_WDT_STG_SEL_RESET_RTC
  10. /*!< 复位主系统和RTC。 */
  11. // houyawei

测试使用的四种狗,前三种都是任务狗,无法彻底复位,不能解决问题,第四种是中断狗用法:

  1. /first/
  2. // esp_task_wdt_init(WDT_TIMEOUT, true); //enable panic so ESP32 restarts
  3. // esp_task_wdt_add(NULL); //add current thread to WDT watch
  4. // esp_task_wdt_reset();
  5. /second/
  6. //enableCore0WDT();
  7. //enableCore1WDT();
  8. //enableLoopWDT();
  9. /third/
  10. //https://github.com/adafruit/Adafruit_SleepyDog
  11. //Watchdog.enable(4000);milliseconds
  12. // Watchdog.reset();
  13. //houaywei
  14. /fourth/
  15. //#include "soc/rtc_wdt.h"
  16. // rtc_wdt_protect_off();
  17. // rtc_wdt_set_length_of_reset_signal(RTC_WDT_SYS_RESET_SIG, RTC_WDT_LENGTH_3_2us);
  18. // rtc_wdt_set_stage(RTC_WDT_STAGE0, RTC_WDT_STAGE_ACTION_RESET_RTC);
  19. // rtc_wdt_set_time(RTC_WDT_STAGE0, 2000);
  20. // 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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/196187
推荐阅读
相关标签
  

闽ICP备14008679号