Skip to content

ESP2S2: Resetting either programmatically or via watchdog causes device to go into SAFE_MODE #3988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dheera opened this issue Jan 13, 2021 · 8 comments · Fixed by #4925
Closed
Assignees
Labels
bug crash espressif applies to multiple Espressif chips
Milestone

Comments

@dheera
Copy link

dheera commented Jan 13, 2021

Running this:

import microcontroller
microcontroller.on_next_reset(microcontroller.RunMode.NORMAL)
microcontroller.reset()

causes the board to reset and go into safe mode instead of normal mode.

Similarly, setting up a watchdog with the following code.py:

from microcontroller import watchdog as w
from watchdog import WatchDogMode
w.timeout = 10.0
w.mode = WatchDogMode.RESET
w.feed()
while True:
    pass

causes the microcontroller to reset after 10.0 seconds (as expected), but the microcontroller resets into safe mode instead of resetting and re-running code.py, which is the usual intent of watchdog usage.

Product: FeatherS2
CircuitPython version: adafruit-circuitpython-unexpectedmaker_feathers2-en_US-6.1.0-beta.3.uf2

Related but not same issue: #3884

@hierophect hierophect added the espressif applies to multiple Espressif chips label Jan 13, 2021
@microdev1
Copy link
Collaborator

There are two different issues here :-

  1. microcontroller.on_next_reset() :- Only RunMode.SAFE_MODE is currently implemented.
  2. The watchdog reset gets caught here :-
    switch (reason) {
    case ESP_RST_BROWNOUT:
    return BROWNOUT;
    case ESP_RST_PANIC:
    case ESP_RST_INT_WDT:
    case ESP_RST_WDT:
    return HARD_CRASH;
    default:
    break;
    }

@tannewt tannewt added this to the 6.x.x - Bug Fixes milestone Jan 13, 2021
@dhalbert dhalbert changed the title Resetting either programmatically or via watchdog causes device to go into SAFE_MODE ESP2S2: Resetting either programmatically or via watchdog causes device to go into SAFE_MODE Mar 31, 2021
@dhalbert dhalbert modified the milestones: 6.x.x - Bug Fixes, 7.0.0 Mar 31, 2021
@dhalbert
Copy link
Collaborator

microcontroller.reset() works for me if I use the .bin, but not if TinyUF2 is present.

@dhalbert
Copy link
Collaborator

The reason is stored in a supposedly "reserved by ESP-IDF". Check if TinyUF2 is using the same RTC register as CircuitPython. Try a different one?

@dhalbert dhalbert self-assigned this Jul 15, 2021
@dheera
Copy link
Author

dheera commented Jul 16, 2021

I believe this was already resolved by this pull request I made that was accepted
#4011
Thanks!

@dhalbert
Copy link
Collaborator

I believe this was already resolved by this pull request I made that was accepted

Thanks! We think there may still be a problem with UF2 builds and will re-test.

@microdev1 microdev1 linked a pull request Jul 19, 2021 that will close this issue
@ThinkTransit
Copy link

Hi,

I have tested this on the nightly build from last night - Adafruit CircuitPython 7.0.0-alpha.5-175-g8da98eb1f on 2021-08-10; FeatherS2 with ESP32S2

microcontroller.reset() works as expected however resetting from the watchdog still goes to safe mode on the FeatherS2

@FlorianBaumgartner
Copy link

FlorianBaumgartner commented Oct 2, 2021

Yes, same problem as @ThinkTransit described. My setup: Adafruit ESP32-S2 Metro, UF2 (0.5.2), cpy (7.0.0).
It's impossible to boot into the UF2-Bootloader from user code. Either by using circuit python:

import microcontroller
microcontroller.on_next_reset(microcontroller.RunMode.UF2)
microcontroller.reset()

or directly in Arduino CPP:

esp_reset_reason();
esp_reset_reason_set_hint((esp_reset_reason_t) 0x11F2);
esp_restart();

It acts just as a regular reset (single button press). By reading the reset reason I always get: "RTCWDT_RTC_RESET"

@FlorianBaumgartner
Copy link

FlorianBaumgartner commented Oct 6, 2021

Problem has been solved. The UF2 Bootloader must be completely reinstalled to update all partitions.
#5426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug crash espressif applies to multiple Espressif chips
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants