Alexander Bugar
Article

Over-The-Air Firmware Update

A scalable OTA update framework for ESP32 devices with safe dual-partitioning

Overview

This is a custom OTA update system I built for the ESP32. It handles firmware updates over the network, switches partitions safely, and gives you full control over how and when devices get updated. Everything is built around making updates reliable without sacrificing flexibility.

The ESP runs the firmware, hosts a web dashboard on the local network, and pulls new firmware from a backend when triggered. It writes to the inactive partition, flips the boot config, and reboots into the new firmware. If that fails, it auto-rolls back to the last good state. You don't need to touch it and there's no risk of bricking or any external dependencies you can't see or modify.

The dual partition approach ensures there's always a working firmware version available, while the automated rollback mechanism protects against failed updates. Each update is verified with checksums before activation, with complete transparency through the dashboard.

Two-device visual interface

The web dashboard shows firmware info, update history, and provides a firmware upload interface. You can trigger updates directly from the browser, with full visibility into device status and update logs.

Project Structure

On the ESP32:

Boot Process

The bootloader is paired with a counter that gets incremented every time the device boots unsuccessfully. If the counter goes over a set limit (3 by default), it flips the boot partition back to the previous one and reboots again. That rollback logic is persistent, automatic, and doesn't rely on user input.

The update logic is built to avoid touching the running partition. Firmware gets written to the other slot, verified, then the boot config is changed. If it fails, it self-heals.

Frontend

There's a web dashboard I made that shows firmware info, update history, and a firmware upload interface. You can trigger updates directly from the browser. It includes:

The dashboard is static, hosted on GitHub Pages or anywhere you want, and talks to the backend and device through simple REST calls.

Backend BETA

Firmware is hosted on an HTTPS server (AWS S3). The ESP32 downloads from there when instructed, using a secure connection and verifying the SHA256 checksum before flashing anything. You can configure auth, signed URLs, or whatever storage logic you need.

Key Features

Safe OTA updates that don't brick

Always writes to the inactive partition. If something goes wrong, the fallback kicks in with no intervention.

Full update control from your browser

No IDE, no serial cable. Upload a .bin file from your dashboard and the ESP takes care of the rest.

Persistent state tracking

Every boot is logged. Failed ones increment a counter. Success clears it. Rollbacks happen automatically if needed.

Built for scaling or self-hosting

Works offline or online. Can be deployed across multiple devices or used in one-off setups.

Tech Stack

ESP32
PlatformIO Visual Studio Code Git AsyncWebServer
HTML/CSS/JS GitHub Pages Amazon AWS S3
SHA256 NTP SPIFFS

This project is made to be reused. I've used it on different ESP32 projects, and it keeps things sane when you're managing firmware that might change often. No part of it is hidden or magic. Everything from the frontend to the flash memory logic is visible and adjustable.

A scalable OTA update framework for ESP32 devices with safe dual-partitioning.

View Showcase →