Closed Goliath86 closed 2 months ago
Hi @Goliath86 I've made a quick test on my device and everything is working as expected using OTA_Qspi_Flash
and OTA_Qspi_Flash_download_onthefly
examples.
The error -5
you are getting means the downloaded file length do not match the expected length of the file that is written inside the ota_header
Are you trying to download the default OTA_Usage_Portenta.ino.OPTA.ota
binary file or a different one?
Are you using Ethernet or WiFi?
Hi @pennam thanks for the answer. I'm trying to download the default OTA binary file that comes with the example. I'm using an Ethernet connection to a GSM Teltonika RUT 241 router. I've also tried to download the file with a custom function because it seems that the ota.download()
original function does not download the full file:
int downloadOtaFile(const char * hostname, const char * endpoint, bool const isWiFi, bool const isHttps) {
DEBUG_PRINT("Download file OTA");
EthernetClient e;
WiFiClient w;
HttpClient *client = nullptr;
if (isWiFi) {
client = new HttpClient(w, hostname, isHttps ? 443 : 80);
} else {
client = new HttpClient(e, hostname, isHttps ? 443 : 80);
}
client->get(endpoint);
int statusCode = client->responseStatusCode();
if (statusCode != 200) {
DEBUG_PRINT("[ERR] Recupero file di aggiornamento: " + String(statusCode));
return -1;
}
if (client->skipResponseHeaders() != HTTP_SUCCESS) {
DEBUG_PRINT("[ERR] Recupero skip header file di aggiornamento");
return -2;
}
int bodyLen = client->contentLength();
DEBUG_PRINT("Lunghezza file da scaricare: " + String(bodyLen) + "bytes");
FILE* f = fopen(UPDATE_FILE_NAME_LZSS, "w");
int byteCounter = 0;
while (client->available()) {
DEBUG_PRINT("Scaricati " + String(++byteCounter) + " bytes");
char _c = client->read();
fwrite(&_c, 1, 1, f);
}
fclose(f);
return bodyLen;
}
and with my custom function the file seems to be fully downloaded if I see the length of it but then the update()
function give to me the -5
error. On your tests have you used the original download()
function? Have you tested it with Ethernet or WiFi?
Thank you again
Mattia
Yes i've used the original download function and WiFi. Do you have the chance to test it with WiFi or Ethernet without the GSM router?
Also make sure to use the latest 4.1.5 mbed core.
@Goliath86 any news about this issue?
Hi @Pennam sorry but I was on holiday the last two weeks and I haven't tested the OTA with WiFi. I will try in this week and I will inform you about the results. Thank you again
Hi @pennam, I've tested the OTA update sketch with WiFi but I continuously receive the -5 error:
15:46:39.975 -> Initializing OTA storage 15:46:39.975 -> Starting download to QSPI ... 15:46:41.709 -> 97861 bytes stored. 15:46:41.709 -> Decompressing LZSS compressed file ... 15:46:41.825 -> Arduino_Portenta_OTA_QSPI::decompress() failed with error code-5
@Goliath86 Did you already tryed to reformat your QSPI flash? You can use the following sketches:
then reload network certificates and wifi firmware with https://github.com/arduino/ArduinoCore-mbed/tree/main/libraries/STM32H747_System/examples/WiFiFirmwareUpdater
The downloaded file size 97861
is correct so i'm suspecting there is some issue storing the file
@pennam ok, I will try, thank you!
Hi @pennam, I've tested what you have suggested and effectively after flashing the two sketches that you've mentioned, the OTA_Qspi_Flash example runned successfully on Wi-Fi. Then I've tried to modify the example with the link with my .ota file (589000 bytes) and the example didn't run successfully (error codes -3001) always on Wi-Fi.
I've then modified this library download()
function with a custom one that I've taken from another sketch of mine only to insert some debug info. I've then noticed that the problem is with the stability of the network connection (even on Wi-Fi): where I've tested the sketch, the Wi-Fi was not so reliable; the sketch remained on the while (client.connected()) {...}
loop but without receiving any bytes from the socket nor loosing connection for hours and hours (I've waited nearly 24h before resetting the device). I've then tested the same sketch with my mobile phone as router and put it nearby the OPTA device and then the OTA update runned successfully.
Now that I've found the problem (the connection not so reliable and the download of large files) I can't switch to this library download()
function because it seems that it does not provide a call to some sort of watchdog reset function (like the decompress()
function.
So, to conclude, thank you again @pennam for the support on this journey!
Ciao!
Hi all, I've tried to OTA update my various OPTA but it seems that I always get the -5 error code. It seems that the .ota file is downloaded correctly (same size of the Content-Length of the download request) but it can not pass the decompress function. I' ve tried with the OTA_Qspi_Flash and the OTA_Qspi_Flash_download_onthefly examples but with no luck. Has anyone tried the OTA with the OPTA devices?
Thank you