Skip to content

Commit 7110ec6

Browse files
committed
examples/OTA_SD_Portenta - adding meaningful comments and error outputs.
1 parent 6612768 commit 7110ec6

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

examples/OTA_SD_Portenta/OTA_SD_Portenta.ino

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,28 @@ void setup()
1313

1414
Serial.println("*****OTA from SD*****");
1515
Arduino_OTA_Portenta_SD ota(SD_OFFSET, 10240);
16-
ota.begin();
16+
Arduino_OTA_Portenta::Error ota_err = Arduino_OTA_Portenta::Error::None;
17+
18+
Serial.println("Initializing OTA storage");
19+
if ((ota_err = ota.begin()) != Arduino_OTA_Portenta::Error::None)
20+
{
21+
Serial.print ("ota.begin() failed with error code ");
22+
Serial.println((int)ota_err);
23+
return;
24+
}
25+
26+
/* This functions set's the precise length of update binary, in this case of OTA_Usage_Portenta.ino.PORTENTA_H7_M7.bin */
1727
ota.setUpdateLen(131728);
1828

19-
pinMode(LEDB, OUTPUT);
20-
digitalWrite(LEDB, LOW);
21-
delay(5000);
22-
digitalWrite(LEDB, HIGH);
29+
Serial.println("Storing parameters for firmware update in bootloader accessible non-volatile memory");
30+
if ((ota_err = ota.update()) != Arduino_OTA_Portenta::Error::None)
31+
{
32+
Serial.print ("ota.update() failed with error code ");
33+
Serial.println((int)ota_err);
34+
return;
35+
}
2336

24-
ota.update();
37+
Serial.println("Performing a reset after which the bootloader will update the firmware.");
2538
ota.reset();
2639
}
2740

0 commit comments

Comments
 (0)