Page 1 of 1

How to force a CPU reset?

Posted: Fri Mar 09, 2018 4:04 pm
by vonnieda
I have an issue where sometimes the I2C stack seems to get stuck and a soft reset via esp_restart() or abort() does not clear it. A hard reset (power off, power on) does clear it and everything starts working again. I am able to detect this situation but I have not found a way via software to force a CPU reset.

The docs for esp_restart() say "Peripherals (except for WiFi, BT, UART0, SPI1, and legacy timers) are not reset." So, is there a way from software to reset the peripherals that are not reset in that call?

I thought maybe I could do it with a watchdog reset, but I don't see a clear way to do that.

Thanks,
Jason

Re: How to force a CPU reset?

Posted: Tue Mar 13, 2018 1:58 pm
by Rrobinet

Re: How to force a CPU reset?

Posted: Tue Mar 13, 2018 9:46 pm
by vonnieda
Rrobinet wrote:See reply
viewtopic.php?f=19&t=4960&p=21544#p21407
Robert
Thank you!

Re: How to force a CPU reset?

Posted: Wed Jun 13, 2018 11:12 am
by blowback
I had exactly the same issue. Tried 5 or 6 different reset strategies (the functions provided, provoking the watchdogs etc)

Eventually I found that going into deep sleep and waking up on a timer a couple of seconds later would reset i2c. Maybe not always the first time, but it would get it eventually.

Code: Select all

static bool go_to_sleep(void)
{
    esp_sleep_enable_timer_wakeup(SLEEP_TIME_US);
    esp_deep_sleep_start();
}
HTH.

Re: How to force a CPU reset?

Posted: Fri Jun 15, 2018 5:35 am
by ESP_Angus
What ESP-IDF version are you each using? (if using Arduino or something else with its own i2c libraries, please mention this.)

In recent ESP-IDF master branch, a change was added to always reset peripherals on startup:
https://github.com/espressif/esp-idf/co ... 1dd21dfde1

Re: How to force a CPU reset?

Posted: Fri Jun 15, 2018 12:52 pm
by ESP_Sprite
Can forcing a CPU reset harm the CPU in any way btw? I'm just curious.
No, not at all. It essentially just resets a bunch of flipflops to a default state, when looking at the chip level. You can theoretically have some higher-level effects, for instance when you reset the CPU in the middle of a flash write when the software cannot handle interrupted flash writes correctly, but the CPU itself doesn't mind being reset.

Re: How to force a CPU reset?

Posted: Fri Jun 22, 2018 4:01 pm
by vonnieda
ESP_Angus wrote:What ESP-IDF version are you each using? (if using Arduino or something else with its own i2c libraries, please mention this.)

In recent ESP-IDF master branch, a change was added to always reset peripherals on startup:
https://github.com/espressif/esp-idf/co ... 1dd21dfde1
Hi ESP_Angus, sorry, I missed this reply the other day. In any case, I started using

Code: Select all

periph_module_reset(PERIPH_I2C0_MODULE);
a couple months back and that fixed my issue. I don't remember where I found that. In any case, I think the new IDF does basically the same thing. I haven't checked it out fully yet.

Thanks,
Jason