I am developing (because I couldn't find an IDF example app) an application where my ROOT_MESH will download and update itself with an OTA image from an HTTPS server (from working example), and then proceed to read the current working OTA partition and send it in fragments of 1024 bytes across the WIFI mesh network using esp_mesh_send.
Going well so far but have run into a snag finding out how large the app in the current partition is when I am reading it using esp_partition_read. I expected the size would be returned in the esp_ota_get_partition_description but it is not. I don't want to send the entire OTA partition when my application is much less.
I added a work around test detecting when I read a block (1024 bytes) entirely consisting of 0xff and assuming this is empty flash. My concern is I would like to use the SHA256 of the esp_app_desc_t as part of my detection the image has changed at the MESH_NODE and I am assuming this won't match if I have added a bunch of 0xff bytes on the end.
I have tested adding a bunch of 0xffs to my current .bin file and then OTA updating it to the ROOT_NODE using https OTA, and doesn't seem to mind them. I also found I could change the contents of the bin file at the start in the description block changing the App name, version and date, and the OTA update still loaded and ran fine. This really surprised me as it demonstrates there is no form of file integrity check (eg checksum or CRC) in the bin file itself. I am not sure what the sha256 in the application description does? Maybe this will become a problem if I enable "Require signed app images" later.
I would really like to know the original image size, is this possible to obtain at runtime?
Is it possible to read my OTA partition application image size at runtime
-
- Posts: 1749
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Is it possible to read my OTA partition application image size at runtime
Can't you get the image size when downloading the image from the server, or when writing the new image to flash?
Store that size somewhere (NVS,...) and retrieve it when needed.
Store that size somewhere (NVS,...) and retrieve it when needed.
Re: Is it possible to read my OTA partition application image size at runtime
You can use esp_image_get_metadata(): https://github.com/espressif/esp-idf/bl ... #L115-L127
Re: Is it possible to read my OTA partition application image size at runtime
Thanks both of you for your responses.
MicroController: yes I could do this but I was not wanting to reinvent the wheel.
boarchuz: Thanks, this is exactly what I needed
Cheers
MicroController: yes I could do this but I was not wanting to reinvent the wheel.
boarchuz: Thanks, this is exactly what I needed
Cheers
Who is online
Users browsing this forum: No registered users and 77 guests