diff --git a/components/spi_flash/include/esp_partition.h b/components/spi_flash/include/esp_partition.h index ade2e9eab8..42ac6777c9 100644 --- a/components/spi_flash/include/esp_partition.h +++ b/components/spi_flash/include/esp_partition.h @@ -249,8 +249,8 @@ esp_err_t esp_partition_write(const esp_partition_t* partition, * @param partition Pointer to partition structure obtained using * esp_partition_find_first or esp_partition_get. * Must be non-NULL. - * @param start_addr Address where erase operation should start. Must be aligned - * to 4 kilobytes. + * @param offset Offset from the beginning of partition where erase operation + * should start. Must be aligned to 4 kilobytes. * @param size Size of the range which should be erased, in bytes. * Must be divisible by 4 kilobytes. * @@ -260,7 +260,7 @@ esp_err_t esp_partition_write(const esp_partition_t* partition, * or one of error codes from lower-level flash driver. */ esp_err_t esp_partition_erase_range(const esp_partition_t* partition, - size_t start_addr, size_t size); + size_t offset, size_t size); /** * @brief Configure MMU to map partition into data memory diff --git a/components/spi_flash/partition.c b/components/spi_flash/partition.c index b598fcd5f2..f31705c81c 100644 --- a/components/spi_flash/partition.c +++ b/components/spi_flash/partition.c @@ -387,27 +387,26 @@ esp_err_t esp_partition_write(const esp_partition_t* partition, } esp_err_t esp_partition_erase_range(const esp_partition_t* partition, - size_t start_addr, size_t size) + size_t offset, size_t size) { assert(partition != NULL); - if (start_addr > partition->size) { + if (offset > partition->size) { return ESP_ERR_INVALID_ARG; } - if (start_addr + size > partition->size) { + if (offset + size > partition->size) { return ESP_ERR_INVALID_SIZE; } if (size % SPI_FLASH_SEC_SIZE != 0) { return ESP_ERR_INVALID_SIZE; } - if (start_addr % SPI_FLASH_SEC_SIZE != 0) { + if (offset % SPI_FLASH_SEC_SIZE != 0) { return ESP_ERR_INVALID_ARG; } #ifndef CONFIG_SPI_FLASH_USE_LEGACY_IMPL - return esp_flash_erase_region(partition->flash_chip, partition->address + start_addr, size); + return esp_flash_erase_region(partition->flash_chip, partition->address + offset, size); #else - return spi_flash_erase_range(partition->address + start_addr, size); + return spi_flash_erase_range(partition->address + offset, size); #endif // CONFIG_SPI_FLASH_USE_LEGACY_IMPL - } /*