From e6d5ca87bb2c9bea2d006cfb6e3c04357fcbb91f Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 15 Feb 2021 09:58:09 +0100 Subject: [PATCH 1/2] Upgrade README with a minimum example code. --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4432662..cc32e1e 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,51 @@ Arduino_Portenta_OTA [![Arduino Lint](https://github.com/arduino-libraries/Arduino_Portenta_OTA/workflows/Arduino%20Lint/badge.svg)](https://github.com/arduino-libraries/Arduino_Portenta_OTA/actions?workflow=Arduino+Lint) [![Spell Check](https://github.com/arduino-libraries/Arduino_Portenta_OTA/workflows/Spell%20Check/badge.svg)](https://github.com/arduino-libraries/Arduino_Portenta_OTA/actions?workflow=Spell+Check) -OTA on the Arduino Portenta. +This library allows to perform OTA (Over-The-Air) firmware update for the Arduino Portenta H7. OTA binaries are downloaded via WiFi and stored on a SD card or on the Portenta H7's QSPI flash storage. Next all information relevant to the firmware update is stored in non-volatile memory. After a reset the Portenta H7 bootloader is accessing this information and uses it for performing the firmware update. ### Example ```C++ -/* TODO */ +#include +#include +#include "arduino_secrets.h" +/* ... */ +void setup() +{ + if (WiFi.status() == WL_NO_SHIELD) + return; + + int status = WL_IDLE_STATUS; + while (status != WL_CONNECTED) + { + status = WiFi.begin(SSID, PASS); + delay(10000); + } + + Arduino_Portenta_OTA_QSPI ota(QSPI_FLASH_FATFS_MBR, 2); + Arduino_Portenta_OTA::Error ota_err = Arduino_Portenta_OTA::Error::None; + + if (!ota.isOtaCapable()) + return; + + if ((ota_err = ota.begin()) != Arduino_Portenta_OTA::Error::None) + return; + + int const ota_download = ota.download("http://downloads.arduino.cc/ota/OTA_Usage_Portenta.ino.PORTENTA_H7_M7.ota", false /* is_https */); + if (ota_download <= 0) + return; + + int const ota_decompress = ota.decompress(); + if (ota_decompress < 0) + return; + + if ((ota_err = ota.update()) != Arduino_Portenta_OTA::Error::None) + return; + + ota.reset(); +} + +void loop() +{ + +} ``` From 0ab63d6dd1bdeadf4d57671d147c45158029df0c Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Mon, 15 Feb 2021 10:08:06 +0100 Subject: [PATCH 2/2] Update README.md Co-authored-by: per1234 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc32e1e..5640e59 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Arduino_Portenta_OTA [![Arduino Lint](https://github.com/arduino-libraries/Arduino_Portenta_OTA/workflows/Arduino%20Lint/badge.svg)](https://github.com/arduino-libraries/Arduino_Portenta_OTA/actions?workflow=Arduino+Lint) [![Spell Check](https://github.com/arduino-libraries/Arduino_Portenta_OTA/workflows/Spell%20Check/badge.svg)](https://github.com/arduino-libraries/Arduino_Portenta_OTA/actions?workflow=Spell+Check) -This library allows to perform OTA (Over-The-Air) firmware update for the Arduino Portenta H7. OTA binaries are downloaded via WiFi and stored on a SD card or on the Portenta H7's QSPI flash storage. Next all information relevant to the firmware update is stored in non-volatile memory. After a reset the Portenta H7 bootloader is accessing this information and uses it for performing the firmware update. +This library allows OTA (Over-The-Air) firmware updates for the Arduino Portenta H7. OTA binaries are downloaded via WiFi and stored on a SD card or on the Portenta H7's QSPI flash storage. Next, all information relevant to the firmware update is stored in non-volatile memory. After a reset the Portenta H7 bootloader accesses this information and uses it to perform the firmware update. ### Example ```C++