OTA update repeats four (or more) times before software finally updates. NG: 0.7.0, OK:1.4.2 [SOLVED]

Hi Forum,

New Feature Description:
When the Electron is powered down and turned back on, I need to perform a software reset on the electron. I used the System.resetReason() command to identify when the device was powered off before hand and then trigger a System.reset().

// OLED Screen Reset: Wait 7 seconds and
// if last reset reson was power down do a system reset.
  if(millis() >= 7000){
    if(System.resetReason() == RESET_REASON_POWER_DOWN){ 
       System.reset(); //

Error Encountered: OTA Repeating Behavior (Video):
The Software flashed to these devices is compiled as Electron 0.6.4 firmware, so no update to base firmware occurs during this download. (i.e. the 0.7.0 unit is still at 0.7.0 after the download finishes)

On devices with 0.7.0 firmware with the software, I am encountering a weird issue where when I try to flash another software version, I see the OTA update repeat 4 or more times before finally ending on the software version requested. (Video shown below)
0.7.0 OTA download video: NG behavior, Auto-update restarts 4 times before new software starts running.

1.4.2 download video: OK behavior: Auto update runs 1x and starts new firmware

Help Request:
As you can see above, there is a situation that occurs on 0.7.0 firmware version devices where the code below results in the OTA repeating itself, in the above video it went 4 times, but it could go much longer. However, on firmware version 1.4.2 this does not seem to occur. When I remove the statement of if(System.resetReason() == RESET_REASON_POWER_DOWN){ everything is nominal on 0.7.0 firmware and the OTA repeating stops.

How can I stop the OTA repeating behavior and still use the if(System.resetReason() == RESET_REASON_POWER_DOWN){ expression for when a power down occurs?


#pragma Particle_NO_PREPROCESSOR;
#include <Particle.h>



#include "Pilot.h"
Pilot Main;

void setup() {
void loop() {

// OLED Screen Reset: Wait 7 seconds and
// if last reset reason was power down do a system reset.
  if(millis() >= 7000){
    if(System.resetReason() == RESET_REASON_POWER_DOWN){ 
       System.reset(); //

This is the expected behaviour when you flash a 1.4.2. targeted application to a device which does not (yet) have 1.4.2 device OS installed.

In order to actually run the application the device OS (3 modules on the Electron) needs to be updataed first - each module at a time with a reset between each module.
If the update also requires a bootloader update that may add another cycle to the process.

Hi @ScruffR,

Ah, good point, it does look like the base firmware is updating on the electron. But, I forgot to mention the software that is being flashed, is compiled in 0.6.4 so no update should be needed.

With the if(System.resetReason() == RESET_REASON_POWER_DOWN){ line removed the 0.7.0 unit does the update does it in only 1 shot.
Also there are not a consistent number of OTA repeats from what I have seen so far. Sometimes it will repeat +12 times and still be repeating the OTA update before I shut it off and use safe-mode to get the target firmware downloaded.

1 Like

From what you are describing, you are hitting Safemode healer (as ScruffR mentioned) - it updates the DeviceOS binaries if there is a mismatch between what’s on the device, and what you are compiling against.

Your video colour makes a bit difficult to tell, but you should see the LED blinking purple in a weird pattern.

You mentioned three firmware versions now, 0.7.0, 0.6.4 and 1.4.2.
You cannot downgrade OTA, so flashing 0.6.4 to 0.7.0/1.4.2 will results in issues.

Do I have that correct? You attempted 0.7.0-1.4.2 and 0.7.0/1.4.2-0.6.4?

I believe this line is interrupting the OTA process, what exactly is the intention behind it?

if(System.resetReason() == RESET_REASON_POWER_DOWN){ 
       System.reset(); //

Hi @no1089,

Yes you exactly understand the firmware versions. 0.6.4, 0.7.0 and 1.4.2.
I’ve never had issues before running 0.6.4 software on 0.7.0 and 1.4.2 versions, until trying to add this System.resetReason() feature.

Also apologies for the color balance on the video. The electron is indeed blinking magenta while downloading firmware.

The intent of this feature is to fix an observed problem where the device OLED screen does not turn on after power is immediately plugged in unless you do a Particle Electron reset.

So, to get this reset to enable 1x after power up, I was hoping to use the System.resetReason() command as an easy way to differentiate when the first power cycle starts. Also after the System.reset() the screen has turned on and I want to run the device normally

 if(System.resetReason() == RESET_REASON_POWER_DOWN){ 
       System.reset(); //

Thanks for identifying that this code could cause the interruption to the OTA process. Is this something you’ve seen before?

Hi Folks!

The root cause here is that while downloading software with firmware 0.7.0,
System.resetReason() == RESET_REASON_POWER_DOWN was being activated.

This does not occur in later firmware, my other case was 1.4.2.

Unfortunately since it is firmware related, there doesn’t seem to be a way to fix it on 0.7.0 firmware.
Fortunately for me, I finally figured out how to solve what I actually wanted to do without the need for the System.resetReason() == RESET_REASON_POWER_DOWN command.

So if you are experiencing weird repeating OTA updates on earlier firmware devices, check for this kind of command in your code.