Page 1 of 1

OTA failure

Posted: Thu Dec 12, 2019 12:17 am
by gibson12345
Hey everyone,

I'm doing an OTA transfer via BLE and I keep getting intermittent failures with the error:

esp_image: invalid segment length 0xfffffff

I've tried googling around but cannot seem to find any related solution.
Using ESP idf ver: v4.0-beta1-180-ga21eb04cc
The odd part to me is it fails 80% of the time after a full clean and build but other times it works just fine and I am able to perform an OTA update. Any help on trying to solve this would be appreciated

Cheers,
Gibson

Re: OTA failure

Posted: Thu Dec 12, 2019 4:41 am
by gibson12345
After some more digging I believe it may be something to do with the bootloader? I'll continue digging see if I come up with something

Cheers,
Gibson

Re: OTA failure

Posted: Fri Dec 13, 2019 2:18 am
by gibson12345
Is anyone able to provide some support on this? It would be really appreciated.

Cheers,
Gibson

Re: OTA failure

Posted: Fri Dec 13, 2019 2:55 am
by ESP_Sprite
Well, you'll have to at least provide a bit more info than what you're doing right now. Is your project source code online somewhere so people can have a look at it, for instance?

Re: OTA failure

Posted: Sun Dec 15, 2019 11:32 pm
by gibson12345
Hey Sprite,

Apologies I can't make the code public. But I can tell you that I now know that it occurs as a result of a disconnection coming mid way through a transaction over BLE with the Application we're interfacing with. We are not manually calling for a disconnect, but we are getting a disconnection event from our gatts handler. If you can think of anything that could potentially cause this, we're currently investigating a potential electrical issue that may cause a loss of current to the ESP32 (Could that cause the radio to turn off?) in addition to talking with the app creator.

Cheers,
Gibson

Re: OTA failure

Posted: Tue Dec 17, 2019 10:37 pm
by ESP_Angus
Hi Gibson,

Sorry for the confusing OTA error. Can confirm the root cause of "esp_image: invalid segment length 0xfffffff" is almost always a truncated image (the transfer completed before all bytes transferred). We have an open ticket internally to make this message more user friendly.

If it's possible to detect the truncation in your app (for example by sending the file length via the BLE connection and checking this many bytes are received) then this may help unnecessary verification failures, as well.

Regarding the BLE connection terminating, this could have a number of root causes but sounds like it may have been initiated by the other side of the connection? Obtaining a HCI dump from the app which shows the BLE packets which are sent/received from that side may be helpful. I'll check if the Bluetooth team has any suggestions as well.

Re: OTA failure

Posted: Thu Dec 19, 2019 11:13 pm
by ESP_Angus
ESP_Angus wrote:
Tue Dec 17, 2019 10:37 pm
I'll check if the Bluetooth team has any suggestions as well.
Bluetooth team says that BLE disconnects can happen for a number of reasons, so without logs it's not possible to debug further.

They agree with the suggestion of tracking the file length and number of transferred bytes as part of the OTA download protocol, and also suggest it may help to add a feature for resuming a download if it's disconnected and reconnected at the BLE protocol level.