Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Erase Size Calculation In esp_ota_begin (IDFGH-2909) #4953

Closed
CDK-Vonkil opened this issue Mar 18, 2020 · 1 comment
Closed

Incorrect Erase Size Calculation In esp_ota_begin (IDFGH-2909) #4953

CDK-Vonkil opened this issue Mar 18, 2020 · 1 comment

Comments

@CDK-Vonkil
Copy link

In components/app_update/esp_ota_ops.c:
In function esp_ota_begin:

An incorrect erase size is calculated when the caller passes image_size=partition->size.

This is because of an error in the rounding calculation at line 160, which adds an extra sector size:
ret = esp_partition_erase_range(partition, 0, (image_size / SPI_FLASH_SEC_SIZE + 1) * SPI_FLASH_SEC_SIZE);

The correct calculation would be something like:
ret = esp_partition_erase_range(partition, 0, ((image_size + SPI_FLASH_SEC_SIZE - 1) / SPI_FLASH_SEC_SIZE) * SPI_FLASH_SEC_SIZE);

@github-actions github-actions bot changed the title Incorrect Erase Size Calculation In esp_ota_begin Incorrect Erase Size Calculation In esp_ota_begin (IDFGH-2909) Mar 18, 2020
@Alvin1Zhang
Copy link
Collaborator

@CDK-Vonkil Thanks for reporting, we have a fix internally now under reviewing. Will update once the fix is available on GitHub. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants