ESP32-S3 (N32R8) boots only from ota_0 after successful OTA update – PlatformIO/Arduino
Posted: Sat Jan 18, 2025 9:39 pm
I'm working on an ESP32-S3-WROOM-2-N32R8 (32MB Flash, 8MB PSRAM) project using PlatformIO in VSCode with the Arduino framework. My goal is to implement OTA updates, but I'm running into an issue: The ESP32 always boots from ota_0 (partition app0), even though the OTA update to ota_1 (partition app1) completes successfully without any errors.
Problem Details:
OTA update writes the new firmware to ota_1 and marks it as the boot partition successfully.
Calls to esp_ota_get_boot_partition() confirm that the boot partition has been updated to ota_1 post-update.
On reboot, the ESP32 always boots from ota_0 (instead of ota_1 as intended)
Environment:
Board: ESP32-S3-WROOM-2-N32R8V (32MB Flash, 8MB PSRAM Octal)
Platform: PlatformIO (VSCode)
Framework: Arduino
Partition Table:
Analysis conducted
The following analysis has been conducted:
1. Find the current boot partition (before update)
Result: Current boot partition: app0
2. Check if ota partition is bootable
Result: Partition is bootable.
3. Checked the ota partition's address
Result: The partition, which the new firmware is written to, shows address 0xBC0000 (app1) correctly.
4. Verified result on setting boot partition
Result: ESP_OK = Boot partition set to app1 without error
5. Forced the ota partition to mark app as valid after verification.
Result: Partition is valid. / App marked as valid.
6. Read-out the contents of ota_data partition
The following data is stored in the otadata partition (address: 0xE000, length 0x2000)
Result: This indicates that the boot loader has correctly been set to app1 as boot partition.
Question
How come that my ESP32 is still booting from partition app0 after reboot / power cycle?
The serial output confirms:
Address 0x10000 is app0, not as after ota update confirmed address 0xBC0000.
Thanks a lot for your help!
Problem Details:
OTA update writes the new firmware to ota_1 and marks it as the boot partition successfully.
Calls to esp_ota_get_boot_partition() confirm that the boot partition has been updated to ota_1 post-update.
On reboot, the ESP32 always boots from ota_0 (instead of ota_1 as intended)
Environment:
Board: ESP32-S3-WROOM-2-N32R8V (32MB Flash, 8MB PSRAM Octal)
Platform: PlatformIO (VSCode)
Framework: Arduino
Partition Table:
Code: Select all
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xE000, 0x2000,
app0, app, ota_0, 0x10000, 0xBB0000,
app1, app, ota_1, 0xBC0000, 0xBB0000,
nvm, data, nvs, 0x1770000, 0x890000,
The following analysis has been conducted:
1. Find the current boot partition (before update)
Code: Select all
esp_ota_get_boot_partition()
2. Check if ota partition is bootable
Code: Select all
if (_partitionIsBootable(_partition) == true) {
Serial.println("[Updater] Partition is bootable.");
}
3. Checked the ota partition's address
Code: Select all
Serial.println("[Updater] New partition address: " + String(_partition->address));
4. Verified result on setting boot partition
Code: Select all
esp_err_t result = esp_ota_set_boot_partition(_partition);
5. Forced the ota partition to mark app as valid after verification.
Code: Select all
if (esp_partition_verify(_partition)) {
// Mark the newly flashed partition as valid, if partition is valid
esp_err_t err = esp_ota_mark_app_valid_cancel_rollback();
if (err != ESP_OK) {
Serial.println("[Updater] Error: Partition not valid.");
Serial.println("[Updater] Error marking app valid! Code: " + String(err));
} else {
Serial.println("[Updater] Partition is valid.");
Serial.println("[Updater] App marked as valid. OK! Code: " + String(err));
}
}
6. Read-out the contents of ota_data partition
The following data is stored in the otadata partition (address: 0xE000, length 0x2000)
Code: Select all
01 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 9A 98 43 47
Question
How come that my ESP32 is still booting from partition app0 after reboot / power cycle?
The serial output confirms:
Code: Select all
Currently running from partition: Type: 0, Subtype: 16, Address: 0x10000
Thanks a lot for your help!