ESP 32 Restart

dovoto
Posts: 27
Joined: Tue Apr 20, 2021 3:51 pm

ESP 32 Restart

Postby dovoto » Thu Apr 21, 2022 11:44 pm

We are getting some odd results restarting the ESP 32 after an OTA.


It seems like some peripherals are not reset (wifi, ble, spi, uart etc as described in the docs)

However, sometimes after an OTA erasing flash sectors appears to not work (about 50 % of the time erase returns success but reading the data shows it doesn't go to 0xFFs).

Pressing reset or powering down and back up make it function normally.

Is there a more forceful way to reset then esp_restart() that resets peripherals?

What might be related is if erase works we almost always get one rtc watch dog timer reset after the OTA completes and the new firmware has been running for 1-2 minutes then it runs fine.

Thanks

dovoto
Posts: 27
Joined: Tue Apr 20, 2021 3:51 pm

Re: ESP 32 Restart

Postby dovoto » Fri Apr 22, 2022 12:27 am

I am going to try something like the following...ill update if it works

Code: Select all

system_reset()
{
    rtc_wdt_protect_off();      
    rtc_wdt_set_stage(RTC_WDT_STAGE0, RTC_WDT_STAGE_ACTION_RESET_SYSTEM);
    rtc_wdt_set_time(RTC_WDT_STAGE0, 100);
    rtc_wdt_enable();         
    rtc_wdt_protect_on();      
}

dovoto
Posts: 27
Joined: Tue Apr 20, 2021 3:51 pm

Re: ESP 32 Restart

Postby dovoto » Fri Apr 22, 2022 10:27 pm

For those that stumble on this same issue, the above solution worked (we increased the timeout, set a global reset pending flag so other threads knew not to start doing things like write to flash (or feed the rtc), added a vtaskdelay to give other tasks time to complete, and then put the thread priority to max and stuck it in a while loop till the timer expired).

Who is online

Users browsing this forum: Gaston1980 and 92 guests