Skip to content

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

Closed

Description

@Neradoc

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.

Activity

  1. anecdata commented on Mar 2, 2021

    @anecdata
    Collaborator

    Possibly related: #3858

  2. microdev1 commented on Mar 2, 2021

    @microdev1
    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.
  3. Neradoc commented on Mar 2, 2021

    @Neradoc
    Author

    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
  4. microdev1 commented on Mar 2, 2021

    @microdev1
    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
  5. added this to the 6.x.x - Bug Fixes milestone on Mar 15, 2021
  6. Neradoc commented on May 15, 2021

    @Neradoc
    Author

    @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.

  7. microdev1 commented on May 15, 2021

    @microdev1
    Collaborator

    It seems to be what makes the difference.

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

  8. microdev1 commented on Jul 19, 2021

    @microdev1
    Collaborator

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

  9. dhalbert commented on Jul 19, 2021

    @dhalbert
    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

Metadata

Metadata

Assignees

Labels

bugespressifapplies to multiple Espressif chips

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions