Can I upload a sketch OTA (Over the Air) using Arduino IOT Cloud with Portenta H7 and Portenta Vision-Ethernet Shield via Ethernet cable (NOT WIFI) on different networks?
I am trying to upload a sketch from my house to a production factory where a Portenta H7 is located and transmitting information via ethernet to a webserver. I could send the characters of a new sketch via ethernet but I don't know how to make this to work as the new program in execution replacing the current code running.
How could I upload OTA in the same conditions as I mentioned in the previous post with Arduino GIGA R1 by ethernet?
I am having trouble understanding how to upload a '.ota' file to an url which I have to code in the "ota_url" variable. How do I get that url, is it always the same for everyone who does OTA updates with GIGA R1?
I have also compiled the example OTA_Qspi_Flash.ino in Arduino_Portenta_OTA.h library and I get the following log:
Attempting to connect to 'MY-WIFI'
You're connected to 'MY-WIFI'
Initializing OTA storage
Error while mounting the filesystem. Err = -5
Arduino_Portenta_OTA::begin() failed with error code -3
I tried using ethernet example code:
/*
* This example demonstrates how to use to update the firmware of the Arduino Portenta H7 using
* a firmware image stored on the QSPI.
*
* Steps:
* 1) Create a sketch for the Portenta H7 and verify
* that it both compiles and works on a board.
* 2) In the IDE select: Sketch -> Export compiled Binary.
* 3) Create an OTA update file utilising the tools 'lzss.py' and 'bin2ota.py' stored in
* https://github.com/arduino-libraries/ArduinoIoTCloud/tree/master/extras/tools .
* A) ./lzss.py --encode SKETCH.bin SKETCH.lzss
* B) ./bin2ota.py PORTENTA_H7_M7 SKETCH.lzss SKETCH.ota
* 4) Upload the OTA file to a network reachable location, e.g. OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota
* has been uploaded to: http://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota
* 5) Perform an OTA update via steps outlined below.
*/
/******************************************************************************
* INCLUDE
******************************************************************************/
#include <Arduino_Portenta_OTA.h>
#include <Ethernet.h>
/******************************************************************************
* CONSTANT
******************************************************************************/
/*#if defined(ARDUINO_OPTA)
static char const OTA_FILE_LOCATION[] = "http://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.OPTA.ota";
#elif defined(ARDUINO_PORTENTA_H7_M7)
static char const OTA_FILE_LOCATION[] = "http://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota";
#el*/
#if defined(ARDUINO_GIGA)
static char const OTA_FILE_LOCATION[] = "https://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.GIGA.ota";
#else
#error "Board not supported"
#endif
/******************************************************************************
* SETUP/LOOP
******************************************************************************/
void setup()
{
Serial.begin(115200);
while (!Serial) {}
while (Ethernet.linkStatus() == LinkOFF)
{
Serial.println("Attempting to connect to the network ...");
Ethernet.begin();
}
Serial.println("Connected");
Arduino_Portenta_OTA_QSPI ota(QSPI_FLASH_FATFS_MBR, 2);
Arduino_Portenta_OTA::Error ota_err = Arduino_Portenta_OTA::Error::None;
if (!ota.isOtaCapable())
{
Serial.println("Higher version bootloader required to perform OTA.");
Serial.println("Please update the bootloader.");
Serial.println("File -> Examples -> STM32H747_System -> STM32H747_manageBootloader");
return;
}
Serial.println("Initializing OTA storage");
if ((ota_err = ota.begin()) != Arduino_Portenta_OTA::Error::None)
{
Serial.print ("Arduino_Portenta_OTA::begin() failed with error code ");
Serial.println((int)ota_err);
return;
}
Serial.println("Starting download to QSPI ...");
int const ota_download = ota.download(OTA_FILE_LOCATION, false /* is_https */);
if (ota_download <= 0)
{
Serial.print ("Arduino_Portenta_OTA_QSPI::download failed with error code ");
Serial.println(ota_download);
return;
}
Serial.print (ota_download);
Serial.println(" bytes stored.");
Serial.println("Decompressing LZSS compressed file ...");
int const ota_decompress = ota.decompress();
if (ota_decompress < 0)
{
Serial.print("Arduino_Portenta_OTA_QSPI::decompress() failed with error code");
Serial.println(ota_decompress);
return;
}
Serial.print(ota_decompress);
Serial.println(" bytes decompressed.");
Serial.println("Storing parameters for firmware update in bootloader accessible non-volatile memory ...");
if ((ota_err = ota.update()) != Arduino_Portenta_OTA::Error::None)
{
Serial.print ("ota.update() failed with error code ");
Serial.println((int)ota_err);
return;
}
Serial.println("Performing a reset after which the bootloader will update the firmware.");
Serial.println("Hint: Board LED will blink Red-Blue-Green.");
delay(1000); /* Make sure the serial message gets out before the reset. */
ota.reset();
}
void loop()
{
}
And get the following error:
C:\Users\usuario\Desktop\JUAN\Empresa Ignacio\Scripts Arduino\OTA_Qspi_Flash_Ethernet\OTA_Qspi_Flash_Ethernet.ino: In function 'void setup()':
C:\Users\usuario\Desktop\JUAN\Empresa Ignacio\Scripts Arduino\OTA_Qspi_Flash_Ethernet\OTA_Qspi_Flash_Ethernet.ino:52:20: error: no matching function for call to 'EthernetClass::begin()'
Ethernet.begin();
^
In file included from C:\Users\usuario\Desktop\JUAN\Empresa Ignacio\Scripts Arduino\OTA_Qspi_Flash_Ethernet\OTA_Qspi_Flash_Ethernet.ino:24:0:
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:82:13: note: candidate: static int EthernetClass::begin(uint8_t*, long unsigned int, long unsigned int)
static int begin(uint8_t *mac, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
^~~~~
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:82:13: note: candidate expects 3 arguments, 0 provided
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:88:14: note: candidate: static void EthernetClass::begin(uint8_t*, arduino::IPAddress)
static void begin(uint8_t *mac, IPAddress ip);
^~~~~
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:88:14: note: candidate expects 2 arguments, 0 provided
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:89:14: note: candidate: static void EthernetClass::begin(uint8_t*, arduino::IPAddress, arduino::IPAddress)
static void begin(uint8_t *mac, IPAddress ip, IPAddress dns);
^~~~~
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:89:14: note: candidate expects 3 arguments, 0 provided
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:90:14: note: candidate: static void EthernetClass::begin(uint8_t*, arduino::IPAddress, arduino::IPAddress, arduino::IPAddress)
static void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway);
^~~~~
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:90:14: note: candidate expects 4 arguments, 0 provided
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:91:14: note: candidate: static void EthernetClass::begin(uint8_t*, arduino::IPAddress, arduino::IPAddress, arduino::IPAddress, arduino::IPAddress)
static void begin(uint8_t *mac, IPAddress ip, IPAddress dns, IPAddress gateway, IPAddress subnet);
^~~~~
C:\Users\usuario\AppData\Local\Arduino15\libraries\Ethernet\src/Ethernet.h:91:14: note: candidate expects 5 arguments, 0 provided
exit status 1
Compilation error: no matching function for call to 'EthernetClass::begin()'