Hi all,
Do any of you know how can find the download image's size at the time we check for the image's description at the beginning of the OTA? I would like to show the status of the download by using the percentage of the image's size since I do know the image_len_read.
How to find the image size for OTA
-
- Posts: 48
- Joined: Thu Sep 12, 2019 11:39 am
Re: How to find the image size for OTA
Anyone? Any suggestion?
-
- Posts: 190
- Joined: Wed Jan 24, 2018 6:51 am
Re: How to find the image size for OTA
Following code snippet from `advanced_https_ota_example` should help here:
https://github.com/espressif/esp-idf/bl ... #L112-L115
Code: Select all
while (1) {
err = esp_https_ota_perform(https_ota_handle);
if (err != ESP_ERR_HTTPS_OTA_IN_PROGRESS) {
break;
}
// esp_https_ota_perform returns after every read operation which gives user the ability to
// monitor the status of OTA upgrade by calling esp_https_ota_get_image_len_read, which gives length of image
// data read so far.
ESP_LOGD(TAG, "Image bytes read: %d", esp_https_ota_get_image_len_read(https_ota_handle));
}
Mahavir
https://github.com/mahavirj/
https://github.com/mahavirj/
Re: How to find the image size for OTA
I think what you want is the total binary size, so that you can determine the progress, eg. image_len_read / total_size * 100 = x%.
Assuming you're downloading the firmware, most servers will automatically set the Content-Length header, otherwise you'll have to implement it on the server some other way (eg. with a custom header, or a separate query for metadata, or embed metadata with the binary, etc).
Assuming you're downloading the firmware, most servers will automatically set the Content-Length header, otherwise you'll have to implement it on the server some other way (eg. with a custom header, or a separate query for metadata, or embed metadata with the binary, etc).
-
- Posts: 48
- Joined: Thu Sep 12, 2019 11:39 am
Re: How to find the image size for OTA
@ESP_Mahavir,
Thank you for the suggestion, but the snippet you suggest only give me the number of byte the successfully download and write to flash each esp_https_ota_perform() function call. It won't help what I am looking for.
What I am looking for is the whole image's size before the download is actually going on. I dig deep inside the advanced_https_ota_example, and there is nothing actually help. All the content_length from the responds return -1 or 0.
@boarchuz,
You are correct on what I am looking for. Do you know from the ota examples guide from esp like this https://github.com/espressif/esp-idf/tr ... system/ota, how can we set the content_length? All I got from the reading the content_length is -1.
Thank you for the suggestion, but the snippet you suggest only give me the number of byte the successfully download and write to flash each esp_https_ota_perform() function call. It won't help what I am looking for.
What I am looking for is the whole image's size before the download is actually going on. I dig deep inside the advanced_https_ota_example, and there is nothing actually help. All the content_length from the responds return -1 or 0.
@boarchuz,
You are correct on what I am looking for. Do you know from the ota examples guide from esp like this https://github.com/espressif/esp-idf/tr ... system/ota, how can we set the content_length? All I got from the reading the content_length is -1.
-
- Posts: 48
- Joined: Thu Sep 12, 2019 11:39 am
Re: How to find the image size for OTA
Hi all,
If you have a chance go over this thread, please simply just leave a message either "me too" or "+1". I am just curiously how many people are looking for the same solution/method. I can see the number of people who read this post increasingly but nothing/no comment. May be if may be too many people looking the same thing, we may have a better chance foe ESP support.
Thank you for reading this.
If you have a chance go over this thread, please simply just leave a message either "me too" or "+1". I am just curiously how many people are looking for the same solution/method. I can see the number of people who read this post increasingly but nothing/no comment. May be if may be too many people looking the same thing, we may have a better chance foe ESP support.
Thank you for reading this.
Re: How to find the image size for OTA
You're barking up the wrong tree. This has nothing to do with the functionality of the ESP32. There's no way to magically determine the total size if the server isn't providing that information.
So you'll need to configure your server:
So you'll need to configure your server:
If that's not possible you might consider using the size of the current app (which your ESP32 can determine independently) instead. The size is unlikely to change dramatically between versions so this will be reasonably accurate for the purposes of a visual indicator.Most servers will automatically set the Content-Length header (I'd suggest investigating this), otherwise you'll have to implement it on the server some other way (eg. with a custom header, or a separate query for metadata, or embed metadata with the binary, etc).
-
- Posts: 48
- Joined: Thu Sep 12, 2019 11:39 am
Re: How to find the image size for OTA
@boarchuz,
Thank you. I already made the decision to have the server's team help in this sizeof thing. I just try to see if there is api provide by ESP to support this, but I understand now it is not their responsibilities.
Thank you. I already made the decision to have the server's team help in this sizeof thing. I just try to see if there is api provide by ESP to support this, but I understand now it is not their responsibilities.
Who is online
Users browsing this forum: No registered users and 69 guests