Hardware: ESP-12E
Core Version: latest git version
Im trying OTA Update with latest git version. It worked a while ago, since it didnt work anymore, i upgraded to latest git version, but the problem still exists. Maybe i have too much flash used, but the compiler says this:
Sketch uses 327315 bytes (31%) of program storage space. Maximum is 1044464 bytes.
Global variables use 37496 bytes (45%) of dynamic memory, leaving 44424 bytes for local variables. Maximum is 81920 bytes.
Uploading...................................................................................................................................................................................................................................An error occurred while uploading the sketch
.
20:58:22 [ERROR]: 10721608536160853653653653653621
So the upload starts, but fails after some time. Dont know whats going on here -.-
Module: Generic ESP8266 Module
Flash Size: 4MB/1MB
CPU Frequency: 80Mhz
Flash Mode: qio
Flash Frequency: 40Mhz
Upload Using: OTA
Reset Method: ck
/***************/
/* Includes /
/****************/
/***************/
/* General /
/****************/
bool firstInit = true;
// Struct for Setudata and file position
struct setupdata {
char data[25];
size_t pos;
};
setupdata wifimode, ssid, password;
/***************/
/* LED defines /
/****************/
bool LED_state = false, last_state = false, LED_req = true;
int32_t LED_color_RGB = 000000, last_color = LED_color_RGB;
colorRgbw rgbw_a {0,0,0,0}, rgbw_cur = rgbw_a;
/***************/
/* Hilfsfunktionen /
/****************/
unsigned long hexToDec(String hexString);
void handleColors();
/***************/
/* Web Server Settings /
/****************/
ESP8266WebServer server ( 80 );
ESP8266HTTPUpdateServer updateserver;
WiFiServer otaserver(8266);
MDNSResponder mdns;
const char* ap_ssid = "ESP-Wifi RGB Dimmer -";
const char* ap_password = "12345678";
const char* ap_mdns = "dimmer"; //dimmer.local
const char* host = "Wifi-RGB-Dimmer";
//char ssid[25];
//char password[25];
IPAddress ip(192,168,1,201);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
// Variables
long wiFiConnTime = 0; // measure time till wifi connect success
int wifiConnectCounter, loopCounter, httpConnectCounter = 0;
// Create an WiFiClient object, here called "ethClient":
WiFiClient ethClient;
void startAP() {
WiFi.softAP(ap_ssid, ap_password);
}
void startWiFi() {
String tmp;
File setup = SPIFFS.open("/wifi_settings.txt", "r");
wifimode.pos = setup.position();
tmp = setup.readStringUntil('\n');
tmp.toCharArray(wifimode.data, tmp.length());
ssid.pos = setup.position();
tmp = setup.readStringUntil('\n');
tmp.toCharArray(ssid.data, tmp.length());
password.pos = setup.position();
tmp = setup.readStringUntil('\n');
tmp.toCharArray(password.data, tmp.length()+1);
setup.close();
#if defined DEBUG_MODE
Serial.println(wifimode.data);
Serial.println(ssid.data);
Serial.println(password.data);
#endif
//WiFi.mode(WIFI_STA);
WiFi.begin(ssid.data, password.data);
while(WiFi.status() != WL_CONNECTED) {
analogWrite(R,0);
analogWrite(G,0);
analogWrite(B,0);
analogWrite(W,0);
for(int i=0;i<=3;i++) {
analogWrite(G,1023);
delay(200);
analogWrite(G,0);
delay(200);
}
analogWrite(R,1023);
analogWrite(G,1023);
delay(500);
wifiConnectCounter++;
Serial.print(".");
if(wifiConnectCounter >100) {
for(int i=0;i<=3;i++) {
analogWrite(G,0);
analogWrite(R,1023);
delay(200);
analogWrite(R,0);
delay(200);
}
Serial.println("No WiFi found, trying again in 5 seconds.");
delay(5);
}
Serial.print(".");
}
IPAddress adresse = WiFi.localIP();
Serial.println(adresse);
}
void startServer() {
if (mdns.begin(ap_mdns, WiFi.localIP())) {
Serial.println("MDNS responder started");
}
updateserver.setup(&server);
//server.serveStatic("/", SPIFFS, "/index.html");
//server.serveStatic("/index.html", SPIFFS, "/index.html");
/*
server.serveStatic("css/bootstrap.min.css", SPIFFS, "/css/bootstrap.min.css");
server.serveStatic("css/wheelcolorpicker.css", SPIFFS, "/css/wheelcolorpicker.css");
server.serveStatic("/js/jquery.min.js", SPIFFS, "/js/jquery.min.js");
server.serveStatic("/js/popper.min.js", SPIFFS, "/js/popper.min.js");
server.serveStatic("/js/bootstrap.min.js", SPIFFS, "/js/bootstrap.min.js");
server.serveStatic("/js/jquery.wheelcolorpicker-3.0.3.min.js", SPIFFS, "/js/jquery.wheelcolorpicker-3.0.3.min.js");
*/
//server.serveStatic("/css", SPIFFS, "/css");
//server.serveStatic("/js", SPIFFS, "/js");
server.onNotFound( { // If the client requests any URI
if (!handleFileRead(server.uri())) // send it if it exists
server.send(404, "text/plain", "404: Not Found"); // otherwise, respond with a 404 (Not Found) error
});
server.on("/color", handleColors);
server.on("/state", handleLEDstate);
server.on("/seqon", handleSequenceOn);
server.on("/seqoff", handleSequenceOff);
server.begin();
}
String getContentType(String filename){
if(filename.endsWith(".htm")) return "text/html";
else if(filename.endsWith(".html")) return "text/html";
else if(filename.endsWith(".css")) return "text/css";
else if(filename.endsWith(".js")) return "application/javascript";
else if(filename.endsWith(".png")) return "image/png";
else if(filename.endsWith(".gif")) return "image/gif";
else if(filename.endsWith(".jpg")) return "image/jpeg";
else if(filename.endsWith(".ico")) return "image/x-icon";
else if(filename.endsWith(".xml")) return "text/xml";
else if(filename.endsWith(".pdf")) return "application/x-pdf";
else if(filename.endsWith(".zip")) return "application/x-zip";
else if(filename.endsWith(".gz")) return "application/x-gzip";
return "text/plain";
}
bool handleFileRead(String path){ // send the right file to the client (if it exists)
Serial.println("handleFileRead: " + path);
if(path.endsWith("/")) path += "index.html"; // If a folder is requested, send the index file
String contentType = getContentType(path); // Get the MIME type
String pathWithGz = path + ".gz";
if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)){ // If the file exists, either as a compressed archive, or normal
if(SPIFFS.exists(pathWithGz)) // If there's a compressed version available
path += ".gz"; // Use the compressed version
File file = SPIFFS.open(path, "r"); // Open the file
size_t sent = server.streamFile(file, contentType); // Send it to the client
file.close(); // Close the file again
Serial.println(String("\tSent file: ") + path);
return true;
}
Serial.println(String("\tFile Not Found: ") + path);
return false; // If the file doesn't exist, return false
}
/***************/
/* Handle HTTP _GET Requests /
/****************/
void handleColors() { //Handle Color Wheel Color Selection
if(server.hasArg("rgb")) {
String color = server.arg("rgb");
LED_color_RGB = hexToDec(color);
Serial.println("GET Color: ");
Serial.print(color);
Serial.println("LED_color_RGB: ");
Serial.print(LED_color_RGB);
}
server.send(200, "text/html");
}
void handleLEDstate() {
if(server.hasArg("led")) {
String state = server.arg("led");
if(state == "1") {
LED_state = true;
}
if(state == "0") {
LED_state = false;
}
}
if(server.hasArg("rgb")) {
String color = server.arg("rgb");
LED_color_RGB = hexToDec(color);
}
server.send(200, "text/html");
}
uint16_t seqtiming, seqcnt;
uint32_t seqcolors[10];
bool seqstate = false;
void handleSequenceOn() {
String tmp;
if(server.hasArg("timing")) {
tmp = server.arg("timing");
seqtiming = tmp.toInt() * 1000;
Serial.print("Timing: ");
Serial.print(seqtiming/1000);
Serial.println(" Sec");
}
tmp = server.arg("seqcnt");
seqcnt = tmp.toInt();
for(int i=0;i
String tmpcol = server.arg(tmpseq);
seqcolors[i] = hexToDec(tmpcol);
Serial.print(tmpseq + ": ");
Serial.println(seqcolors[i]);
}
seqstate = true;
server.send(200, "text/html");
}
void handleSequenceOff() {
seqstate = false;
seqcnt = 0;
for(int i=0;i<10;i++) {
seqcolors[i] = 0;
}
server.send(200, "text/html");
}
/***************/
/* Configure update via WiFi/Arduino IDE /
/****************/
void startOTA() {
ArduinoOTA.onStart( {
Serial.println("Start");
});
ArduinoOTA.onEnd( {
Serial.println("\nEnd");
});
ArduinoOTA.onProgress( {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError( {
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();
}
/***************/
/* Handle LEDs /
/****************/
/****************
Timervariable f眉r eine Verz枚gerung.
Als alternative zu delay was die verarbeitung anh盲lt.
****************/
int timer = 0;
int EndTimer = 200;
void setup_LED() {
pinMode(R, OUTPUT);
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
pinMode(W, OUTPUT);
analogWrite(R,1024);
analogWrite(G,0);
analogWrite(B,0);
analogWrite(W,0);
delay(1000);
analogWrite(R,0);
analogWrite(G,1024);
analogWrite(B,0);
analogWrite(W,0);
delay(1000);
analogWrite(R,0);
analogWrite(G,0);
analogWrite(B,1024);
analogWrite(W,0);
delay(1000);
analogWrite(R,0);
analogWrite(G,0);
analogWrite(B,0);
analogWrite(W,1024);
delay(1000);
}
void RGB_to_int (uint32_t RGB_tmp) {
rgbw_a.red = RGB_tmp / 0x10000;
rgbw_a.green = (RGB_tmp /0x100) % 0x100;
rgbw_a.blue = RGB_tmp % 0x100;
rgbw_a.white = 0;
}
colorRgbw RGB_to_ESP (colorRgbw rgbw_tmp) {
float tmp;
tmp = rgbw_tmp.red;
tmp = (tmp * 1024) / 255;
rgbw_tmp.red = tmp;
tmp = rgbw_tmp.green;
tmp = (tmp * 1024) / 255;
rgbw_tmp.green = tmp;
tmp = rgbw_tmp.blue;
tmp = (tmp * 1024) / 255;
rgbw_tmp.blue = tmp;
tmp = rgbw_tmp.white;
tmp = (tmp * 1024) / 255;
rgbw_tmp.white = tmp;
return(rgbw_tmp);
}
void processLED() {
if(!(LED_state == last_state)) {
LED_req = true;
last_state = LED_state;
}
if(LED_state) {
if(!(LED_color_RGB == last_color)) {
last_color = LED_color_RGB;
RGB_to_int(LED_color_RGB);
rgbw_a = rgbToRgbwNew(rgbw_a.red,rgbw_a.green,rgbw_a.blue);
rgbw_a = RGB_to_ESP(rgbw_a);
#if defined DEBUG_MODE
Serial.println("New color values:");
Serial.print("R: ");
Serial.println(rgbw_a.red);
Serial.print("G: ");
Serial.println(rgbw_a.green);
Serial.print("b: ");
Serial.println(rgbw_a.blue);
Serial.print("W: ");
Serial.println(rgbw_a.white);
#endif
}
}
else {
rgbw_a = {0,0,0,0};
}
if (timer <= EndTimer) timer++;
else {
timer = 0;
if (rgbw_a.red < rgbw_cur.red) rgbw_cur.red--;
else if (rgbw_a.red > rgbw_cur.red) rgbw_cur.red++;
if (rgbw_a.green < rgbw_cur.green) rgbw_cur.green--;
else if (rgbw_a.green > rgbw_cur.green) rgbw_cur.green++;
if (rgbw_a.blue < rgbw_cur.blue) rgbw_cur.blue--;
else if (rgbw_a.blue > rgbw_cur.blue) rgbw_cur.blue++;
if (rgbw_a.white < rgbw_cur.white) rgbw_cur.white--;
else if (rgbw_a.white > rgbw_cur.white) rgbw_cur.white++;
}
analogWrite(R,rgbw_cur.red);
analogWrite(G,rgbw_cur.green);
analogWrite(B,rgbw_cur.blue);
analogWrite(W,rgbw_cur.white);
/* if(LED_state) {
digitalWrite(LED_Pin, HIGH);
last_state = true;
}
else {
digitalWrite(LED_Pin, LOW);
last_state = false;
}*/
}
unsigned long previousMillis = 0;
//int seqtiming, seqcnt;
//uint32_t seqcolors[10];
//bool seqstate = false;
void processSequence() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= seqtiming) {
static uint8_t seqno = 0;
previousMillis = currentMillis;
LED_color_RGB = seqcolors[seqno];
if(seqno++ > seqcnt) seqno = 0;
}
}
/***************/
/* Setup /
/****************/
void readSetup(void) {
if (!SPIFFS.begin())
{
// Serious problem
Serial.println("SPIFFS Mount failed");
} else {
Serial.println("SPIFFS Mount succesfull");
}
}
void setup() {
Serial.begin(115200);
Serial.println("Hello");
readSetup();
setup_LED();
//startAP();
startWiFi();
startOTA();
startServer();
}
/***************/
/* Start of Main /
/****************/
void loop() {
// put your main code here, to run repeatedly:
server.handleClient();
ArduinoOTA.handle();
processLED();
if(seqstate) processSequence();
}
/***************/
/* End of Main /
/****************/
unsigned long hexToDec(String hexString) {
unsigned long decValue = 0;
int nextInt;
for (int i = 0; i < hexString.length(); i++) {
nextInt = int(hexString.charAt(i));
if (nextInt >= 48 && nextInt <= 57) nextInt = map(nextInt, 48, 57, 0, 9);
if (nextInt >= 65 && nextInt <= 70) nextInt = map(nextInt, 65, 70, 10, 15);
if (nextInt >= 97 && nextInt <= 102) nextInt = map(nextInt, 97, 102, 10, 15);
nextInt = constrain(nextInt, 0, 15);
decValue = (decValue * 16) + nextInt;
}
return decValue;
}
OTA
Error[4]: End Failed
ERROR[0]: No Error
UPDATER
pm open,type:2 0
sleep disable
[begin] roundedSize: 0x00052000 (335872)
[begin] updateEndAddress: 0x00300000 (3145728)
[begin] currentSketchSize: 0x00052000 (335872)
[begin] _startAddress: 0x002AE000 (2809856)
[begin] _currentAddress: 0x002AE000 (2809856)
[begin] _size: 0x00051660 (333408)
Start
premature end: res:0, pos:270336/333408
Error[4]: End Failed
CORE just before Fail
:sent 12: 81%
:rn 536
:rd 536, 536, 0
:rdi 536, 536
:c0 536, 536
:wr 3 3 0
:wrc 3 3 0
:rn 536s: 81%
:rd 296, 536, 0
:rdi 536, 296
:rch 536, 536
:er -14 0x00000000
:rd 776, 1072, 296
:rdi 240, 240
:c 240, 536, 1072
:rdi 536, 536
:c0 536, 536
Error[4]: End Failed
The Upload fails at approx 82%
Seen the same error after uploading a sketch that had an infinite loop. Flash a known good version of your sketch using usb, reset the board with the hardware reset switch, then ota should work again.
Hey, thanks for answerring, but i cant understand what you mean.
I dont think there is an infinite loop in my sketch. Its working properly. Serving Frontend HTML files nicely and the other functions are working too when connecting to the ESP via browser and sending data to the esp.
There is just the HTML update and the OTA update which make problems.
maybe i should attach the content of data folder too?
so, upatding BasicOTA over previous flashed BasicOTA stops at 84% with an error.
Conmpletely erased the chip and reflashed it, same problem -.-
I guess you did the hardware reset or power cycled it after flashing from usb.. bad flash chip maybe? Power supply voltage look ok while its uploading? If you've got any spare esp, now might be a good time to try one of them. Wish I could be of more help, but no problems with ota here other than when its my own fault (which is often).
Yes, i power cycled and the chip sits on a pcb with voltage regulator, so there should not be a problem with power supply.
I maybe try another chip. But i have to say, OTA worked a while ago on the same chip.
I have 2 esp on latest git install, but both using the older version of lwip. 4 other esp I have on 2.4.0-rc2, all with ota... maybe its worthy to try going back to that and testing with basicOTA again?
Thats it!
Thank you very much!
So latest git version has problems with ota, version 2.4.0-rc2 works.
hi
There is no solution provided here about this problem, I have this problem right now with same board .
please help !
Yes: you can spend 5 minutes to search the repo source code for what updater error 4 means: space.
Or if you can't manage to do that, you can seek peer help at a community forum like esp8266.com or stackoverflow, where if you ask nicely, maybe somebody will show you how to do the above.
Yes: you can spend 5 minutes to search the repo source code for what updater error 4 means: space.
Maybe if you're developer of the mentioned source code then yeah. I have a similar problem and it's taking me hours to find out what is going on, and I'm close to giving up. I can't even reupload the BasicOTA example over the air. It stops at 1%. It worked before same day. Arduino IDE is not helping with substituting every possible compile error with "Multiple libraries were found".
Most helpful comment
Maybe if you're developer of the mentioned source code then yeah. I have a similar problem and it's taking me hours to find out what is going on, and I'm close to giving up. I can't even reupload the BasicOTA example over the air. It stops at 1%. It worked before same day. Arduino IDE is not helping with substituting every possible compile error with "Multiple libraries were found".