I am using AWS IoT OTA jobs with the AWS OTA library (MQTT based) that sits on top of the WICED OTA2 image library calls.
On occasion i have seen the OTA jobs fail almost immediately and I noticed a trend while checking debug logs. If the first two blocks of the image is received, then the image typically complete fine but if I receive block 2 or 3 first then the update will fail immediately. The AWS OTA system is design to receive files in any order and I think the OTA2 library requires at least the header to be received first.
Looking at the wiced_ota2_image.c, in wiced_ota2_image_update_staged_header, it appears the (total_bytes_received > ota2_header.image_size) line could be a source of failure of the header has not been received (image_size is invalid).
Has anyone encountered an issue like this while integrating OTA into their application?
Yes. OTA requires the image to be delivered in correct order.