arduino-pico/libraries/PicoOTA/examples/OTAfromFile/OTAfromFile.ino
Earle F. Philhower, III 2063a2d23d
Enable OTA support for RP2350 (#2472)
The RP2350 has a different blob header requirement to identify a working
image.  Ensure that header is present in the OTA loader.

Update the PicoOTA examples for the 2350
2024-09-17 15:05:42 -07:00

40 lines
1.1 KiB
C++

// This example overwrites itself with a serial blinker sketch using OTA
// In general, you will get a file from the Internet, over a serial port, etc.
// and not include it in a header like we do here for simplicity.
//
// You need to have at least 256K of filesystem configured in
// Tools->Flash Size
//
// Released to the public domain August 2022 by Earle F. Philhower, III
#include <PicoOTA.h>
#include <LittleFS.h>
#include "blink_100_1000_rp2040.h"
#include "blink_500_500_rp2350.h"
void setup() {
Serial.begin(115200);
delay(5000);
Serial.printf("Writing OTA image of blinker...");
LittleFS.begin();
File f = LittleFS.open("blink.bin", "w");
if (sizeof(blink) != f.write(blink, sizeof(blink))) {
Serial.printf("Unable to write OTA binary. Is the filesystem size set?\n");
return;
}
f.close();
Serial.printf("done\n\n");
Serial.printf("Programming OTA commands...");
picoOTA.begin();
picoOTA.addFile("blink.bin");
picoOTA.commit();
LittleFS.end();
Serial.printf("done\n\n");
Serial.printf("Rebooting in 5 seconds, should begin blinker instead of this app...\n");
delay(5000);
rp2040.reboot();
}
void loop() {
}