Skip to content

OTAWebUpdater speed upload  #1566

@rel1ct

Description

@rel1ct

Hardware:

Board: ESP32 Dev Module
Core Installation/update date: 27/06/2018
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 921600

Description:

69.56 Kbit/s is normal? dial up??

Sketch:

#include "WiFi.h"
#include "WebServer.h"
#include "Update.h"
const char* ssid = "Update_Web";
const char* pass = "1234567890";
WebServer server(80);
char* serverIndex = "<form method='POST' action='/update' enctype='multipart/form-data'>"
                    "<input type='file' name='update'><br><br>"
                    "<input type='submit' value='Update'>"
                    "</form>";
unsigned long t_start,t_stop;
void setup(void) {
  Serial.begin(115200);
  Serial.println();
  Serial.println(ESP.getSdkVersion());
  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid, pass);
  server.on("/serverIndex", HTTP_GET, []() {
    server.sendHeader("Connection", "close");
    server.send(200, "text/html", serverIndex);
  });
  server.on("/update", HTTP_POST, []() {
    server.sendHeader("Connection", "close");
    server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
    delay(500);  // else server not be in time send "FAIL" or "OK"
    ESP.restart();
  }, []() {
    HTTPUpload& upload = server.upload();
    if (upload.status == UPLOAD_FILE_START) {
      t_start = millis();
      Serial.printf("Update: %s\n", upload.filename.c_str());
      if (!Update.begin(UPDATE_SIZE_UNKNOWN)) {
        Update.printError(Serial);
      }
    } else if (upload.status == UPLOAD_FILE_WRITE) {
      if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
        Update.printError(Serial);
      }
    } else if (upload.status == UPLOAD_FILE_END) {
      if (Update.end(true)) {
        t_stop = millis();
        Serial.print("Time UPLOAD: "); Serial.print((t_stop - t_start) / 1000); Serial.println(" sec.");
        Serial.print("Speed UPLOAD: "); Serial.print((float(upload.totalSize / 1024)*8) / float((t_stop - t_start) / 1000)); Serial.println(" Kbit/s");
        Serial.printf("Update Success: %u bytes\nRebooting...\n", upload.totalSize);
      } else {
        Update.printError(Serial);
      }
    }
  });
  server.begin();
}
void loop(void) {
  server.handleClient();
}

Debug Messages:

.....
v3.2-dev-39-gaaf12390
Update: test1.ino.esp32.bin
Time UPLOAD: 82 sec.
Speed UPLOAD: 69.56 Kbit/s
Update Success: 730528 bytes
.....

Wireshark file esp32.pcapng

P.S.
especially for me-no-dev, please repeat your experiment at the last SDK.
library ESPAsyncWebServer

.....
v3.2-dev-39-gaaf12390
Update start: test2.ino.esp32.bin
Time UPLOAD: 10.82 sec.
Speed UPLOAD: 529.28 Kbit/s
Update Success: 733104 bytes
.....

old SDK

.....
v3.1-dev-661-gf586f5e6
Update start: test2.ino.esp32.bin
Time UPLOAD: 0.77 sec.
Speed UPLOAD: 6439.53 Kbit/s
Update Success: 634864 bytes
.....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions