- Tue Feb 23, 2016 5:34 pm
#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);
}
Use: ESP8266 ESP-07 ESP-12F ESP-14
Windows 10
Arduino IDE 1.6.13
ESP8266 2.3-RC-2 + git ESP8266 core