Could IMP download wrong squirrel code?

On a recent build of a program I could see that the imp was behaving strange. It after the cold start worked for a while, then it disconnected from wifi and get frozen, the next was that the imp was rebooting and starting a new loop of this behaviour.

Since I couldn’t understand the behavior I just changed the program to an exactly similar program in order to make modifications to this second code, but it didn’t show the bad behavior showed before.

Then I proceeded to change the imp’s program to the former and it kept working without failures.

My only explanation to this is that the download of the program was made wrong the first time, and therefore it wasn’t executing the correct program.

Is there any other explanation for this?
Has imp any way to prevent this to happen/perdure?

It’s not possible for the imp to get corrupt code (eg partial download, etc). The code goes over TLS and TCP and if the complete code is not received eg due to a power loss it will be downloaded again the next time it connects.

Can you describe the bug any more? Could the behaviour be due to an external peripheral connected to the imp?

My program reads from a sensor and shows the value on a 7-segment display. And its configured to work even if it is offline.

After the start, it works normally, as the other imps that I have with the same program work, but after 1 min aprox I can see how logs are not received anymore.
Then I have 10 seconds while it continues working normally, and then I can see through the display that the program is frozen (it keeps the value unchanged and doesn’t respond to any stimulus).

After a while it goes out of this state and start to respond to the sensor again and after that I can see in the IDE that the program in booting, and there I get in the same second it boots a couple measures (I should only get one a second).

The same sequence is repeated over and over. Even if I turn off and turn on the imp.

And simply change the code to another program, with the same code, without adding or removing peripherals, solve this bug.

Sounds like your code is not using RETURN_ON_ERROR, and the wifi connection is getting into trouble. Your squirrel is then suspended whilst the imp tries to get the connection back.

Other question: how are you doing the loop? Repeated imp.wakeup?