-->
Page 1 of 5

WebUpdate - how to?

PostPosted: Sat Aug 15, 2015 9:11 am
by DaniloFix
Hi guys

I tried to load my NodeMCU with the ESP8266Webserver WebUpdate example and copied the bin file the Arduino IDE generated and upload that to the ESP. It seems it doesn't work as I would expect it to. Isn't the point that we can update the firmware over the air?

This was generated from the terminal:

Booting Sketch...
Ready! Open http://esp8266.local in your browser
Update: WebUpdate.cpp.bin
lmac.c 662

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

wdt reset
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld

Booting Sketch...
Ready! Open http://esp8266.local in your browser

Thing is ... I have changed the host in the .bin file so it seems nothing has changed.

Re: WebUpdate - how to?

PostPosted: Mon Feb 22, 2016 5:52 pm
by Stévanovich
Hello,
I followed instruction to update with bin file (created by arduino).
I can't access with http://esp8266-webupdate.local as mentionned, but can access with ip address


Here is message after updated
:
Booting Sketch...
..............................................Ready! Open http://esp8266-webupdate.local in your browser
Update: WebUpdater_v1.ino.generic.bin
sleep disable
ERROR[0]: No Error
ERROR[0]: No Error
ERROR[0]: No Error
Update Success: 257680
Rebooting...

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


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

wdt reset


Does it really work ? :?

I had to put original firmware to get it work again ... very strange .
Is anybody has any idea ?

Thanks,
Best regards.

Re: WebUpdate - how to?

PostPosted: Mon Feb 22, 2016 10:38 pm
by MartianMartin
I too am having trouble with the mDNS service, though I successfully performed web update by browsing directly to the IP address and this version of the web-update code:

Code: Select all/*
  To upload through terminal you can use: curl -F "image=@firmware.bin" esp8266-webupdate.local/update
*/

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

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

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){

    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
 
    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);
}


I also had to make sure that gpio-0 was high for the whole sequence, since part of the OTA update requires a reboot.

There are two versions of the web-update example sketch in the arduino library, the one that uses the ESP8266HTTPUpdateServer class did not work for me, not sure why.

Re: WebUpdate - how to?

PostPosted: Tue Feb 23, 2016 5:54 am
by Stévanovich
Ok, my try was based on same example.
Is there any way to simulate GPIO0 to HIGH without any connexion ?
Like digitalWrite(0,1); ? (mode OUTPUT) ?

Thanks