Skip to content

Commit

Permalink
esp_ota_ops.c: Fix size calculation to erase partition range for OTA …
Browse files Browse the repository at this point in the history
…image

Closes espressif#4953
  • Loading branch information
shubhamkulkarni97 authored and espressif-bot committed Mar 31, 2020
1 parent 4a005a0 commit c82a4d5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/app_update/esp_ota_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c82a4d5

Please sign in to comment.