These are chat archives for esp8266/Arduino

25th
Nov 2015
Dmitry Kireev
@kireevco
Nov 25 2015 07:47 UTC
if anyone interested, I’m working on https://github.com/kireevco/esp-alt-sdk - true cross platform toolchain. almost working, keep you posted
it doesn’t use croosstool-NG, so it’s easier to build
not sure if @pfalcon would accept such a huge change (no crosstool-ng)
Ivan Grokhotkov
@igrr
Nov 25 2015 07:50 UTC
wow, that's awesome.
Dmitry Kireev
@kireevco
Nov 25 2015 07:50 UTC
of course, it is work-in-progress, but I’m tired of cross-platform ignorance
Rohit Yermalkar
@romuye123
Nov 25 2015 08:03 UTC
hello, i have an issue with arduino ide + esp8266 causing crash on smartconfig
what could be the issue ?
getting crash on WiFi.beginSmartconfig()
frippe75
@frippe75
Nov 25 2015 08:50 UTC
This message was deleted
frippe75
@frippe75
Nov 25 2015 09:18 UTC

Also have a "strange" crash
Fatal exception (9): as well as Fatal exception (29):

ALWAYS crashes on the second pageload of /firmware/esp8266/check
server.send always returns. Feels like the crash occurs in loop. loop() contains a yield.
But my checkLatestFirmware is sometimes quite lengthy due do my cheap hosting selection :-)
In this scenario I have moved to my local running Apache though.

 server.on ( "/firmware/esp8266/check", []() {
      String fwfile = checkLatestFirmware("esp8266", "192.168.0.210","/firmware/inventory.json");
      String msg = "No new firmware found for esp8266";
      if (fwfile != NULL) {
          msg = "New firmware found for esp8266";            
      }
      USE_SERIAL.println("BEFORE:server.send");
      server.send( 200, "text/plain", msg );
      USE_SERIAL.println("AFTER:server.send");
 } );

Short output:
HTTP server started
<client does http://192.168.0.219/firmware/esp8266/check>
ENTER:checkLatestFirmware
getJSON http://192.168.0.210:80/firmware/inventory.json
EXIT:checkLatestFirmware
BEFORE:server.send
AFTER:server.send
<client does http://192.168.0.219/firmware/esp8266/check>
ENTER:checkLatestFirmware
getJSON http://192.168.0.210:80/firmware/inventory.json
EXIT:checkLatestFirmware
BEFORE:server.send
AFTER:server.send
Fatal exception (28)

During the second pageload I get "The connection was reset"

Full curl output on pastebin

Full serial output on pastebin

wireshark output

frippe75
@frippe75
Nov 25 2015 09:39 UTC
Would it be better to do a server.send staight away to say... checking firmware... standby... Or maybe it's not related to the long pageload?
frippe75
@frippe75
Nov 25 2015 09:55 UTC

Tried to delete the post above without success.

First modified my checkLatestFirmware to simply return a filename with no delay. Things worked as expected.

Then put in a more well behaved delay of ~500ms:

for (int i=0; i<10; i++ ) {
     delay(50);
     yield();
  }
 return String("Filename");

Still works ... Started to think about blocking code in my checkLatestFirmware.
I think its the http client library that needs to perform a few yields.. Or ??

I'm reading it this way:

WiFiClient stream = http.getStream();
int len_ret = stream.readBytes(json, http.getSize());

Or maybe somewhere in WifiClient... ??

Ivan Grokhotkov
@igrr
Nov 25 2015 10:12 UTC
You really shouldn't be doing checkLatestFirmware from within the server callback
this blocks the server from producing reply
set a flag that inside the callback, return some response like "checking in progress", and then run the check in the next loop cycle.
but certainly don't do any lengthy inside server callback
frippe75
@frippe75
Nov 25 2015 10:52 UTC

@igrr ok thanks! So have the client check for progress... lets say during a firmware upgrade. This is a client asking the esp8266 to perform a pull-upgrade. Would this be be a better way

*At boot the esp8266 check for firmware status

Exposed functions:
/firmware/esp8266/check (returns status immediately)
/firmware/esp8266/update (initiates a background pull, download to spiffs, then updates with,without reboot)
/firmware/esp8266/progress (returns percentage in inc of 10)
/firmware/esp8266/reboot (if I want the client to be able to control this stage)

Ivan Grokhotkov
@igrr
Nov 25 2015 10:56 UTC
i don't think it's possible to have web server running in parallel with OTA
at least, i wouldn't recommend that
(that's regarding /firmware/esp8266/progress)
frippe75
@frippe75
Nov 25 2015 10:59 UTC

@igrr ahh.. you right... WIFI...stopall... And for some reason the update process is not especially consistent in time. But I have the firmware downloaded to spiffs. Why couln't I have networking enabled?.

 if(ESP.updateSketch(file, file.size(), false, false)) {
             file.close();
             ESP.restart();
         } else {
            USE_SERIAL.println("Error: Update failed");
         }

Any part of updateSketch that's sensitive to networking?

frippe75
@frippe75
Nov 25 2015 11:05 UTC

My stream is a file stream to
EspClass::updateSketch(Stream& in, uint32_t size, bool restartOnFail, bool restartOnSuccess)

I could of course have the client do a progress-spinner instead of a progress-bar in percentage and simply poll /firmware/esp8266/check ... If it goes to "latest" after an update it means it rebooted and was updated... But I would like to have the progress-bar with ..."Download firmware".... "Updating firmware"... Don't know why but it feel much more 90thies ... :-)

Ivan Grokhotkov
@igrr
Nov 25 2015 11:37 UTC
Server can only dispatch a callbacks when you call server.handleClient(). When you call ESP.updateSketch(), your loop doesn't get called, so server.handleClient() won't get called as well.
It might be possible to call server.handleClient() from update progress callbacks, but i haven't tried that
I.e. you can try removing a call to WiFi::stopAll from Updater.cpp, and then call server.handleClient from your progress callbacks.
but that might not work for some obscure reason which i can't figure out right now...
Markus
@Links2004
Nov 25 2015 11:52 UTC
@igrr FAILD i make it wrong every time not know why :)
Ivan Grokhotkov
@igrr
Nov 25 2015 11:54 UTC
yeah, i have a few words which i consistently mis-type as well. thankfully text editors highlight spelling errors nowadays, so it's normally not a big deal.
Markus
@Links2004
Nov 25 2015 11:55 UTC
yes eclipse do but not for failed
it was for some reason disabled in this workspace ....
Ivan Grokhotkov
@igrr
Nov 25 2015 12:01 UTC
one suggestion/question regarding HTTPClient API... did you consider adding a method like http.begin("http://host/uri")?
also don't you think that class name should start with upper case? like HttpClient or HTTPClient?
actually we have both HTTP and http: ESP8266HTTPUpdateServer and ESP8266httpUpdate...
Me No Dev
@me-no-dev
Nov 25 2015 12:05 UTC
I was looking at those and was confused to why is ESP8266HTTPUpdateServer called such if it's not a server but a client
Ivan Grokhotkov
@igrr
Nov 25 2015 12:05 UTC
ESP8266httpUpdate is a client
ESP8266HTTPUpdateServer is a server (it uses ESP8266WebServer inside)
Markus
@Links2004
Nov 25 2015 12:06 UTC
ESP8266httpUpdate will be rewriten to use the httpClient :)
I plan to add md5 support too
Me No Dev
@me-no-dev
Nov 25 2015 12:06 UTC
yes yes... ESP8266HTTPUpdateServer is based on a setch I had as example a while back
Ivan Grokhotkov
@igrr
Nov 25 2015 12:07 UTC
regarding https api, I would vote for:
HTTPClient client;
client.begin(host, uri, port);
client.enableHTTPS("fingerprint");
or maybe enableSSL or enableTLS, or just ssl
Me No Dev
@me-no-dev
Nov 25 2015 12:08 UTC
I think it's time to fit basic auth in both the server and the client class
Ivan Grokhotkov
@igrr
Nov 25 2015 12:08 UTC
but if you like the way it is done now, i'm okay with that
Me No Dev
@me-no-dev
Nov 25 2015 12:08 UTC
have been sporatically thinking about how to fit it in the API
Ivan Grokhotkov
@igrr
Nov 25 2015 12:08 UTC
@me-no-dev yeah, actually someone was asking about that on the issue tracker
Markus
@Links2004
Nov 25 2015 12:09 UTC
i think we need a basic base64 class the rest is easy
Me No Dev
@me-no-dev
Nov 25 2015 12:09 UTC
the API is the paert that I can not wrap inside my head yet
Markus
@Links2004
Nov 25 2015 12:10 UTC
@igrr if I get a url phasing working than the http / https question is easy to handle.
Me No Dev
@me-no-dev
Nov 25 2015 12:11 UTC
@Links2004 I think it's a must for the client to parse the URL and figure out server and security
also how do you handle forwards?
example: calling some url shortening link
Markus
@Links2004
Nov 25 2015 12:13 UTC
yes, it will make it a loot easyer to use.
currently not, but will add it to the todo list.
the current version is a first step, I have many Ideas in mind what can be added to make the live easier for the most people.
like download file direct to the FS or a API to generate POST / form requests easy including Uploade files to the webserver (from FS or string)
but all this will take some time ;) for now my goal is a simply to use API to make GET request.
frippe75
@frippe75
Nov 25 2015 12:24 UTC

@igrr about me making "checkLatestFirmware" inside the server.on call.

I moved out to the living-room. Much closer to my wifi-router. Now problem "is gone" or at least masked by stronger reception.

So one should not make ANY type of networking calls inside any of the the server.on functions?

It appear to me that the networking part of this is somewhat shaky. And this would cause alot of reset's due to this. Why not have an extra yield in the WifiClient, or what else gets me there :-) ?

Me No Dev
@me-no-dev
Nov 25 2015 12:26 UTC
so if you are blocking the network because you need to respond to the curent request, how will you yield to it?
frippe75
@frippe75
Nov 25 2015 12:28 UTC
I was thinking yield had a broader meaning. Haven't checked what it actually does.
Why do I get the Fatal exception (28) in the first place?
Ivan Grokhotkov
@igrr
Nov 25 2015 12:30 UTC
normally the output which follows Fatal exception: contains the necessary info
frippe75
@frippe75
Nov 25 2015 12:30 UTC

Fatal exception (28):
epc1=0x4020cc6d, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000

Exception (28):
epc1=0x4020cc6d epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3fff42b0 end: 3fff4560 offset: 01a0

way above my paygrade :-)
Ivan Grokhotkov
@igrr
Nov 25 2015 12:31 UTC
so the exception happened at 0x4020cc6d, and that was due to a null pointer being dereferenced
your next step would be to figure out what code is at 0x4020cc6d
frippe75
@frippe75
Nov 25 2015 12:31 UTC
ok !
Ivan Grokhotkov
@igrr
Nov 25 2015 12:31 UTC
xtensa-lx106-elf-objdump -S <your_sketch>.cpp.elf
then look for 0x4020cc6d inside the output
you can also take a look at the stack trace which follows
usually for each function call, stack contains return address
frippe75
@frippe75
Nov 25 2015 12:33 UTC
thanks!
Me No Dev
@me-no-dev
Nov 25 2015 12:33 UTC
or use xtensa-lx106-elf-addr2line -aipfC -e <your_sketch>.cpp.elf
then enter the hex numbers
Ivan Grokhotkov
@igrr
Nov 25 2015 12:33 UTC
most of the time, these are in the fourth column of the output (but not always)
Me No Dev
@me-no-dev
Nov 25 2015 12:33 UTC
function name and line number should show
Ivan Grokhotkov
@igrr
Nov 25 2015 12:35 UTC
@me-no-dev how about building an online service where you can upload your .elf and crash info, and it tells you everything in a nice human-readable format? :)
Me No Dev
@me-no-dev
Nov 25 2015 12:35 UTC
@igrr totally doable
Ivan Grokhotkov
@igrr
Nov 25 2015 12:36 UTC
with gdb i can get good stack traces most of the time, just need to figure out how to load a stackdump there
i.e. there might be some tricks for xtensa
okay, i got myself a weekend project now ;)
frippe75
@frippe75
Nov 25 2015 12:38 UTC
0x4020cc6d: ESP8266WebServer::_parseRequest(WiFiClient&) at /usr/local/arduino-PR-4107-BUILD-421/hardware/esp8266com/esp8266/libraries/ESP8266WebServer/src/Parsing.cpp:190
Me No Dev
@me-no-dev
Nov 25 2015 12:38 UTC
do we have access to the elf in the IDE "tool"?
maybe a simple one can be made to run on the host
Ivan Grokhotkov
@igrr
Nov 25 2015 12:39 UTC
yeah, we can infer its name from the sketch name
Me No Dev
@me-no-dev
Nov 25 2015 12:39 UTC
I will look into that
frippe75
@frippe75
Nov 25 2015 12:39 UTC
My request was http://192.168.0.219/firmware/esp8266/check
Shouldn't hasSearch be -1 ?
 int hasSearch = url.indexOf('?');
  if (hasSearch != -1){
    searchStr = url.substring(hasSearch + 1);
    url = url.substring(0, hasSearch);
  }
...
56: searchStr = url.substring(hasSearch + 1);
...
190: _parseArguments(searchStr);
Ivan Grokhotkov
@igrr
Nov 25 2015 13:01 UTC
@Links2004 is this still valid? #1070
i saw a commit entitled "fixed some memory leaks", did you figure out what happened?
@frippe75 this crash happens occasionally, or every time?
Me No Dev
@me-no-dev
Nov 25 2015 13:04 UTC
@frippe75 yes it's -1 and searchStr = "" in this case, so _parseArguments will just delete any old arguments that be leftover and return
how about enabling debug on the web server and see what will come out of there
Markus
@Links2004
Nov 25 2015 13:06 UTC
@igrr yes the loos of 40 Byte is still there and it comes not from the http Client
I was not able to locate it.
its not a ack problem.
Ivan Grokhotkov
@igrr
Nov 25 2015 13:08 UTC
it's been a long time since i last did this (so something might have changed), but WiFiClient example produced steady heap values.
that is, when server closed connection first.
Markus
@Links2004
Nov 25 2015 13:10 UTC
the ssl has the same problem but with 48 Byte.
Ivan Grokhotkov
@igrr
Nov 25 2015 13:13 UTC
sizeof(WiFiClient) = 40, sizeof(WiFiClientSecure) = 48
Markus
@Links2004
Nov 25 2015 13:14 UTC
~WiFiClientSecure or ~WiFiClient shut fully deconstruct it or?
Me No Dev
@me-no-dev
Nov 25 2015 13:15 UTC
if refcount is 0
else will keep it
so maybe missing unref() somewhere
Ivan Grokhotkov
@igrr
Nov 25 2015 13:16 UTC
err, no :)
you need to call delete client;
never call destructor directly
oh my, how did i miss this in your code...
Markus
@Links2004
Nov 25 2015 13:17 UTC
        WiFiClient * _tcp = new WiFiClient();
        _tcp->connect("192.168.1.12", 80);
        _tcp->stop();
        delete _tcp;
?
Me No Dev
@me-no-dev
Nov 25 2015 13:17 UTC
_tcp->unref(); is better is it not?
Markus
@Links2004
Nov 25 2015 13:18 UTC
@me-no-dev WiFiClient dont have unref, unref is from ClientContext
Ivan Grokhotkov
@igrr
Nov 25 2015 13:19 UTC
@Links2004 that's better.
Me No Dev
@me-no-dev
Nov 25 2015 13:19 UTC
right... was reading the ClientSecure and was expecting the api to be the same
Markus
@Links2004
Nov 25 2015 13:19 UTC
k will try, on moment.
no fix still the same problem.
Me No Dev
@me-no-dev
Nov 25 2015 13:21 UTC
any reason there is no ClientSecureContext the same way there is a ClientContext?
Markus
@Links2004
Nov 25 2015 13:22 UTC
@me-no-dev WiFiClientSecure extend WiFiClient so no need?
Ivan Grokhotkov
@igrr
Nov 25 2015 13:22 UTC
@me-no-dev i could have done it so, i guess.
perhaps will do some refactoring after all WiFiClientSecure features are implemented
Me No Dev
@me-no-dev
Nov 25 2015 13:23 UTC
@Links2004 my question is more about consistency :)
@Links2004 have you noticed if those bytes are recovered after some minutes?
Markus
@Links2004
Nov 25 2015 13:25 UTC
they do never come back.
Ivan Grokhotkov
@igrr
Nov 25 2015 13:27 UTC
k, i'll check
Markus
@Links2004
Nov 25 2015 13:31 UTC
@igrr my bad i shut save the delete change :P now its working.
Ivan Grokhotkov
@igrr
Nov 25 2015 13:32 UTC
thank goodness!
basically when you do WiFiClient* client = new WiFiClient, this translates to:
WiFiClient* client = malloc(sizeof(WiFiClient));
client->WiFiClient();
i.e. allocate the memory and call the constructor
with delete its similar
client->~WiFiClient();
free(client);
onkelfunny
@onkelfunny
Nov 25 2015 13:35 UTC
@igrr i try to compile my project with eclipse. some of the libraries could not resolve
Markus
@Links2004
Nov 25 2015 13:35 UTC
good to know, have closed the issue with a big note for everyone :)
onkelfunny
@onkelfunny
Nov 25 2015 13:35 UTC
Bildschirmfoto 2015-11-25 um 14.33.16.png
Markus
@Links2004
Nov 25 2015 13:35 UTC
@onkelfunny you need to add them
Ivan Grokhotkov
@igrr
Nov 25 2015 13:35 UTC
@onkelfunny maybe @Links2004 will help you, i'm not an Eclipse user myself
Markus
@Links2004
Nov 25 2015 13:36 UTC
blob
onkelfunny
@onkelfunny
Nov 25 2015 13:36 UTC
@igrr ok, thx
Markus
@Links2004
Nov 25 2015 13:36 UTC
then select them and it shut work
onkelfunny
@onkelfunny
Nov 25 2015 13:37 UTC
@Links2004 thx!! works perfect!
another question
i have to rename my ino file from Projekt.ino to Project.ino.cpp is this correct?
Markus
@Links2004
Nov 25 2015 13:39 UTC
yes you can do this.
onkelfunny
@onkelfunny
Nov 25 2015 13:39 UTC
"../.ino.cpp:8:2: error: #error the file: Project.ino is not found in the indexer though it exists on the file system."
Markus
@Links2004
Nov 25 2015 13:40 UTC
try:
and:
blob
blob
onkelfunny
@onkelfunny
Nov 25 2015 13:41 UTC
same error
if the filename is Project.ino.cpp it works
Markus
@Links2004
Nov 25 2015 13:42 UTC
have you created the project as ino or as cpp?
onkelfunny
@onkelfunny
Nov 25 2015 13:43 UTC
Bildschirmfoto 2015-11-25 um 14.42.52.png
Markus
@Links2004
Nov 25 2015 13:44 UTC
some later you get this:
blob
onkelfunny
@onkelfunny
Nov 25 2015 13:46 UTC
i created a new with "default ino" with the same error
Markus
@Links2004
Nov 25 2015 13:46 UTC
try cpp when you want to use cpp ;)
if you want to have ino, have you done the steps here: http://www.baeyens.it/eclipse/how_to.shtml#/e
noted by "tell cdt you are using ino file"
onkelfunny
@onkelfunny
Nov 25 2015 13:52 UTC
thx!!
auto spiffs upload i can do with a external run configuration right?
Markus
@Links2004
Nov 25 2015 13:57 UTC
you can uploade spiffs from arduino IDE,
eclipse integration is not complete yet see #1063 (but is possible)
onkelfunny
@onkelfunny
Nov 25 2015 13:59 UTC
ok, thx
Dmitry Kireev
@kireevco
Nov 25 2015 15:15 UTC
What is the fastest wake up after deep sleep I could get ?