How to deploy new software to hard fault-ing devices

I mistakenly deployed some code to a group of devices which is causing them to hard fault. As I can see from a local device, they boot up, hard fault, reset, and repeat. After seeing this I deployed a new binary that fixes the problem, however, not all of the devices have started running this new code. Some of the devices downloaded the new version and are fine, but most are stuck constantly rebooting. I’ve tried putting them as dev devices and flashing directly, or locking them to the new binary, but no response at all. Is there anything I can do to get these devices back without having to manually put them in safe mode?

This is the pattern of events I get from the stuck devices:

Manually putting devices in safe mode is usually the only way if you are in rolling reboot.

One way to guard against this is to keep a flag in retained memory. Set this after the device comes online for a while, maybe a minute or two. Also have a retained counter variable, clear you set the successfully online flag.

At the beginning of setup(), if the successfully connected to the cloud flag is not set, increment the counter.

If the counter exceed some value, like 3, the device is continually rebooting and you call System.enterSafeMode().

2 Likes