Skip to content

WebUpdater problem #2090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pauloeduardosp opened this issue Jun 3, 2016 · 9 comments · Fixed by #6325
Closed

WebUpdater problem #2090

pauloeduardosp opened this issue Jun 3, 2016 · 9 comments · Fixed by #6325
Assignees
Milestone

Comments

@pauloeduardosp
Copy link

pauloeduardosp commented Jun 3, 2016

Basic Infos

Hardware

Hardware: ESP-07 and ESP-01
Core Version:

Description

Problem description
I'm try to use webupdater sketch exemple, but didn't work.
After I do webupdate with WebUpdate.cpp.bin and to module didn't work and freeze with this information

After I do webupdate with WebUpdate.cpp.bin and to module didn't work and freeze with this information

ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x0f
csum 0x0f

Settings in IDE

Module: Generic ESP8266 Module
Flash Size: 1MB/64KB
CPU Frequency: 80Mhz
Flash Mode: DIO
Flash Frequency: 44Mhz
Upload Using: OTA
Reset Method:

Sketch

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char* host = "esp8266-webupdate";
const char* ssid = "anonymous2";
const char* password = "manuela.";

ESP8266WebServer server(80);
const char* serverIndex = "<form method='POST' action='/update' enctype='multipart/form-data'><input type='file' name='update'><input type='submit' value='Update'></form>";

void setup(void){
  Serial.begin(115200);
  Serial.println();
  Serial.println("Booting Sketch...");
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin(ssid, password);
  if(WiFi.waitForConnectResult() == WL_CONNECTED){
    MDNS.begin(host);
    server.on("/", HTTP_GET, [](){
      server.sendHeader("Connection", "close");
      server.sendHeader("Access-Control-Allow-Origin", "*");
      server.send(200, "text/html", serverIndex);
    });
    server.on("/update", HTTP_POST, [](){
      server.sendHeader("Connection", "close");
      server.sendHeader("Access-Control-Allow-Origin", "*");
      server.send(200, "text/plain", (Update.hasError())?"FAIL":"OK");
      ESP.restart();
    },[](){
      HTTPUpload& upload = server.upload();
      if(upload.status == UPLOAD_FILE_START){
        Serial.setDebugOutput(true);
        WiFiUDP::stopAll();
        Serial.printf("Update: %s\n", upload.filename.c_str());
        uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000;
        if(!Update.begin(maxSketchSpace)){//start with max available size
          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)){ //true to set the size to the current progress
          Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize);
        } else {
          Update.printError(Serial);
        }
        Serial.setDebugOutput(false);
      }
      yield();
    });
    server.begin();
    MDNS.addService("http", "tcp", 80);

    Serial.printf("Ready! Open http://%s.local in your browser\n", host);
  } else {
    Serial.println("WiFi Failed");
  }
}

void loop(void){
  server.handleClient();
  delay(1);
} 
### Debug Messages

messages here





<bountysource-plugin>

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/34847918-webupdater-problem?utm_campaign=plugin&utm_content=tracker%2F14245935&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F14245935&utm_medium=issues&utm_source=github).
</bountysource-plugin>
@me-no-dev
Copy link
Collaborator

does it freeze after the update is done? Also what happens if you reset the ESP manually after you update and then try again?

@pauloeduardosp
Copy link
Author

Yes, freeze after update. I make a manual reset because when they reset
after up load I was without serial, than a reset manually to get a msg.
I'll try again to check if a msg is the same

Em Sáb, 4 de jun de 2016 05:27, Me No Dev notifications@github.com
escreveu:

does it freeze after the update is done? Also what happens if you reset
the ESP manually after you update and then try again?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2090 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ARI5EfS64bbo9K0nKMwhRLfdtWishXZZks5qITbzgaJpZM4It2l0
.

@pauloeduardosp
Copy link
Author

pauloeduardosp commented Jun 5, 2016

@me-no-dev
follow the entire message.
Don't have a error at serial after webupdate

Booting Sketch...
192.168.1.31
Ready! Open http://esp8266-webupdate.local in your browser
Update: webupdater.ino.bin
sleep disable
ERROR[0]: No Error
ERROR[0]: No Error
ERROR[0]: No Error
Update Success: 251760
Rebooting...
¢@rjrA(!‹SËu‹Ðšv�XKAú~‡êÑ!½a€�þ"@ªrjrA(!‹SËu‹Ðšö›X%¨ý«Ðyêeh)�"�át‡mݪNø

#############################################################################
They freeze here, after a make a manual reset happen this

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1264, room 16
tail 0
chksum 0x0f
csum 0x0f
@cp:0
ld

ets Jan 8 2013,rst cause:4, boot mode:(3,6)

wdt reset
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x0f
csum 0x0f
~ld
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0003bff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0003bff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0003bff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0003bff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0003bff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0003bff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0003bff0, depc=0x00000000
Fatal exception (28):
epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0x0003bff0, depc=0x00000000

@bakroistvan
Copy link

I am having the same exception: amica nodemcu with latest master||dev image from nodemcu-build.com
Right after flashing.

@MoegerleStephan
Copy link

Having the same issue..
Are there any news?:)

@MoegerleStephan
Copy link

Ok I think I've found the problem..
The issue occurs everytime the update failes and the user restart the update without rebooting the esp8266 in the mean time. Because the esp didn't reset the attributes eg startAdress, currentAddress, size,.. before beginning the update it will continue where it ended the last time when it failes.
Therefore line 44 in Updater.cpp should be removed. After this fixture the update starts once again from the beginning:
https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Updater.cpp#L44

With this fix I didn't had any more freezing problems after update with one client.
I didn't checked what happened if several clients try to update the esp at the same time. I guess this could also lead to unsightly problems..

@devyte
Copy link
Collaborator

devyte commented Oct 17, 2017

@pauloeduardosp is this issue still valid in latest git?
@MoegerleStephan I can't tell which line you mean by line 44.

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Oct 17, 2017
@MoegerleStephan
Copy link

The path changed now to line 45.
Please remove this return command.
Otherwise if a firmware upload fails and you upload this file once again you are not able to update the esp correctly.

@earlephilhower
Copy link
Collaborator

Summary of the bug:
Updater::begin() checks that _start==0, but if you had a failed upload before, _start would be the address of the last program attempted to upload. So after one failed upload, you need to reset the ESP to try another upload.

Solution A:

  • Remove the check that start==0 in ::begin, because the structure is __reset() to all 0s later on in the method.

Solution B:

  • Keep the check, but on any failure in the method call __reset() before return false;.

I like sol'n B.

@earlephilhower earlephilhower self-assigned this Jan 16, 2019
@earlephilhower earlephilhower added this to the 2.6.0 milestone Jan 16, 2019
@earlephilhower earlephilhower added type: bug component: OTA and removed type: troubleshooting waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. labels Jan 16, 2019
earlephilhower added a commit to earlephilhower/Arduino that referenced this issue Jul 21, 2019
Fixes esp8266#2090

The Updater checks that an update isn't already in progress on ::begin,
but when an error happens in the middle of an upload it's impossible to
actually reset this flag w/o a reboot.

Reset the state members (esp. _size) on any error condition so
that you can restart the transfer with a new ::begin.  Any error
condition is fatal, anyway, so there is no reason not to clear the
current state at that point.
earlephilhower added a commit that referenced this issue Jul 21, 2019
Fixes #2090

The Updater checks that an update isn't already in progress on ::begin,
but when an error happens in the middle of an upload it's impossible to
actually reset this flag w/o a reboot.

Reset the state members (esp. _size) on any error condition so
that you can restart the transfer with a new ::begin.  Any error
condition is fatal, anyway, so there is no reason not to clear the
current state at that point.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants