How to reset the entire system? esp_restart() doesn't work sometimes

yuwenpeng
Posts: 30
Joined: Tue Apr 12, 2022 6:25 am

How to reset the entire system? esp_restart() doesn't work sometimes

Postby yuwenpeng » Sun Jul 31, 2022 11:06 pm

Hi Everyone,
In my project, I'm using ESP32-S3, IDF, and have 2 level-5 GPIO interrupts, 1 level-5 timer interrupt, as well as some uart, SPI, USB peripherals. It will have to restart after some parameter changes. Function esp_restart() is called to restart, but sometimes the program will be then stuck at the interrupt registeration (code is shown below). In this case, either power off/on or flashing the same code then 'Hard resetting via RTS pin...' can resolve the problem.
It seems esp_restart() doesn't reset everything, or else it shouldn't be stuck at the interrupt registeration after calling esp_restart(). According to the post https://github.com/espressif/esp-idf/issues/3658, there are CPU reset, Core reset and System reset, and esp_restart() may not reset the rtc.
My question is:
Is there any function other than esp_restart() that reset the entire system?
What did esptool.py do to 'Hard resetting via RTS pin' after flashing the program? Can I do the same 'hard resetting' in the program by either calling some function or operating some 'RTS pin' ?

The following code is where it got stuck after esp_restart(). It can be stuck at the later one of line 2 and line 3, no matter what's the order of them.

Code: Select all

    xt_ints_on(1 << 16);
    xt_ints_on(1 << 31);					//Line 2
    intr_matrix_set(0, ETS_GPIO_INTR_SOURCE, 31);		//Line 3.
Any information will be appreciated!!

Best,
Wayne

yuwenpeng
Posts: 30
Joined: Tue Apr 12, 2022 6:25 am

Re: How to reset the entire system? esp_restart() doesn't work sometimes

Postby yuwenpeng » Sun Jul 31, 2022 11:55 pm

In 'esptool.py' there is a function hard_reset(...), attached below. With this hard_reset everything works well. Can I do the same hard reset internally on ESP32, or it has to be done externally?

Code: Select all

    def hard_reset(self):
        print('Hard resetting via RTS pin...')
        self._setRTS(True)  # EN->LOW
        time.sleep(0.1)
        self._setRTS(False)

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

Re: How to reset the entire system? esp_restart() doesn't work sometimes

Postby ESP_Sprite » Mon Aug 01, 2022 1:59 am

Hard reset using RTS works by physically pulling the reset pin of the ESP32 low using some circuitry external to the ESP32; there's no way you can do that from 'inside' the ESP32. Any chance you can attach a JTAG debugger to see where the interrupt stuff hangs?

yuwenpeng
Posts: 30
Joined: Tue Apr 12, 2022 6:25 am

Re: How to reset the entire system? esp_restart() doesn't work sometimes

Postby yuwenpeng » Mon Aug 01, 2022 3:48 am

I see... Thank you Sprite!
I don't have any debugger for now, but I'll try it in the near future.

chegewara
Posts: 2362
Joined: Wed Jun 14, 2017 9:00 pm

Re: How to reset the entire system? esp_restart() doesn't work sometimes

Postby chegewara » Mon Aug 01, 2022 6:07 am

Recently i got some weird situation. I OTA updated esp32 with LEDC pins changed in new version and guess what, LEDC are not reassigned after esp_reset().
Then i found that wakeup from deep sleep solved my "issue", so my suggestion is to try deep sleep with minimum timeout instead of esp_reset().

Who is online

Users browsing this forum: No registered users and 132 guests