Uploading program over the air ESP32 using the HTTP webserver

Thread Starter

zazas321

Joined Nov 29, 2015
936
I get another error message if I use:
t_httpUpdate_return ret = ESPhttpUpdate.update(client,"192.168.100.159",80, "/var/www/html/uploads/dev1.bin");
Error(-102) File not found
 

geekoftheweek

Joined Oct 6, 2013
1,429
The html should be fine since the group had read permissions. The uploads owner shouldn't make a difference as long as /var/www/uploads still shows www-data as it's owner.

The 102 error should be due to the server would convert it to /var/www/html/var/www/html/uploads/dev1.bin

The url you enter will be relative to /var/www/html.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Okay. Thank you for all your help ! You helped alot.

I will continue to debug this problem, update here if I found anything
 

geekoftheweek

Joined Oct 6, 2013
1,429
Tried this in google and came up with a slew of possibilites... esp8266 ota update error 104

Do you have serial debugging connected on your ESP32 and running? Maybe comparing it's output to some others will shed some light on things.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Different function calls returns a different error - im not too sure which one should I use as every other example on the internet is using different call:

t_httpUpdate_return ret = ESPhttpUpdate.update(client,"192.168.100.158",80, "uploads/web.bin");
returns error 104

If I remove client,
t_httpUpdate_return ret = ESPhttpUpdate.update("192.168.100.158",80, "uploads/web.bin");
Also returns error 104

If I remove port 80:
t_httpUpdate_return ret = ESPhttpUpdate.update("192.168.100.158", "uploads/web.bin");
HTTP_UPDATE_FAILD Error (-1): HTTP error: connection failed


t_httpUpdate_return ret = ESPhttpUpdate.update(client, "uploads/web.bin");
HTTP_UPDATE_FAILD Error (-1): HTTP error: connection failed
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
I have connected usb cable to my esp devices ( the same uart serial i use to flash the program in the first place)
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Okay something new - I have added / before uploads as such and now I am getting error
t_httpUpdate_return ret = ESPhttpUpdate.update(client,"192.168.100.158",80, "/uploads/web.bin");
CALLBACK: HTTP update process started
CALLBACK: HTTP update fatal error code -107
HTTP_UPDATE_FAILD Error (-107): New Binary Does Not Fit Flash Size

I guess that means that my esp chip recognised the .bin file
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
I have managed to upload the most basic sketch over OTA! Having memory problems though when trying to upload slightly bigger sketch
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Trying to play with flash size:
1594722123699.png

Does not seem to make any difference. The blink sketch that I have uploaded successfuly is just 20kB smaller than my sketch but it does not upload that due to the flash size error
 

geekoftheweek

Joined Oct 6, 2013
1,429
Ahh... good to hear you are getting somewhere!! I saw in https://github.com/espressif/arduino-esp32/issues/3020 in the beginning the debugging output shows free space and current sketch size. I'm thinking addting the current size and free space should give you the total memory available. I may be wrong, but I'm also guessing the memory settings in Arduino IDE won't make a difference in this case since it is still able to compile your sketch.

At any rate you should be able to find the total memory that way and work back from there. It doesn't list the new sketch size so maybe you'll have to watch compiler output to see what is actually what. If you scroll up on the bottom window of Arduino IDE somewhere it shows how much memory your sketch will actually occupy.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
1594725901512.png

So it says:
Sketch uses 298268 bytes (28%) of program storage space. Maximum is 1044464 bytes.
When trying to OTA flash 255kB sketch, it works
277kB - does not work anymore. Hmmm
 

geekoftheweek

Joined Oct 6, 2013
1,429
Might be good to see if you can find memory specs on the unit you have. Could be it's reporting things wrong and you're stuck with the 512k version. 255 would work since both sketches would only occupy 510k, but 255k and 277k would be over the limit.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
The board thar I am using is nodemcu 1.0 whicu has 4MB flash storage.

I will continue debugging tommorow.

Big thanks to you sir
 

geekoftheweek

Joined Oct 6, 2013
1,429
The board thar I am using is nodemcu 1.0 whicu has 4MB flash storage.

I will continue debugging tommorow.

Big thanks to you sir
Shoots my thought to pieces. Hopefully there is an easy answer!! You are most welcome and once again thank you for asking in the first place. Next time I spend time with my ESP12F I'm going to try this to eliminate constantly having to switch jumpers around, reset, and reprogram. Already came too close to putting 5V to the reset pin!!
 

geekoftheweek

Joined Oct 6, 2013
1,429
@zazas321 It took me a little while to figure it out, but I remember trying to steer you towards these for a different project at one time. Glad to see you at least looked into them. Seems you found different questions to figure out your project also. Keep working at it!

At any rate have you made any progress? I bought some ebay ESP12F and they didn't have all the specs so I kind of needed to find a way to figure out what I have. I came across https://github.com/espressif/esptool which can be installed on PI with the normal apt system tool. Just thought I'd mention it. I found I do have the 4 MB version also so it's time to get busy I guess.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
I have managed to get OTA working on my Weemos mini d1 pro which has 16MB flash without any trouble. I still havent managed to update on the ESP8266. I will still continue looking at it. Yes I have also read about esptool and a way to clear the flash completely.

I also have read many things about spiffs and configuring the esp8266 configuration file in the arduino to manually allocate more memory but I am not too sure about that yet.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Just a quick update:

I have installed esptool.py on my raspberry PI and ran a script:

Code:
sudo esptool.py --port /dev/ttyUSB0 erase_flash
Apparently, this script supposed to completely erase flash memory. After this cript, I have managed to succesffully run OTA on my Node-mcu-1.0 board.
 

Thread Starter

zazas321

Joined Nov 29, 2015
936
Just a quick update:

I have installed esptool.py on my raspberry PI and ran a script whilst connected to my ESP8266 through usb cable

Code:
sudo esptool.py --port /dev/ttyUSB0 erase_flash
Apparently, this script supposed to completely erase flash memory. After this cript, I have managed to succesffully run OTA on my Node-mcu-1.0 board.
 
Top