Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By spflmf
#46228 Need some pointers on how I can diagnose the problem I am getting using OTA updates on a ESP-12F. It was working fine with an ESP-01 but using the same code on the 12F fails.

Im using 1.6.8 IDE configured as Generic ESP8266 Module, flash size 4M (1M SPIFFS), Debug port: serial, Debug Level: OTA + Updater, and the port set to the 12F net client name.

I've also tried with different smaller flash sizes until it eventually reports not enough space.

When I attempt an update it fails instantly, the serial console shows ...

sleep disable
[begin] roundedSize: 0x0003E000 (253952)
[begin] updateEndAddress: 0x00300000 (3145728)
[begin] currentSketchSize: 0x0003E000 (253952)
[begin] _startAddress: 0x002C2000 (2891776)
[begin] _currentAddress: 0x002C2000 (2891776)
[begin] _size: 0x0003D480 (251008)
OTA Start
ERROR[1]: Flash Write Failed
premature end: res:1, pos:251008/251008
OTA Error[4]: End Failed
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
LmacRxBlk:1
ERROR[1]: Flash Write Failed

The code I'm using ....
Code: Select all#define OTA_DEBUG true

#include <Wire.h>
#include <ESP8266WiFi.h>
#include <ArduinoOTA.h>

const char* ssid = "**SSID**";
const char* password = "**SSID PASSWORD **";

WiFiClient espClient;

#define HOSTNAME "SENSOR "
String esphostname(HOSTNAME);

void setup() {
  pinMode(BUILTIN_LED, OUTPUT);     // Initialize the BUILTIN_LED pin as an output
  Serial.begin(115200);

  esphostname += String(ESP.getChipId(), HEX);
  setup_wifi();
 
  ArduinoOTA.setHostname((const char *)esphostname.c_str());
  ArduinoOTA.onStart([]() {
    Serial.println("OTA Start");
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nOTA End");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("OTA Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("OTA 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();
}

void setup_wifi() {
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.hostname(esphostname);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {
  ArduinoOTA.handle();
  yield();
}


Any suggestions gratefully recieved.
Thanks Steve