With the proliferation of IoT and Internet access for small embedded devices, it is becoming more common for such systems to be deployed to remote locations. This implies a requirement on the devices to work autonomously without physical access by human personnel. In addition, the devices are mass deployed with centralized management through a Cloud-based service, allowing for an easy and cost-effective solution for long term maintenance. The combination of remote locations and Cloud management mandates the implementation of OTA (Over-the-air) firmware upgrades with fail-safe mechanisms in order to avoid long downtimes, and costly repair operations. Fail-safe mechanisms shall guarantee device accessibility through the Cloud. This mechanism shall work flawlessly even in the cases of failed firmware upgrades by getting back to a known state or allowing remote diagnosis and repair.