OTA upload http issue - Arduino FINDER OPTA Wifi

Hi all,

Sorry to disturb the community.
But I am in trouble w/ my OPTA Wifi module when I try to upload sketch from my https server :frowning:

To help me, I use in my project the OTA upload from this tutorials :

https://docs.arduino.cc/tutorials/portenta-h7/over-the-air-update/

and

https://github.com/arduino-libraries/Arduino_Portenta_OTA/blob/main/examples/OTA_Qspi_Flash_Ethernet/OTA_Qspi_Flash_Ethernet.ino

All works well if and only if I use the download link from the tutorials. I mean :

https://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.OPTA.ota

As soon as I use my own link :

https://ota.ejc-solutions.com/OTA_Usage_Portenta.ino.OPTA.ota

an error -3011 is returned ! See the debug below :

16:12:44.332 -> Starting download to QSPI ...
16:12:45.112 -> Arduino_Portenta_OTA_QSPI::download failed with error code -3011

I tried in Ethernet or Wifi, same behavior, error -3011.
If I set false to is_https from ota.download function (int const ota_download = ota.download(OTA_FILE_LOCATION, false /* is_https */) the OPTA stays blocked to download :

15:41:34.228 -> Starting download to QSPI ...
and not more !

I know that I did a mistake w/ my https link, but where, I don't know. Because when I click on it, it works. The file can be uploaded.

I tried to find the -3011 error but unfortunately, I didn't find anything :frowning:
I searched into the utility.cpp from the same tutorial but there is no explanation about this error code. Same situation from the web, I didn't find.

Please, if someone can help me, it will be w/ pleasure :slight_smile:

I forgot to precise that I tried an others links and always same pb. I think that it is a pb w/ http server but what, I don’t know :confused:

Hi @manucast

-3011 is NSAPI_ERROR_AUTH_FAILURE

and is probably being thrown by the handshake

These are the tests mbed devs run to validate the handshake code. I'd check your site against each of the tests that are expected to return -3011

Just checked the cacert.pem installed on the GIGA (I suspect OPTA uses the same) and I can't see the cert authorities you've used for your site. (keytool output attached)
cacert.txt (55.7 KB)

Many many thanks Steve9 to take your time to answer me.
Very appreciated :blush:
If I understand well (sorry but not familar w/ that), maybe, it is a pb w/ the SSL certificate.
I will regenerate it in case or and re-check it.
I will keep you the result.

I believe the problem is that the root CA used by Let's Encrypt (ISRG Root X1) is not included in the Arduino supplied cacert.pem file. It is therefore considered untrusted and fails to connect. Arduino downloads uses a cert with Google Trust Services as root, which is included.
Options:

  1. Use a certificate service whose root is already in the Arduino provided file
  2. Ask Arduino to include your root CA in the file and have them reissue
  3. Add your root CA to the .pem file yourself

p.s. this may also be of use ArduinoCore-mbed/libraries/STM32H747_System/examples/WiFiFirmwareUpdater/Readme.md at main · arduino/ArduinoCore-mbed · GitHub

Update: Just seen a commit from 2yrs ago that adds ISRG Root X1 (Let's Encrypt) to CAs. Add ISRG Root X1 (Let's Encrypt) to CAs · arduino/ArduinoCore-mbed@be09d4e · GitHub

Suggest you run the WiFiFirmwareUpdater sketch from STM32H747_System examples before anything else.

Update 2: Forget everything I've said! I've just tried to download the ota file from your site using the Arduino code and the response is:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access this resource.</p>
</body></html>

I've run the same code for the Arduino site and I get a 96KB binary. I suspect a problem with site permissions but that's as far as my website knowledge goes.

As the server is saying 2.0, maybe check it is also configured for 1.x

Many many thanks for your help :pray:

I just started updating the certificate.h from my own MemoryPartitionning.ino from your link above (Update 1).
Indeed, I modified the initial partionning by adding 2x new block device after wifi_data (always 1Mb) and ota_data (5Mo).

And now, it works :smile: . I mean error 3011 disappeared / solved :partying_face:
Therefore, Let's encryp is full compatible w/ Arduino. Good news !

But, and unfortunately there is a but, there is a pb w/ the lenght data uploaded. Not conform 199 bytes instead of 97861 bytes using the download.arduino.cc link.
See below the debug :

15:03:39.485 -> Attempting to connect to the network ...
15:03:39.485 -> Connected
15:03:39.485 -> Initializing OTA storage
15:03:39.485 -> OTA_FILE_LOCATION: https://ota.ejc-solutions.com/OTA_Usage_Portenta.ino.OPTA.ota
15:03:39.485 -> Starting download to QSPI ...
15:03:41.161 -> 199 bytes stored.
15:03:41.161 -> Decompressing LZSS compressed file ...
15:03:41.352 -> Arduino_Portenta_OTA_QSPI::decompress() failed with error code-5

Maybe, it is an issue from server saying 2.0 as you wrote. I will try to find how to downgrade it or make it compatible.

I will keep you the result.
Once again, thanks for your help.

Great news, good progress. If you add these few lines to your sketch you'll be able to see the QSPI Flash partitions on your PC and read the file it has downloaded.

#include <PluggableUSBMSD.h>
#include <QSPIFBlockDevice.h>
QSPIFBlockDevice root;
USBMSD MassStorage(&root);

Good idea, thanks steve9

So, the result is OK (UPDATE.BIN present) from arduino web site and KO (empty) from my web site :frowning:

Therefore, and clearly, there is always an issue w/ the upload file from my web site because the USB OTA partition is empy.

Here is the debug :

From downloads.arduino.cc
16:03:36.020 -> Attempting to connect to the network ...
16:03:43.854 -> Connected
16:03:43.854 -> Initializing OTA storage
16:03:43.854 -> OTA_FILE_LOCATION: https://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.OPTA.ota
16:03:43.854 -> Starting download to QSPI ...
16:03:50.924 -> 97861 bytes stored.
16:03:50.924 -> Decompressing LZSS compressed file ...
16:04:04.933 -> 125376 bytes decompressed.
16:04:04.933 -> Storing parameters for firmware update in bootloader accessible non-volatile memory ...
16:04:04.933 -> Performing a reset after which the bootloader will update the firmware.
16:04:04.933 -> Hint: Board LED will blink Red-Blue-Green.

Result w/ AccessFlashAsUSBDisk
USB(D:) : 4343WA1.BIN & cacert.pem
USB(E:) : UPDATE.BIN (125376 bytes)
USB(F:) : empty
USB(G:) : empty

From my ota.ejc-solutions.com
16:11:01.790 -> Attempting to connect to the network ...
16:11:08.777 -> Connected
16:11:08.777 -> Initializing OTA storage
16:11:08.777 -> OTA_FILE_LOCATION: https://ota.ejc-solutions.com/OTA_Usage_Portenta.ino.OPTA.ota
16:11:08.777 -> Starting download to QSPI ...
16:11:10.410 -> 199 bytes stored.
16:11:10.410 -> Decompressing LZSS compressed file ...
16:11:10.579 -> Arduino_Portenta_OTA_QSPI::decompress() failed with error code-5

Result w/ accessfalsh
USB(D:) : 4343WA1.BIN & cacert.pem
USB(E:) : empty !!!!!!
USB(F:) : empty
USB(G:) : empty

The ota.decompress is removing the downloaded file if it fails validation so comment out everything in the example setup() after Serial.println(" bytes stored.");

Sorry, I didn't know that the file was deleted after a decompress failed.

The result is an UPDATE.BIN.LZSS file present but w/ only 199 bytes instead of 97861 bytes.

I am searching how to modify the header (DOCTYPE) from my provider (OVH). And I don't find how to do :frowning:

I will continue to search.
Many thanks for your help and time steve9

A friend will share w/ me his file server in order to check if this issue is also present.
He works w/ an other provider. Maybe...

Adventure to follow but :sweat:

Pb solved :partying_face:

W/ my friend, we have compared our files servers.
To summarize, his files server worked well w/ ota.download.
In comparing our dashboard, there was only one difference. His firewall application is disabled, not in my side.
And after disabling my firewall application, it works in my side.

Once again, thanks for your help steve9 :pray:

So glad it's working for you. Would be good to know what rule in the firewall config would be required to have it work with the firewall app running

I agree w/ you because it is not normal to disable firewall in order to allow the download.
I will try to understand why this situation.a