Skip to content

ESP32S2: cpu.reset_reason is wrong when resetting from button or microcontroller #4304

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
Neradoc opened this issue Mar 2, 2021 · 8 comments
Assignees
Labels
bug espressif applies to multiple Espressif chips
Milestone

Comments

@Neradoc
Copy link

Neradoc commented Mar 2, 2021

The ESP32S2 gives POWER_ON as a reset reason when pressing the reset button (I expected RESET_PIN).
microcontroller.reset() gets a WATCHDOG reset reason (expected SOFTWARE).

Tested on MagTag (latest) and ttgo (beta 2), printing out microcontroller.cpu.reset_reason.

@anecdata
Copy link
Member

anecdata commented Mar 2, 2021

Possibly related: #3858

@microdev1
Copy link
Collaborator

  • The reset button is wired to S2's chip enable pin so it literally turns off the chip. That's the reason for POWER_ON status.
  • I am getting the expected SOFTWARE as reset reason when using microcontroller.reset(). Can you try with current main.

@Neradoc
Copy link
Author

Neradoc commented Mar 2, 2021

Ah I was thinking something like that might be going on with the reset button. That's too bad.

I tried latest S3, and compiled current main on the Magtag.
Adafruit CircuitPython 6.2.0-beta.2-230-g64192b0eb on 2021-03-01; Adafruit MagTag with ESP32S2
I tried manually calling microcontroller.reset() in the REPL.
I also used this code on battery to exclude the possibility of USB messing with it.

I get WATCHDOG in both cases. (Well, except on first boot).

import board
import displayio
import microcontroller
import terminalio
import time
from adafruit_display_text import label

display = board.DISPLAY
splash = displayio.Group(max_size=10)
display.show(splash)

text = label.Label(
    terminalio.FONT,
    scale = 3,
    color = (255,255,255),
    x = display.width // 2,
    y = display.height // 2 - 10,
    max_glyphs = 50,
    anchor_point = (0.5, 0.5),
)
splash.append(text)
print(microcontroller.cpu.reset_reason)
text.text = str(microcontroller.cpu.reset_reason)[28:]
display.refresh()

for x in range(20):
    print(microcontroller.cpu.reset_reason)
    time.sleep(1)
microcontroller.reset() # <--- should result in the screen changing to SOFTWARE

@microdev1
Copy link
Collaborator

Still unable to replicate this. Tried both in REPL and code.py.

Adafruit CircuitPython 6.2.0-beta.2-230-g64192b0eb on 2021-03-02; microS2 with ESP32S2
>>> import microcontroller
>>> microcontroller.reset()
# <--- Reset --->
>>> microcontroller.cpu.reset_reason
microcontroller.ResetReason.SOFTWARE

@microdev1 microdev1 added the espressif applies to multiple Espressif chips label Mar 4, 2021
@jepler jepler added the bug label Mar 15, 2021
@jepler jepler added this to the 6.x.x - Bug Fixes milestone Mar 15, 2021
@dhalbert dhalbert modified the milestones: 6.x.x - Bug Fixes, 7.0.0 Mar 31, 2021
@Neradoc
Copy link
Author

Neradoc commented May 15, 2021

@microdev1 do you use the UF2 bootloader ? It seems to be what makes the difference.
I get the same result as you when I rease_flash and install Circuitpython from the bin.

@microdev1
Copy link
Collaborator

It seems to be what makes the difference.

Yup! I get WATCHDOG with UF2 and the expected SOFTWARE with non-UF2 build.

@microdev1
Copy link
Collaborator

I just tested this with TinyUF2 0.5.0 and this seems to be fixed.

@dhalbert
Copy link
Collaborator

This should be fixed now with the latest TinyUF2. Update your TinyUF2 bootloader to at least 0.5.0, following the instructions here: https://learn.adafruit.com/adafruit-magtag/install-uf2-bootloader. Thanks @microdev1 for testing and @hathach for the TinyUF2 fix.

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

No branches or pull requests

5 participants