Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Fix ESP32-S2 restart #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 13 additions & 4 deletions src/AsyncElegantOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,19 @@ void AsyncElegantOtaClass::loop() {
}

void AsyncElegantOtaClass::restart() {
yield();
delay(1000);
yield();
ESP.restart();
#if defined CONFIG_IDF_TARGET_ESP32S2 || defined CONFIG_IDF_TARGET_ESP32S2
yield();
delay(1000);
yield();
esp_task_wdt_init(1,true);
esp_task_wdt_add(NULL);
while(true);
#else
yield();
delay(1000);
yield();
ESP.restart();
#endif
Comment on lines +114 to +126

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the basic example works this seems likely to be a bug elsewhere in your code/the code you rely on, rather than something that this library should deal with.

If this workaround is actually necessary, you should structure the code so it's clear what is actually different between the branches:

Suggested change
#if defined CONFIG_IDF_TARGET_ESP32S2 || defined CONFIG_IDF_TARGET_ESP32S2
yield();
delay(1000);
yield();
esp_task_wdt_init(1,true);
esp_task_wdt_add(NULL);
while(true);
#else
yield();
delay(1000);
yield();
ESP.restart();
#endif
yield();
delay(1000);
yield();
#if defined(CONFIG_IDF_TARGET_ESP32S2)
// Normal restarts don't work due to X. Abuse the watchdog timer to perform a hard reset.
esp_task_wdt_init(1, true);
esp_task_wdt_add(NULL);
while(true);
#else
ESP.restart();
#endif

}

String AsyncElegantOtaClass::getID(){
Expand Down