[SOLVED] A machine.reset() different than pushing reset
I want to issue in my code machine.reset() and have code on next boot execute differently than if the user pressed the reset button. I see in the documentation that issuing a machine.reset() will reset the device in a manner similar to pushing the external RESET button.
Do I need to set a flag in the filesystem or how can I programmatically determine this?
daniel said in New firmware release 1.6.12.b1:
Fix bug caused by machine.reset(). Used a quick WDT reset instead which actually performs a full reset of the chip.
Maybe - but i think better will be to distinguished this
PS. We have also another reset condition
@robert-hh Perhaps machine.reset() works by tripping the watchdog?
@BetterAuto OK. I was testing with 1.6.12. With 1.6.13, at least there is a difference between hard reset, reset by machine.reset() and reset by Ctrl-D. I do not know whether WDT_RESET is unexpected. It is also a kind of software reset, but it might be nice to tell the difference.
I tested it on my WiPy. Pressing the reset button on the board then running machine.reset_cause() shows 0 which equals to machine.PWRON_RESET, whereas running machine.reset() gives reset_cause 2, equal to machine.WDT_RESET.
Alright so how can I do this? Do I need to set a flag in the filesystem?
@BetterAuto No. This is on an ESP8266 port of micropython.org. The ESP32 ports of pycom.io do NOT tell the difference between pushing the button snd machine.reset(). That looks inconsistent, since there seems no method to force an soft reset like Ctrl-D by software.
So I gather you're saying reset_cause() on a WiPy 2.0 will say one thing after issuing machine.reset() and something different after pushing reset?
I will test these out later if you're not sure.
@BetterAuto It seems that you are right. I used that feature on an ESP8266, and there you can use it to tell the difference between a reset caused by machine.reset() or a hard one (pushing the button).
In the Pycom port, it tells the difference between a reset cause by Ctrl-D versus machine.reset(), push button, etc.
I just tried both variants.
@robert-hh Wouldn't machine.reset() give the same reset_cause() for both a pushbutton reset and programmatic reset? Since it says in the documentation, "machine.reset() resets the device in a manner similar to pushing the external RESET button."
@BetterAuto You can use machine.reset_cause() after reboot to tell, what happened. Look for it in the docs.