esp_ota_ops.c: Fix size calculation to erase partition range for OTA image

Closes https://github.com/espressif/esp-idf/issues/4953
pull/5135/head
Shubham Kulkarni 2020-03-27 19:37:53 +05:30 zatwierdzone przez bot
rodzic 4a005a02f9
commit c82a4d59ee
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -157,7 +157,8 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
if ((image_size == 0) || (image_size == OTA_SIZE_UNKNOWN)) {
ret = esp_partition_erase_range(partition, 0, partition->size);
} else {
ret = esp_partition_erase_range(partition, 0, (image_size / SPI_FLASH_SEC_SIZE + 1) * SPI_FLASH_SEC_SIZE);
const int aligned_erase_size = (image_size + SPI_FLASH_SEC_SIZE - 1) & ~(SPI_FLASH_SEC_SIZE - 1);
ret = esp_partition_erase_range(partition, 0, aligned_erase_size);
}
if (ret != ESP_OK) {