How to force a CPU reset?

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

How to force a CPU reset?

Postby vonnieda » Fri Mar 09, 2018 4:04 pm

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

Rrobinet
Posts: 29
Joined: Wed Aug 16, 2017 7:05 am

Re: How to force a CPU reset?

Postby Rrobinet » Tue Mar 13, 2018 1:58 pm


vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: How to force a CPU reset?

Postby vonnieda » Tue Mar 13, 2018 9:46 pm

Rrobinet wrote:See reply
viewtopic.php?f=19&t=4960&p=21544#p21407
Robert
Thank you!

blowback
Posts: 2
Joined: Wed Jun 13, 2018 11:08 am

Re: How to force a CPU reset?

Postby blowback » Wed Jun 13, 2018 11:12 am

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.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: How to force a CPU reset?

Postby ESP_Angus » Fri Jun 15, 2018 5:35 am

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

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: How to force a CPU reset?

Postby ESP_Sprite » Fri Jun 15, 2018 12:52 pm

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.

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: How to force a CPU reset?

Postby vonnieda » Fri Jun 22, 2018 4:01 pm

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

Who is online

Users browsing this forum: No registered users and 130 guests