|
| 1 | +/* |
| 2 | + * This example demonstrates how to use to update the firmware of the Arduino Portenta C33 using |
| 3 | + * a firmware image stored on the QSPI. |
| 4 | + * |
| 5 | + * Steps: |
| 6 | + * 1) Create a sketch for the Portenta C33 and verify |
| 7 | + * that it both compiles and works on a board. |
| 8 | + * 2) In the IDE select: Sketch -> Export compiled Binary. |
| 9 | + * 3) Create an OTA update file utilising the tools 'lzss.py' and 'bin2ota.py' stored in |
| 10 | + * https://github.com/arduino-libraries/ArduinoIoTCloud/tree/master/extras/tools . |
| 11 | + * A) ./lzss.py --encode SKETCH.bin SKETCH.lzss |
| 12 | + * B) ./bin2ota.py PORTENTA_C33 SKETCH.lzss SKETCH.ota |
| 13 | + * 4) Upload the OTA file to a network reachable location, e.g. OTAUsage.ino.PORTENTA_C33.ota |
| 14 | + * has been uploaded to: http://downloads.arduino.cc/ota/OTAUsage.ino.PORTENTA_C33.ota |
| 15 | + * 5) Perform an OTA update via steps outlined below. |
| 16 | + */ |
| 17 | + |
| 18 | +/****************************************************************************** |
| 19 | + * INCLUDE |
| 20 | + ******************************************************************************/ |
| 21 | + |
| 22 | +#include <SFU.h> |
| 23 | +#include <WiFiC3.h> |
| 24 | +#include <Arduino_DebugUtils.h> |
| 25 | +#include "arduino_secrets.h" |
| 26 | + |
| 27 | +/****************************************************************************** |
| 28 | + * CONSTANT |
| 29 | + ******************************************************************************/ |
| 30 | + |
| 31 | +/* Please enter your sensitive data in the Secret tab/arduino_secrets.h */ |
| 32 | +static char const SSID[] = SECRET_SSID; /* your network SSID (name) */ |
| 33 | +static char const PASS[] = SECRET_PASS; /* your network password (use for WPA, or use as key for WEP) */ |
| 34 | + |
| 35 | +#if defined(ARDUINO_PORTENTA_C33) |
| 36 | +static char const OTA_FILE_LOCATION[] = "http://downloads.arduino.cc/ota/OTAUsage.ino.PORTENTA_C33.ota"; |
| 37 | +#else |
| 38 | +#error "Board not supported" |
| 39 | +#endif |
| 40 | + |
| 41 | +/****************************************************************************** |
| 42 | + * SETUP/LOOP |
| 43 | + ******************************************************************************/ |
| 44 | + |
| 45 | +void setup() |
| 46 | +{ |
| 47 | + Serial.begin(115200); |
| 48 | + while (!Serial) {} |
| 49 | + |
| 50 | + Debug.setDebugLevel(DBG_VERBOSE); |
| 51 | + |
| 52 | + if (WiFi.status() == WL_NO_SHIELD) |
| 53 | + { |
| 54 | + Serial.println("Communication with WiFi module failed!"); |
| 55 | + return; |
| 56 | + } |
| 57 | + |
| 58 | + int status = WL_IDLE_STATUS; |
| 59 | + while (status != WL_CONNECTED) |
| 60 | + { |
| 61 | + Serial.print ("Attempting to connect to '"); |
| 62 | + Serial.print (SSID); |
| 63 | + Serial.println("'"); |
| 64 | + status = WiFi.begin(SSID, PASS); |
| 65 | + delay(10000); |
| 66 | + } |
| 67 | + Serial.print ("You're connected to '"); |
| 68 | + Serial.print (WiFi.SSID()); |
| 69 | + Serial.println("'"); |
| 70 | + |
| 71 | + SFU::begin(); |
| 72 | + |
| 73 | + SFU::download(OTA_FILE_LOCATION); |
| 74 | + |
| 75 | + SFU::apply(); |
| 76 | +} |
| 77 | + |
| 78 | +void loop() |
| 79 | +{ |
| 80 | + |
| 81 | +} |
0 commit comments