Modules uploaded as functions on Esp8266

Posted on
  • Hi guys,

    There seems to be something wrong with "Modules uploaded as functions" feature on ESP8266 board. The problem was spotted for a while referring to comments in following post.
    http://forum.espruino.com/conversations/­296431/#comment13636908

    I just move this issue into ESP8266 section.

  • Can you give me a really simple example of something that doesn't work? Are you using up to date firmware?

    There shouldn't really be a reason for it not to work...

  • For me, its always the same Gordon. It doesn't matter which board I try (ESP-01, WeMos D1 Mini (ESP-12F), today the ESP Witty (ESP-12F), it always produces the the same error:

    "Uncaught InternalError: Not connected to the internet"

    So I'm on a Chromebook and using the Web IDE. And just now I plugged in an ESP Witty (basically just a 12F module), and uploaded the following code:

    console.log("hello");
    

    What I got back was:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v92.902 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 4MB:512/512, manuf 0xe0 chip 0x4016
    >Erasing Flash..................
    Writing...
    Compressed 25600 bytes to 31
    Loading 31 bytes from flash...
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    

    etc etc. I have no idea if anyone else experiences it. I thought to go through the Espruino source, but I'm a bit wrapped up with projects right now, and don't have time to learn how to debug at that level, yet.

  • Interestingly if I press the reset button the board I get the following:

    >;ld|dà|Ädìc<ì{ÛcÄ#ónglgnãìcp${$sdpò'àlcoã<cûgnçdÄÇd`'l`orÇ'd`8ûoà;Üãàb'ã|äÇcû'oîd`ogl n{glxóoà{ãàälcgã|cûg'çl no$`g{ol`rÛgl`{lnûgnãÄ{'ogÄdÄcdì$ä$dl{lällloãddldì$ÄnàoìÛo~ldàbì$dpcÃcrìd`ol8ìl cd`$'gÛãnl|l$`sdãänì{ûo|äll`ã{dþLoading 31 bytes from flash...
    >
    =undefined
    >
    

    and can play around with the command prompt as normal. But if I do a reset () / load () the error comes back as follows:

    >
    =undefined
    >reset()
    =undefin
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v92.902 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 4MB:512/512, manuf 0xe0 chip 0x4016
    >load()
    =undefined
    Loading 31 bytes from flash...
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    

    Interestingly, if I use E.setBootCode to erase the flash the problem doesn't go away:

    E.setBootCode("")
    Erasing Flash..................
    Writing...
    Compressed 25600 bytes to 8
    Checking...
    Done!
    >
    =undefined
    >reset()
    =undefin
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v92.902 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 4MB:512/512, manuf 0xe0 chip 0x4016
    >load()
    =undefined
    Loading 8 bytes from flash...
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    

    So not sure.

  • I just tested it on latest version 1v93. still got "Uncaught InternalError: Not connected to the internet" error.

  • I wonder if this is something to do with Telnet or something like that? It may not be related to modules at all.

    Any ideas @Wilberforce?

  • I think this could be related to the address of functions getting called from an earlier version of the firmware. If flash and blank out the code area, and then upload your code again, it might all go away...

    Sorry, can't recall the address to flash too.

  • @Wilberforce This wouldn't apply to virgin modules (stock Espressif firmware), which you then erased and flashed with Espruino, would it? This is what I've been using mostly. Anyways as I mentioned, E.setBootCode("") doesn't fix the problem....

  • @hungryforcodes - ok - get your point after a flash erase.

    This is a bit odd - searching the sources for that error message - no ESP8266 sources come up:

    https://github.com/espruino/Espruino/sea­rch?utf8=%E2%9C%93&q=Not+connected+to+th­e+internet&type=

    So if the "Modules uploaded as functions" is left off - everything works as usual?
    If that is the case it looks like the addition of this feature has changed the start up initialisation order and wifi does not get initialised?

  • @Wilberforce Maybe we're getting warmer. So to summarize:

    1/ If I do not use "Save On Send" -- IE: disable the feature in question, all is normal. There are absolutely no problems.

    2/ If I DO enable "Save On Send", then AFTER all the code has been uploaded (looking at the green bar in the lower right in the Web IDE), and AFTER the message (suggesting the code has been saved to flash successfully):

    >Erasing Flash..................
    Writing...
    Compressed 25600 bytes to 31
    Loading 31 bytes from flash...
    Uncaught InternalError: Not connected to the internet
    

    the ESP8266 gives us an endless stream of "Not connected to the internet".

    3/ If I unplug the ESP module and plug it back in, none of my code executes, however I have the normal Espruino prompt. At this point if I do "dump()" I get the message:

    Connected
    >
    >dump()
    // Code saved with E.setBootCode
    =undefined
    > 
    

    so then if I type "load()". I get the following:

    >dump()
    // Code saved with E.setBootCode
    =undefined
    >load()
    =undefined
    Loading 31 bytes from flash...
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    Uncaught InternalError: Not connected to the internet
    

    So it definitely seems to be something about the initialization and loading of the code.

    4/ If I save the code normally (IE: without the feature in question enabled), I can easily always reset() and load() code without any problems (and do so frequently for debugging purposes etc).

    So this suggests to me there is something about either Save on Send, or something about E.setBootCode() which is implicated in this. Again, not sure.

  • @hungryforcodes
    this load() issue has been seen before - @MaBe might recall and have some input.

  • I'm getting the same thing on the ESP32. It looks like if this option is enabled, then on restart the code gets executed before the network stack is initialised.

  • It looks like if this option is enabled, then on restart the code gets executed before the network stack is initialised.

    Yep, that's what you'd expect I guess. It's executed just before onInit is called - so if you were doing something that required network connectivity in your code, I guess it would error.

    Of course if your code didn't do anything with the network, that'd be a bit odd?

  • @Wilberforce @Gordon As I said before I uploaded just:

    console.log("hello");
    

    And this was from a virgin ESP that I flashed with a recent version of Espruino (you can look above).

    As far as I know that shouldn't do anything. So are there default modules.js that are loaded before my code? Something else?

    -hfc

  • Hmm - there's nothing built in that should be accessing the internet, except Telnet on the ESP8266...

    Can you try: TelnetServer.setOptions({mode:'off'}) and save() and see if that helps?

  • Hi Gordon,

    I tried your script. It looks like "TelnetServer" lib is not available.

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v93 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 4MB:512/512, manuf 0xe0 chip 0x4016
    >Uncaught ReferenceError: "TelnetServer" is not defined
     at line 1 col 13
    TelnetServer.setOptions({mode:'off'});
                ^
    =undefined
    
  • Sorry, not sure what to suggest - it looks from the code like it should be in there.

  • Maybe I try your script in wrong way? I typed

    TelnetServer.setOptions({mode:'off'})
    

    in the left-hande side terminal of Web IDE.
    I also put it in the right-hand side editor and click "Send to Espruino".
    Both return following error messge

    Uncaught ReferenceError: "TelnetServer" is not defined
     at line 1 col 13
    TelnetServer.setOptions({mode:'off'});
    

    Is any other way to test it in web IDE or other tools?

  • Hi guys,

    Someone helped and committed a fix for the "Uncaught InternalError: Not connected to the internet" error. Here is the commit in his pull request.
    https://github.com/espruino/Espruino/pul­l/1197/commits/ca67ee67bc881bd4a507a867e­d5de4cada932e66

  • Yep, it works - big thanks to iotong

  • Cheers - fix also folding into ESP32 branch:

    https://github.com/espruino/Espruino/pul­l/1202

  • Yay! ;)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Modules uploaded as functions on Esp8266

Posted by Avatar for LeoWang @LeoWang

Actions