Once you have thousands of devices in the field, you cannot update them one by one. OTA updates let you push new firmware remotely — but getting it right is critical. A failed OTA update can brick a device permanently.
The architecture
An OTA system has three components: a firmware server, a communication channel, and a device-side update client. The device periodically checks the server for updates, downloads the firmware, verifies it, writes it to flash, and reboots into the new firmware.
The dual-bank approach
Never overwrite the running firmware. Use two flash partitions:
┌─────────────────┐
│ Bootloader │ (always intact)
├─────────────────┤
│ Bank A │ (currently running)
├─────────────────┤
│ Bank B │ (download target)
└─────────────────┘
Download the new firmware to Bank B while Bank A continues running. After download and verification, set a flag telling the bootloader to boot Bank B. If Bank B fails to boot successfully, the bootloader automatically reverts to Bank A.
Verification is mandatory
Never flash unverified firmware. Always verify:
- Integrity: CRC or SHA256 hash check to confirm no corruption during download
- Authenticity: Cryptographic signature verification with your signing key
- Version: Reject downgrades to prevent rollback attacks
The communication layer
MQTT over TLS is a common choice for IoT OTA. The device subscribes to an update topic. When you publish a firmware announcement, devices check if it is newer than their current version and initiate the download.
HTTPS is simpler and works well for devices with enough resources. Use TLS certificate pinning to prevent man-in-the-middle attacks.
Testing your OTA
Test every failure scenario: power loss during download, power loss during flash write, corrupted image, network interruption. A robust OTA system handles all of these gracefully — the device reboots and continues running the previous firmware.



