Sorry I was out for a few days for product demo to another city. So couldnt reply back. But we did the tests that you guys asked. So to give a little more insight upgrading the code on photon P1, when we upgrade with the Blink app it works fine.
So that directs us into believing that the issue is with our application. But it is weird that when we flash the code photon stops connecting to the same wifi but connects onto other wifi in its list. What could be the issue?
Another observation - when we had recently flashed our app keep the firmware also the same as 0.5.3 then also it had stopped connecting over the same wifi. But when we enabled the other wifi photon quickly connected to the other one and we could flash the same application code on the new wifi without it giving any such problems.
So to summarise whatever little I have understood, the first time we flash the latest app code even keeping the firmware the same the photon stops communicating with the same wifi. And after we enable the other wifi (which it knows) it connects successfully and then we can flash the app code as many times without such an issue. It just becomes like its forgotten the wifi credntials as if its been deleted. But when we read the wifi credentials stored it shows that wifi credential in its list.