Skip to content

OTA stuck when upload 8% - 44% progress #6718

Closed
@rashn

Description

@rashn

Platform

  • ESP8266MOD (ESP-07)
  • Visual Studio Code
  • PlatformIO (ArduinoOTA)
  • iMac 27, Mac OS Catalina

Settings in IDE

  • Module: ESP8266MOD
  • Flash Mode: OTA
  • Flash Size: 1MB
  • Upload Using: OTA

Problem Description

Each time of upload stuck on 43-44% without any reasons (some times 3-8%, but often 43%).
In the serial i see error [4] - OTA_END_ERROR

MCVE Sketch

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <elapsedMillis.h>
#include <SoftwareSerial.h>

// флаг процесса обновления устройства
byte  upDateMe = 0;

int isConnected = 0 ;
const char* ssid = "newrn";
const char* password = "kurban12lam";
elapsedMillis timeElapsed;
byte pina = 0;
void setup() {
  Serial.begin(115200);
  Serial.println("Booting");  //  "Загрузка"
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  pinMode(0, OUTPUT);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    //  "Соединиться не удалось! Перезагрузка..."
    delay(5000);
    ESP.restart();
  }
  delay(3000);
  
  ArduinoOTA.setHostname("Elekrik31-2");

   ArduinoOTA.onStart([]() {
    Serial.println("Start OTA");  //  "Начало OTA-апдейта"
       upDateMe = 1;

  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd OTA");  //  "Завершение OTA-апдейта"
      upDateMe = 0;
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.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");
    //  "Ошибка при начале OTA-апдейта"
    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");
    //  "Ошибка при завершении OTA-апдейта"

      upDateMe = 0;
  });
  ArduinoOTA.begin();
  Serial.println("Ready");  //  "Готово"
  Serial.print("IP address: ");  //  "IP-адрес: "
  Serial.println(WiFi.localIP());
}

void loop() {
  ArduinoOTA.handle();

  if (upDateMe == 0)
  {
    if (timeElapsed > 550)
    {
      timeElapsed = 0;
      pina ^= 1;
      digitalWrite(0, pina * 255);
    // Serial.println("Reba");
    }
  }
}

void onConnected(const WiFiEventStationModeConnected& event) {
  Serial.println ( "Connected to AP." );
  isConnected = 1;

}

void onDisconnect(const WiFiEventStationModeDisconnected& event) {
  Serial.println ( "WiFi On Disconnect." );
  isConnected = 0;

}

void onGotIP(const WiFiEventStationModeGotIP& event) {
  Serial.print ( "Got Ip: " );
  isConnected = 2;

  Serial.println(WiFi.localIP());
}

PLATFORMIO INI

;PlatformIO Project Configuration 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
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = esp07

[common_env_data]
build_flags =
    -D VERSION=1.2.3
    -D DEBUG=0

[env:esp07]
platform = espressif8266
board = esp07
framework = arduino
build_flags = -Wl,-Teagle.flash.1m.ld ;eagle.flash.1m128.ld
; OTA
build_flags = -DDEBUG_ESP_OTA

upload_port = 192.168.1.101 ; Elekrik31-2.local
upload_protocol = espota
upload_speed = 921600

upload_flags = --host_ip=192.168.1.179
upload_flags = --port=8266

monitor_port = /dev/cu.wchusbserial1410
monitor_speed = 115200

targets = upload 

Debug Messages

Ready
IP address: 192.168.1.101
Start
Progress: 0%
Progress: 0%
Progress: 0%
Progress: 1%
Error[4]: End Failed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions