Skip to content

ESP32 OTA Rollback Does Not Revert

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about ESP32 OTA Rollback Does Not Revert. We cover key concepts, practical examples, and best practices.

The Problem

ESP32 firmware update fails but does not roll back to the previous working version.

Quick Fix

Wrong

// No rollback support configured
Corrupt firmware stays active. ESP32 does not boot correctly.
esp_ota_set_boot_partition(factory_partition);
esp_ota_mark_app_invalidated();
esp_restart();
// On next boot, ESP-IDF detects invalid app and rolls back
Previous firmware loaded. System recovered from bad update.

Prevention

Enable CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE in menuconfig. Mark app valid after successful boot. Test OTA with development board first. Use factory partition as fallback. Monitor boot count for automatic rollback.

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### How does ESP32 OTA rollback work?

If the new app fails to boot (reset loop), the bootloader automatically loads the previous app partition after a timeout.

How do I mark an app as valid?

Call esp_ota_mark_app_valid_cancel_rollback() after successful initialization and connectivity checks.

Do I need a factory partition for rollback?

Recommended but not required. Rollback can switch between ota_0 and ota_1 partitions. Factory partition is a third fallback.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro