esp_https_ota Corrupts downloaded firmware image when partial_http_download is used (IDFGH-11993) #13065
Closed
3 tasks done
Labels
Resolution: Done
Issue is done internally
Status: Done
Issue is done internally
Type: Bug
bugs in IDF
Answers checklist.
IDF version.
v5.1.2
Espressif SoC revision.
ESP32
Operating System used.
Windows
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
PowerShell
Development Kit.
Custom Board
Power Supply used.
USB
What is the expected behavior?
The
esp_https_ota
module should successfully download OTA images regardless of thepartial_http_download
setting.What is the actual behavior?
Whenever
partial_http_download
is set totrue
andesp_https_ota_get_img_desc(...)
is not called betweenesp_https_ota_begin(...)
andesp_https_ota_perform(...)
, the downloaded OTA image is corrupted.Steps to reproduce.
esp_https_ota(...)
withpartial_http_download
set totrue
.Debug Logs.
More Information.
This is caused by a set of bytes being double-counted at the very start of the OTA update process. If
esp_https_ota_get_img_desc(...)
is not called, then control flows through the else block at lines 511-514 (using 5.1.2 line numbers) ofesp_https_ota.c
. The call toread_header(...)
in that block updates the value ofhandle->binary_file_len
to account for the bytes that are read in order to read in the header. These bytes are then counted again in the value ofhandle->binary_file_len
when_ota_write(...)
is called with that same buffer on line 535. This then offsets the header calculation on line 588, effectively skipping part of the file download. This corrupts the downloaded OTA and typically makes it unusable.This appears to have been fixed in
v5.3-dev
by commit37a098e
, but the commit message only refers to an incorrect debug print and it has not been back-ported to v5.1. It does not only affect printing, it can corrupt the OTA image.Additionally note that
esp_https_ota_get_img_desc(...)
is incorrectly referred to asesp_https_ota_read_img_desc(...)
in several of the comments and error messages inesp_https_ota.c
.The text was updated successfully, but these errors were encountered: