← index #5779PR #6782
Related · high · value 1.377
QUERY · ISSUE

machine.soft_reset() behaves curiously on esp8266

openby nazsoltiopened 2020-03-20updated 2020-03-23
port-esp8266

Hi!

This is related to https://github.com/micropython/micropython/issues/5764
Thanks a lot for implementing it by the way! 😄

If I invoke it from the REPL, everything works as expected, but if it's invoked from a running code, it will drop to REPL (and with no MPY: soft reboot message). Here's an example:

try:
    trixie.run()

 except KeyboardInterrupt:
    trixie.runner.stop()

except trixie.ResetError:
    # land here on reset
    print('SOFT RESET')
    machine.soft_reset()

except trixie.RebootError:
    # land here on reboot
    print('HARD RESET')
    machine.reset()

except Exception as exc:
    # we should never end up here
    print('EXCEPTION')
    trixie.runner.stop()

trixie.run() raises trixie.SoftReset on soft reset intent, after which 'SOFT RESET' is printed, but then it drops to REPL instead.

I saw it in another issue, that it's by design that main.py won't be called on soft-reset, so I tested the snippet above in _boot.py and boot.py also, but it produces the same behavior. Not having 'MPY: soft reset' printed is suspicious. I'm confused if this is indeed a bug, or I'm doing something wrong.

Thanks a lot for looking into this!

CANDIDATE · PULL REQUEST

esp32: make machine.soft_reset() work in main.py

closedby tveopened 2021-01-18updated 2021-02-19
port-esp32

This patch fixes two issues on the esp32: it enables machine.soft_reset() to be called in main.py and it enables machine.reset_cause() to correctly identify a soft reset. The former is useful in that it enables soft resets in applications that are started at boot time.
The support is patterned after the stm32 port.
No docs changes 'cause this makes things works as documented.
No unit test, I can create one but due to the reset it ends up being pretty messy.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied