Hard/factory reset in software

I’m interested in triggering a “hard,” or factory reset from software. This is the equivalent of holding down “mode” and the “reset” button until the core is in blinking blue mode. I tried System.reset(), but that’s the equivalent of a soft reset – it just resets the processor.

Any ideas are welcome! Thanks!

Try this: :smiley:

  // This tells the WLAN setup to clear the WiFi user profiles on bootup
  NVMEM_SPARK_Reset_SysFlag = 0x0001;

Opened an issue here for possible add-on: https://github.com/spark/docs/issues/287

1 Like

I have just had a quick read through the new documentation - especially the guide on how how to build a product. It recommends having a reset button. My current package design hides away the Photon, so no consumer access to reset. Can I simply add a switch to the outside and wire this to reset the photon? I presume I wire it to a pin which when set will fire an interrupt to run a software reset - but what should it run?

Thanks for your continued support here as I work through my project.

  • You can wire up to the reset pin on the Photon which is the actual reset pin on the STM32F2/P0
  • I think calling System.reset() should do :wink:

I have an interesting question about this issue. Is there any possibility that the chip could hang in a state such that only a hard reset of the reset pin will restart the processor? I am not talking about buggy code but rather latched up hardware. Is it possible? Has anyone seen it happen?

The reason I ask is I used to use an external hard reset for the Core via the reset pin but am now moving over to the WKP pin on the Photon. I am not sure if the WKP is purely a hardware feature or if there is some system level code that supports it’s function, but any change like this makes me concerned.

1 Like

Thanks @kennethlimcp Is the software reset (System.reset) the same as setting the RST pin to low? Otherwise, what are the differences?

It’s different the RST pin is really a hardware form of reset whereas the System.reset() really is a software triggered reboot.

Hi All, @kennethlimcp

I am still not clear if an external button should be wired to the RST pin? Would this ensure that all software hangups would be cleared? What state would the device be in after the reset? I presume a software reset is of no use here (as the system has hung)?

Perhaps I should be asking the question the other way round - what does the Particle team recommend in terms of providing a reset button - i.e. what should it be wired to, any additional firmware code required to set into a safe state?

Thank you

Wire to the RST pin which is the same pin that the on-board RST button is wired to.

Perfect! Thank you.

I have looked through the docs for explanations of the various button press combinations ( e.g. Press both buttons, then release the reset button…), but I cannot see any info on what happens when you just press the reset button). Should be obvious, but what state is the device in and when should just reset be used?

Apologies for all the questions, but I need to understand the implications before I ship out to customers.

Pressing the reset button is the same as pulling out the power and plugging it back in, if I’m not mistaken. A fresh start, if you will.

@Moors7 @kennethlimcp
OK, that all sound fine. Except now I am a little confused!
If setting the RST pin low only does the same as unplugging, why is it advised to have a reset button on a production device? Surely the customer could be advised to unplug just as easy as pressing a button?