Need Help! ESP32+LAN8710+Mega2560 OTA update using Serial3 #254
Replies: 4 comments 6 replies
-
the Advanced examples have
|
Beta Was this translation helpful? Give feedback.
-
Hello, byte b; if (length > 0) { Serial.println("Sketch update apply and reset."); |
Beta Was this translation helpful? Give feedback.
-
did you use bin file? (without bootloader of course. only ISP can flash a hex with bootloader) |
Beta Was this translation helpful? Give feedback.
-
if you do a manual reset after OTA update, does the sketch start? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a project that contains esp32+mega2560+lan8710. A code runs on the esp32 that does certain things, and another code runs on the Mega, and the two boards communicate with each other on Serial2(Esp32) and Serial3(Mega2560). I need to update Mega using esp32.
On Esp32 I use these 2 functions to download the firmware for Mega2560 from my server, store in SPIFFS and then send over Serial2 to InternalStorage of Mega.
On Mega2560:
#include <ArduinoOTA.h>
#define SERIAL_PORT Serial3
void setup() {
SERIAL_PORT.begin(115200); // Ensure this matches the baud rate of your ESP32
Serial.begin(115200);
}
void loop() {
if (SERIAL_PORT.available()) {
String command = SERIAL_PORT.readStringUntil('\n');
if (command == "START") {
size_t firmwareSize = SERIAL_PORT.parseInt(); // Read firmware size
if (firmwareSize > 0) {
Serial.println("Receiving firmware update");
receiveFirmware(firmwareSize);
}
}
}
}
void receiveFirmware(size_t length) {
if (!InternalStorage.open(length)) {
Serial.println("There is not enough space to store the update. Can't continue with update.");
return;
}
byte b;
while (length > 0) {
if (!SERIAL_PORT.readBytes(&b, 1)) { // Reading a byte with timeout
break;
}
InternalStorage.write(b);
length--;
}
InternalStorage.close();
if (length > 0) {
Serial.print("Timeout downloading update file at ");
Serial.print(length);
Serial.println(" bytes. Can't continue with update.");
return;
}
Serial.println("Sketch update apply and reset.");
Serial.flush();
InternalStorage.apply(); // This doesn't return
}
The problem is when I compile the code I get this error:
FQBN: my_boards:avr:mega
Using board 'mega' from platform in folder: C:\Users....\Documents\Arduino\hardware\my_boards\avr
...........
:\Users...\Documents\Arduino\libraries\ArduinoOTA\src/ArduinoOTA.h:141:22: error: 'WiFiServer' was not declared in this scope
ArduinoOTAMdnsClass <WiFiServer, WiFiClient, WiFiUDP> ArduinoOTA;
^~~~~~~~~~
c:\Users.......\Documents\Arduino\libraries\ArduinoOTA\src/ArduinoOTA.h:141:22: note: suggested alternative: 'WiFiDrv'
ArduinoOTAMdnsClass <WiFiServer, WiFiClient, WiFiUDP> ArduinoOTA;
^~~~~~~~~~
WiFiDrv
c:\Users......\Documents\Arduino\libraries\ArduinoOTA\src/ArduinoOTA.h:141:34: error: 'WiFiClient' was not declared in this scope
ArduinoOTAMdnsClass <WiFiServer, WiFiClient, WiFiUDP> ArduinoOTA;
^~~~~~~~~~
c:\Users.......\Documents\Arduino\libraries\ArduinoOTA\src/ArduinoOTA.h:141:34: note: suggested alternative: 'DNSClient'
ArduinoOTAMdnsClass <WiFiServer, WiFiClient, WiFiUDP> ArduinoOTA;
^~~~~~~~~~
DNSClient
c:\Users........\Documents\Arduino\libraries\ArduinoOTA\src/ArduinoOTA.h:141:53: error: template argument 1 is invalid
ArduinoOTAMdnsClass <WiFiServer, WiFiClient, WiFiUDP> ArduinoOTA;
^
c:\Users.......\Documents\Arduino\libraries\ArduinoOTA\src/ArduinoOTA.h:141:53: error: template argument 2 is invalid
In my code I don't need WiFiServer, WiFiClient, WiFiUDP, but the library requires them.
Beta Was this translation helpful? Give feedback.
All reactions