My user firmware has a function that blinks D7 to indicate normal startup. The blink routine is only called in startup(). My user firmware does not declare a SYSTEM_MODE, so I assume I’m in AUTOMATIC.
I have an number of devices running in my test environment (office) and every once in a while D7 will start flashing on some device. There are no power interruptions because everything is on an uninterruptible power supply and I never notice any flickering of lights when this happens. There’s no system reset in my firmware.
What could make my user firmware execute startup() more than once?
If your system every hard faults or has other system faults that cause an literal red blinking SOS followed by an error code, your system will then typically reset itself. If that happened you’d see setup() run again. Here’s the various code for SOS and what might cause them: https://docs.particle.io/guide/getting-started/modes/photon/#red-flash-sos
Most common is dividing by zero, followed by a memory access fault (trying to read the memory contents using a NULL pointer) and also running out of HEAP (RAM).
If you are using a Core another reason for going through
setup() are all
System.sleep() modes that power down the µC.
And at some point (might well be fixed by now tho’) a longer lasting loss of cloud connection also put the device back to startup.