Page 1 of 1

esp_https_ota() fails to complete

Posted: Thu Nov 11, 2021 9:39 pm
by sramberg2
Using IDF 4.3 I call esp_https_ota() and it never returns. Here is the log output.

Code: Untitled.txt Select all

D (14171) esp_https_ota: Written image length 19652
D (14171) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (14181) TRANS_SSL: remain data in cache, need to read again
D (14181) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=289, ridx=0
D (14191) HTTP_CLIENT: http_on_body 289
D (14211) esp_https_ota: Written image length 19941
D (14211) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (14221) TRANS_SSL: remain data in cache, need to read again
D (14231) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=289, ridx=0
D (14231) HTTP_CLIENT: http_on_body 289
D (14251) esp_https_ota: Written image length 20230
D (14261) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (14261) TRANS_SSL: remain data in cache, need to read again
D (14271) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=289, ridx=0
D (14281) HTTP_CLIENT: http_on_body 289
D (14341) esp_https_ota: Written image length 20519
D (14341) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (14351) TRANS_SSL: remain data in cache, need to read again
D (14351) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=70, ridx=0
D (14361) HTTP_CLIENT: http_on_body 70
D (14361) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (14371) HTTP_CLIENT: need_read=219, byte_to_read=219, rlen=-1, ridx=70
D (14391) esp_https_ota: Written image length 20589
D (14391) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (19401) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=0, ridx=0
D (19401) HTTP_CLIENT: Chunks were not completely read
D (19401) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (24401) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=0, ridx=0
D (24401) HTTP_CLIENT: Chunks were not completely read
D (24401) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (29401) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=0, ridx=0
D (29401) HTTP_CLIENT: Chunks were not completely read
D (29401) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (34401) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=0, ridx=0
D (34401) HTTP_CLIENT: Chunks were not completely read
D (34401) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (39401) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=0, ridx=0
D (39401) HTTP_CLIENT: Chunks were not completely read
D (39401) HTTP_CLIENT: is_data_remain=1, is_chunked=1, content_length=-1
D (44401) HTTP_CLIENT: need_read=289, byte_to_read=289, rlen=0, ridx=0
D (44401) HTTP_CLIENT: Chunks were not completely read
It appears to have an issue with the last piece of data (70 bytes) at (14361), and will continue to output the same lines forever.

Partition Table.
# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap,,,,
nvs, data, nvs, 0x9000, 0x4000,
otadata, data, ota, 0xd000, 0x2000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 0x160000,
ota_0, app, ota_0, 0x170000, 0x160000,
ota_1, app, ota_1, 0x2D0000, 0x160000,
www, data, spiffs, , 0x3D0000,

Searched through the forum and was able to find any info about this issue.

Thanks
-Steve

Re: esp_https_ota() fails to complete

Posted: Tue Nov 16, 2021 6:23 pm
by sramberg2
Solved the issue. Turned out to be an issue with the http server I was using.
openssl s_server -WWW -key ca_key.pem -cert ca_cert.pem -port 8070

Using the curl command as suggested in the troubleshooting section of examples\system\ota\README.MD pointed me to the issue as the curl command would only transfer the first part of the file (same number of bytes as the ESP firmware).

I am now using a python secure server suggested by this github issue: https://github.com/espressif/esp-idf/issues/5240

Re: esp_https_ota() fails to complete

Posted: Wed Mar 26, 2025 1:18 pm
by miltoneo
Hi,

I had the same issue with esp_https_ota() stuck and not completing the download.
I was using openssl:
sudo openssl s_server -WWW -key ./server_certs/ca_key.pem -cert ./server_certs/ca_cert.pem -port 8070

I changed from opessl to python server.

The solution was found at: https://github.com/espressif/esp-idf/issues/5240