OTA flash of Electron device not always successful on the first try


I’ve the following problem, when I flash Electron Device OTA, I often need to run it at least two time before my code get successfully through.

When OTA flash fails:
-I do see the Electron device (LED blinking magenta, and then device restart) during the update
-I don’t have any error anywhere (console or on the device) after the device reboot
-But my device still use my older code version (I can see it via Serial logs and a call to a dedicated function) after the device restart

Running the OTA flash a second time will usually solve the issue

I’m using the following environment to flash OTA:
-ATOM 1.7.3
-particle CLI 1.16.0
-Electron FW 0.6.0-rc.1
-my code does use SYSTEM_THREAD(ENABLED); and I do not use any delay call in my code.

As I do use Serial (to print debug logs) and Serial1 (to communicate with another device), could this be part of the issue:

This would be very annoying as I do need to keep at least Serial1 open all the time.

How long have you been waiting after the flash to confirm your old code was still running?
With SYSTEM_THREAD(ENABLED) I’ve had a delay of up to 10sec (on Photons) after the magenta finished that the device actually rebooted an executed the new code. Resetting or rebooting the device manually during this periode did prevent the new code from sticking.

You can also subscribe to a system event that indicates an update and drop into a tight loop only executing Particle.process() (possibly with some timeout to bail out if the OTA fails to reboot the device).

1 Like

Tks for the reply. I usually callback the device the device a few seconds after a got a device restart message via a webhook. So I’m expecting the device to be running the new code at this time. In other words, I ask ask for software version about 10 to 20s after reboot.

I will check your proposed Particle.process() approach. However, I don’t understand why I would need that. Each time I do an OTA update, I could clearly see the Electron going to update (Magenta LED), reboot, and network reconnection. It is just that after these actions, I still see the old firmware.

Do you mean that my program while running on the device could somehow disrupt the FW update? If yes, should I not see an error in the GUI?

Thank you.

P.S. Do you have any link to a document that explain in (more) details how OTA update works? To improve my understanding of the process.

Yes, and without knowing your code it’s hard to tell if my “Particle.process() approach” is needed or not, but it might help.
I also don’t know the cellular service quality where you are and while you are performing OTA.

But, you could try some test apps to see how SYSTEM_THREAD(ENABLED) and ither things (e.g. delay(), longish running sensor reads, interrupts, Serial/Serial1, …) can impact the OTA process.