OTA Firmware
Update System.
A scalable Over-the-Air update framework for ESP32 devices. Ensures safe updates with dual-partitioning, browser-based progress tracking, and version control for robust remote firmware management.
View detailed documentation →Reliable Updates
Utilizes a dual-partition scheme for safe rollbacks if an update fails.
Web Interface
An intuitive web page allows for easy firmware uploads without requiring special tools.
Live Progress
Tracks the upload and flashing progress in real-time.
Secure & Efficient
Validates firmware with checksums before the update is applied.
Project Overview
This Over-the-Air (OTA) update system provides a safe and efficient method for deploying firmware to ESP32 devices across a network. It was developed to eliminate the tedious and time-consuming process of manual updates. The framework is reliable, user-friendly, and integrates easily into existing ESP32 projects with minimal overhead.
By leveraging the ESP32’s dual-partitioning feature, the system ensures that a failed update won't render a device inoperable. You can upload new firmware through a simple web interface and monitor the flashing and verification process with live progress tracking.
Technical Deep Dive
The ESP32 hosts a local web server that provides a firmware upload form when accessed via its IP address. The device's firmware handles the file upload, validates the binary, and writes it to the inactive memory partition. Once the process is successfully completed, the ESP32 reboots into the new firmware.
// C++ code snippet for handling the firmware upload
void handleFirmwareUpload(AsyncWebServerRequest *request, String filename) {
if (!index) {
Serial.println("Update started");
if (!Update.begin(UPDATE_SIZE_UNKNOWN)) {
Update.printError(Serial);
}
}
if (len) {
Update.write(data, len);
}
if (final) {
if (Update.end(true)) {
Serial.println("Update successful");
ESP.restart();
} else {
Update.printError(Serial);
}
}
}
Implementation
The client-facing web interface is built with vanilla HTML and JavaScript to be lightweight and fast. The frontend communicates with the ESP32 using asynchronous HTTP requests to manage the file upload and display the progress bar.
// JavaScript for handling the file upload and progress bar
document.getElementById('upload-form').addEventListener('submit', function(e) {
e.preventDefault();
var form = e.target;
var data = new FormData(form);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/update');
xhr.upload.addEventListener('progress', function(e) {
if (e.lengthComputable) {
var percentComplete = (e.loaded / e.total) * 100;
document.querySelector('.progress-bar').style.width = percentComplete + '%';
}
});
xhr.onload = function() {
if (xhr.status === 200) {
alert('Update successful!');
} else {
alert('Update failed!');
}
};
xhr.send(data);
});