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

Moderator: igrr

User avatar
By MartianMartin
#41749
Stévanovich wrote: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

Just the be sure - on boot the chip reads GPIO0, if HIGH then Flash Boot, if LOW then UART download. Some boards/usb hosts handle the switch automatically with the USB DTS signal, others require flipping a switch. In the serial output that you posted, I think that the first reset is good, part of the OTA flow. The problem is that boot mode(1,6) indicates that GPIO0 is indeed LOW upon reset which we do not want. Note: "In the bootup message 'boot mode:(x,y)' three low bits of x are {MTDO, GPIO0, GPIO2}." - https://github.com/esp8266/esp8266-wiki/wiki/Boot-Process

It's not optimal, but one thing that you could try is simply unplugging the USB from the computer for the duration of the OTA process (just use USB for power instead). This would mean flying partially blind which is unfortunate (maybe setup UDP debug channel?)... but it may be that the USB host is set DTS high each time it detects a reset. Either way I would definitely get a scope or multimeter on GPIO0 to track its behavior, this has helped solve things for me in the past.
User avatar
By Stévanovich
#41758 Hi,

I will try to describe all my process to webupdate .

Frist, i lanch arduino with my source code, fully based on webupdater.
I plug my usb FDT1232 , only ground, TX and RX,
Power supply is assumed by an external 12V to 3.3V adapter (YwRobot)
I put ESP8266 to record mode (GPIO0 to 3.3v with 10kOhm and GPIO to 3.3v with 10kOhm) GIO15 stay always to GND with 10K.
I launch compil and upload process .
All done correctly and ESP8266 reboot itself at end (how ? ..)
ESP connect to my SSID correctly
I deconnect USB TTL
I lauch Webupdate and select the bin file prepared with Arduino

Now , i can't send all file steel freeze at 38% of sending.

I try serveral time but none get right
I connect my usb TTL and here is log :

sleep disable

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

wdt reset


Here is my full source file :
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_v1";
const char* ssid = "MABOXE";
const char* password = "monmotdepasse";

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 WIFI_Connect()
{
  digitalWrite(2,1);
  WiFi.disconnect();
  Serial.println("Booting Sketch...");
  WiFi.mode(WIFI_AP_STA);
  WiFi.begin(ssid, password);
    // Wait for connection
  for (int i = 0; i < 25; i++)
  {
    if ( WiFi.status() != WL_CONNECTED ) {
      delay ( 250 );
      digitalWrite(2,0);
      Serial.print ( "." );
      delay ( 250 );
      digitalWrite(2,1);
    }
  }
  digitalWrite(2,0);
}


void setup(void){
  pinMode(2, OUTPUT);
  pinMode(16, OUTPUT);
  Serial.begin(115200);
  Serial.println();
  WIFI_Connect();

  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){
  digitalWrite(16,0);
    if (WiFi.status() != WL_CONNECTED)
    {
      digitalWrite(2,1);
      WIFI_Connect();
    } else {
      digitalWrite(2,0);
    }
  digitalWrite(16,1);
  server.handleClient();
  delay(100);
  digitalWrite(16,0);
  delay(100);
}
User avatar
By Stévanovich
#41759 Oops ,
I think i miss something very important ... where does new bin is store before update ... and what happend when new "firmware" is greater then old one ?

i had a look there :

https://github.com/esp8266/Arduino/blob/master/doc/ota_updates/ota_updates.md#web-browser

A graphical drawing explain how it work.
So, now , Arduino compiler said me :

Le croquis utilise 253 538 octets (58%) de l'espace de stockage de programmes. Le maximum est de 434 160 octets.
Les variables globales utilisent 38 676 octets (47%) de mémoire dynamique, ce qui laisse 43 244 octets pour les variables locales. Le maximum est de 81 920 octets.


Bin file size is 251 Ko (257 728 octets)

Maybe that is why it does not work ?

Should i try something with a sd card ?