Hello,
As the title suggests, I cannot get PlatformIO to upload my firmware OTA to my ESP32 regardless of the settings I have changed. I have, however, been able to flash the ESP32 OTA when I use the “OTAWebUpdater” example from the ArduinoOTA library. This leads me to believe something is wrong with the uploading/flashing process on my PC/PlatformIO side.
The error I get when uploading via the espota protocol is:
Configuring upload protocol...
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = espota
Uploading .pio\build\esp32-s3-devkitc-1\firmware.bin
00:51:59 [DEBUG]: Options: {'esp_ip': '192.168.12.169', 'host_ip': '0.0.0.0', 'esp_port': 3232, 'host_port': 29312, 'auth': '', 'image': '.pio\\build\\esp32-s3-devkitc-1\\firmware.bin', 'spiffs': False, 'debug': True, 'progress': True, 'timeout': 10}
00:51:59 [INFO]: Starting on 0.0.0.0:29312
00:51:59 [INFO]: Upload size: 762304
Sending invitation to 192.168.12.169 ..........
00:53:39 [ERROR]: No response from the ESP
*** [upload] Error 1
I’ve dug through as many forum posts as I could to remedy this. I have disabled my firewall and tried many other changes to no avail. Are there some other settings I need to change/enable to make the OTA upload work? I’m surprised it works with the OTAWebUpdater example, but not with the BasicOTA example.
Modified BasicOTA (does not work):
#include <ESPmDNS.h>
#include <FastLED.h>
#include <WiFi.h>
#include <WiFiUdp.h>
const char* ssid = "BenjaminWifi";
const char* password = "megafart";
CRGB leds[1];
bool LEDsOn = true;
unsigned long lastTime = millis();
void setup() {
Serial.begin(115200);
Serial.println("Booting");
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("Connection Failed! Rebooting...");
delay(5000);
ESP.restart();
}
// Port defaults to 3232
// ArduinoOTA.setPort(3232);
// Hostname defaults to esp3232-[MAC]
// ArduinoOTA.setHostname("myesp32");
// No authentication by default
// ArduinoOTA.setPassword("admin");
// Password can be set with it's md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
ArduinoOTA
.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = "sketch";
else // U_SPIFFS
type = "filesystem";
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR)
Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR)
Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR)
Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR)
Serial.println("Receive Failed");
else if (error == OTA_END_ERROR)
Serial.println("End Failed");
});
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
FastLED.addLeds<NEOPIXEL, 38>(leds, 1);
}
void loop() {
ArduinoOTA.handle();
if(millis() - lastTime > 1000){
lastTime = millis();
if(LEDsOn){
leds[0] = CRGB(0x80, 0x00, 0x00);
Serial.println("Led on");
LEDsOn = false;
}else{
leds[0] = CRGB(0x00, 0x00, 0x00);
Serial.println("Led off");
LEDsOn = true;
}
}
FastLED.show();
}
Platform.ini file:
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
board_build.flash_mode = opi
lib_deps =
arduino-libraries/NTPClient@^3.2.1
fastled/FastLED@^3.6.0
upload_protocol = espota
upload_port = 192.168.12.169
Hi @benjamin.a.molnar
I made a test and have no issues.
Please check that the trailing ` is just a copy and paste error and is not inside your platformio.ini
Please also check that the IP address matches the address on the serial monitor.
Hello,
Yes the ` was frome me messing with markdown and isn’t in the actial project. The IP is correct. I see the device on my wifi network with that IP and can ping it with my PC on the same network. However OTA flashing yields no response from the device. I have no idea why.
Pinging the ESP is not the problem.
The ESP must also be able to reach your PC!
The procedure is as follows:
- The PC starts a service on a free port (here: 29312)
- The PC sends an invitation to the ESP on port 3232 and submitts its address and the current download port
- The ESP connects to the submitted address and port and starts downloading the new firmware.
It appears that something in the second/third step is not completing correctly. Is there a good way to troubleshoot these steps specifically so I can see where the process is dropped?
Maybe running wireshark and capturing the traffic could help to see what’s going on.
I suspect something on your PC is blocking traffic.