-
Notifications
You must be signed in to change notification settings - Fork 13.3k
HTTP OTA (ESP8266httpUpdate) #1177
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
Comments
what flash size is on you module? |
Hi, Links2004. Thanks for your reply. Here's the output of the sketch: Flash real id: 001640C8 Flash ide size: 524288 I've uploaded the sketch with "512K (64K SPIFFS)", as usual. It's that ok? Thanks again :o) |
try with "512K no SPIFFS" and additional check my issue: |
|
Thanks again for the answers. 512K no SPIFFSA bit better, but not enough. Now sketch is just for OTA testing. If works, I'd insert it in my real sketch, so, sice will be higher. [httpUpdate] Header read fin. "4M (1M SPIFFS)"No wifi connection!!!! I can't even "ping" the ESP8266. I can't see activity at my Apache HTTP acces.log. [httpUpdate] Header read fin. No way :'o( Thanks for your help!!!! |
I am getting a similar issue. I have put the .bin file in the root of my publically accessible NAS drive and in a browser put in the address and file name (tester.bin) - it's there - it downloaded. Now I've put my ssid and password and the same link into httpdUpdate example - and it gets the connection to the WIFI and says "HTTP_UPDATE_FAILD" - but here's the thing - it says the same whether or not there the bin file is in that directory - surely if the file is not there, it should say "HTTP_UPDATE_NO_UPDATES" - regardless of whether there is enough RAM or not (the file is 210k) ??? |
I think my problem it's related to #1147. In fact, I understand why I can't do OTA: just because not enough free space to load new sketch. The problem is that I change to 4M SPIFFS, WiFi doesn't work at all, no connection to the AP. In #1147 says connection is too slow. For me, it's not connection at all. Same code. Code is properly loaded (I can see Serial messages), but no WiFi connection. Just connection with 512K option. |
@scargill @ikin77 |
Hi, Links2004. Thanks for your help. In fact, the problem is that in 4Mb flash mode I have no Wifi connection. I can't ping ESP8266 from my module and I can't see activity at my Apache access.log file. I'm seeing the script you suggest me to run to erase the flash. It's a "makefile.init" file and I don't know how to run it, the first time I see this language. How can I run it? I can't see much information on Internet about this "makefile.init" file :o/ Anyway, I've tried with two different ESP8266 modules with same result :o( Thanks!!! |
you only need to run the line. |
Hah - you are right Andrei - no topic :-) - ok I have my little LEDs running a treat. I'll update the blog - thank you for this - a great new toy to play with. From: Markus [mailto:[email protected]] you only need to run the line. — |
Thanks for yor help again. I'm to busy today and I can't try the solution you suggest. I'll try it tomorrow and I'll let you know :) Regards!! |
HI. I'm still stuck with the problem, trying to find out what's wrong. Just a question: if I choose Nodemcu instead of Generic ESP8266 as board in Arduino IDE, I'm supposed to install before firmware Nodemcu with esptool.py in my ESP8266. I haven't do it. That might be trying cause of the problem? |
no the original Nodemcu firmware has noting to do with this project, and is not needed. |
No, I haven't still run the script you gave to me. But I've flashed several times the esp8266 with expressif firmware. I've also tried with two different units. I'll try to run tomorrow the erase script and I'll let you know. Thanks for your fast reply!!!! |
Hi again. I erased the flash and now I can upload a sketch Flash size 4M (3M SPIFFS) and have wifi connection!!!! The bad thing is that I've arrived to the next error: the unit restarts before OTA. Debuggin, I'm sure of being entering the method "ESP8266HTTPUpdate::runUpdate" and the crash arrives in "Update.writeStream(in)", line 185. Any ideas? |
do you running the latest git version? when it make still problems please enable the debug output: |
I've been doing more debug....the problem is in "UpdaterClass::_writeBuffer()", when "ESP.flashWrite" is invoked. |
Getting better.... [httpUpdate] Header read fin. ets Jan 8 2013,rst cause:2, boot mode:(3,6) load 0x4010f000, len 1264, room 16 ets Jan 8 2013,rst cause:4, boot mode:(3,6) The problem is that after reboot, the new sketch is not running (it's the same I used to test OTA). Trying to find out what's going on. Is relevant to choose as board Generic ESP8266 vs NodeMCU? Actually, I'm using just an ESP8266, not NodeMCU. I keep myself doing more test. I'll let you know. Regards |
Here’s what I did. I compiled a version of the MQTT software and tested it on an ESP12 board. I ran the example HTTPUPDATE software – using latest code from GIT today on Arduino 1.6.5 The HTTPUPDATE loaded up – and then I got UPDATE FAILD.. So instead of using the 512K setup I used the 4MEG setup. This time it waited a while – looking like it might be loading the update and then… [SETUP] WAIT 3... [SETUP] WAIT 2... [SETUP] WAIT 1... ets Jan 8 2013,rst cause:2, boot mode:(1,7) ets Jan 8 2013,rst cause:4, boot mode:(1,7) wdt reset Nothing – sat there DEAD. I rebooted the board and indeed it HAD uploaded the new software – which then ran perfectly.. But if it does not reboot properly after the update it is all a bit pointless as the point of remote updating is not to have to disconnect the board to reboot it.. Any ideas? From: Markus [mailto:[email protected]] du you running the latest git version? when it make still problems please enable the debug output: — |
I'm running the latest GIT. I'm having the problem in function UpdaterClass::_writeBuffer(). I've added some Serial.println to have extra debug info: bool UpdaterClass::_writeBuffer(){ The last thing I see at Serial monitor is: WRITE BUFFER AAA Soft WDT reset So, I think the error occurs in "ESP.flashWrite(_currentAddress, (uint32_t*) _buffer, _bufferLen);". I go on with my debugging.... |
the reboot problem is tracked here: #1017 |
So.. If I blow the HTTPUPDATE software and pull the power just before it actually does anything… reconnect – it does INDEED go off and do the update and all is well… BUT.. [SETUP] WAIT 1... ets Jan 8 2013,rst cause:2, boot mode:(3,7) load 0x4010f000, len 1264, room 16 tail 0 chksum 0x42 csum 0x42 @cp:0 Ld So there it is – then the program starts – all is well.. but if you look at the source- somewhere it is supposed to say “HTTPUPDATE OK” – I’m no seeing that anywhere… From: Markus [mailto:[email protected]] the reboot problem is tracked here: #1017 #1017 — |
Also I wonder if anyone can help.. So I used the HTTPUPDATE software to blow the MQTT example…. So I update the software – and the MQTT software start up – and that’s fine. But what I’d like to do – and I imagine most people using this would – is to incorporate the HTTPUPDATE software into something existing – like for example – the MQTT example – so that one could send a remote command – for the software to update itself. But the HTTPUPDATE software uses a completely different set of includes and the WIFI setup uses a different function call… Is the ESP8266WiFiMulti really necessary or can one simply add these two #include <ESP8266HTTPClient.h> #include <ESP8266httpUpdate.h> And this t_httpUpdate_return ret = ESPhttpUpdate.update("http://whatever.domain/tester.bin"); To, say the MQTT normal MQTT example??? Pete. From: Markus [mailto:[email protected]] the reboot problem is tracked here: #1017 #1017 — |
the "HTTPUPDATE OK" will not be shown see: #1202 |
Thanks. Just need to figure out how to integrate that into the MQTT or other actual program… From: Markus [mailto:[email protected]] the "HTTPUPDATE OK" will not be shown see: #1202 #1202 — |
@scargill I don't understand what is your problem. You don't know how to "mix" MQTT and OTA? A sample sketch of what you're trying to do would be: #include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <ESP8266httpUpdate.h>
const char* ssid = "........";
const char* password = "........";
const char* mqtt_server = "broker.mqtt-dashboard.com";
WiFiClient espClient;
PubSubClient client(espClient);
void setup() {
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
}
void setup_wifi() {
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void callback(char* topic, byte* payload, unsigned int length) {
String message = String();
for (int i = 0; i < length; i++) {
char input_char = (char)payload[i];
message += input_char;
}
if (message == "ota") { // When we receive ota notification from MQTT, start the update
ESPhttpUpdate.update("http://whatever.domain/tester.bin");
}
}
void reconnect() {
while (!client.connected()) {
Serial.print("Attempting MQTT connection...");
if (client.connect("ESP8266Client")) {
Serial.println("connected");
client.subscribe("devices/esp8266/control"); // Subscribe to your MQTT topic
} else {
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 5 seconds");
delay(5000);
}
}
}
void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();
} What's the problem? |
try
I am guessing that "flashWrite" is taking too much time. I don't know what is the "_buffer" size. |
when flashWrite works well then there will be no WDT. the WDT comes for a reason we need to find this reason and fixing it. |
@Links2004 Thanks. Yes. Lets wait for the info you asked from @ikin77. Even I want to know what are those three things. Do you know any other reason this can happen "Soft WDT reset". Let me know. |
I added the lines @Links2004 suggested. Firs time I saw the message up to "WRITE BUFFER AAA", and after that, I saw the "Soft WDT reset". I tried again, and got the following: WRITE BUFFER AAA So, the Soft WDT reset is unpredictable :o(. I'll try @itsjustvenky and I'll inform you... |
please add |
Thaks again. Here's the new output....Iniciando OTA.... Exception (0): ctx: sys
|
strange now we have a null ptr, may be course an interrupt during the flash is blocked. when you make a obj dump for the address, i think we see an function called from a interrupt. |
I'm using the following libraries: Wire.h, ESP8266WiFi.h ,ESP8266WebServer.h, ESP8266HTTPClient.h, ESP8266httpUpdate.h, Timers.h, OneWire.h, DS3231.h, DallasTemperature.h. The only one written by me is "Timers.h", where interrupts are not used. Timers.h is developed for "multi-threading" purpose, similar to Java classes Timer && Runnable. Maybe any of the others use interrupts, but I've disabled them to avoid problems:
The result is more or less similar: Iniciando OTA.... Exception (0): ctx: sys I agree with you....pretty strange :o( Thans again :o) |
try to make a objdump from the elf that match to the bin file. then we hopefully see where the problem is coming from. noInterrupts();
result = ESP.flashWrite(_currentAddress, (uint32_t*) _buffer, _bufferLen);
interrupts(); note: I edit your post for better reading using Markdown code tags |
or rather, try changing static const int FLASH_INT_MASK = ((B10 << 8) | B11111110); |
Thanks to you. I won't be able today to do any testing. Tomorrow I'll try and I'll inform you about the results. Thanks again and best regards :) |
Hi again. I tested, twice, adding your suggestion: noInterrupts(); First try[httpUpdate] Header read fin. ets Jan 8 2013,rst cause:4, boot mode:(3,3) wdt reset Second tryhttpUpdate] Header read fin. Exception (0): ctx: sys
No way :o( Thanks anyway!!! :o) |
Hi, Igrr. With your suggestion the result is: [httpUpdate] Header read fin. ets Jan 8 2013,rst cause:4, boot mode:(3,3) wdt reset |
Hi, any ideas? The lastests GIT updates might be related to this issue? Thans to all of you :o) |
the latest changes in Update are related to wrong flash config in IDE vs real flash. |
@Links2004 Thanks for your help. I'm waiting to arrive some others ESP8266....I'll try with them. Maybe is a problem of my units :o/ |
Hi again. I think all the problems were mine, I'm sorry. The power suply for ESP8266 was not enough and that was causing my unexpected reboots. Now things are better, but OTA is not still working for me: HTTP_UPDATE_FAILD ////// It looks like the http server it's taking too long to reply. Actually, it's an Apache HTTP Server running in the same network, so, speed is more than enough. Any ideas?? Thanks again to all of you :o) |
Hi, @Links2004. I'm using last git, I downloaded it this morning. I'm seeing posts #1157 and #1191. I'm going to try to Try increase more the stream timeout in writeStream in Updater.cpp. I'll let you know |
Some news....in GIT I can see that in Updater.cpp is not present the suggesion of #1157: to add
I'm trying to find out what it means. |
Any idea about the magic bit message? Can you check if extra timeout for serial input at http ota update has been committed to latest git? Thank!!! |
"Magic byte is wrong, not 0xE9" means the verification of the data written to flash has failed, most common is the problem that there is not enough power, The |
Hi, Links2004. It's strange because most of times I get the magic byte error message, but every so often update is performed. You can see two attempts in Serial:ç [httpUpdate] Header read fin. ets Jan 8 2013,rst cause:2, boot mode:(1,7) ets Jan 8 2013,rst cause:4, boot mode:(1,7) wdt reset The problem is that after "Update ok", the ESP remains blocked and it doesn't work any more unless you install new firmware from Serial port. Here's the URL I'm using for OTA:
Thanks again, Links2004 |
will do some tests with the link tomorrow. |
the server send the data in chunks, |
I'm trying to add HTTP OTA to one of my projects. First, I'm using the sample sketch, just changing SSID & password.
I can see in my Apache access.log that the new sketch is being requested from the ESP8266, with HTTP 200 code (all OK).
The problem is that OTA is not being performed. If I active debug messages from ESP8266httpUpdate library, I can see the following at Serial:
[httpUpdate] Header read fin.
[httpUpdate] Server header:
[httpUpdate] - code: 200
[httpUpdate] - len: 265920
[httpUpdate] ESP8266 info:
[httpUpdate] - free Space: 172032
[httpUpdate] - current Sketch Size: 265916
[httpUpdate] FreeSketchSpace to low (172032) needed: 265920
Seems that new sketch it's to big. But new sketch is really simple: the same OTA example provided with the library.
I've compiled the sketch with "Generic ESP8266 Board". If I try to compile it with "NodeMCU 1.0 (ESP-12EModule) " I can upload it with Serial port to the ESP8266, but the module can't connect to the router with that option selected.
What might be going on?
Thanks in advance and best regards!!!
The text was updated successfully, but these errors were encountered: