esp8266 save() wrong js code, auto reset and crash

Posted on
  • Hi,

    I have a nodemcu board (esp8266-esp12). I saved a wrong js code into. Now I can't save a new working code.

    I got this from the chrome ide:

    Connected
    > 30648, room 16
    Connected
    >{ll|$à|Ädìc<Çä{ÛcÄbóogl'oÜãì[#p](http://forum.espruino.com/search/?q­=%23p)ì${ls$pò'àlcoã<ìÇ#óogïll ogl n;ÛgÜlxûoà;ãà#'ã|lbóogç$`Ø'oll n{gl``óoàcnlûg'çdpûgàsãàcnâ|cÄò'oï$l`Ø'od`gsobã$`rÛgcãl`çÿYåÍõ66515 rtc=17857
    {$§Loading -491521 bytes from flash...
    

    I reflashed with this command (as i flashed first time the espruino firmware):

    ./esptool -bm qio -bz 512K -bf 40 -cp /dev/ttyUSB0 -cb 115200 -cd nodemcu -ca 0x00000 -cf espruino_esp8266_board_0x00000.bin -ca 0x10000 -cf espruino_esp8266_board_0x10000.bin
    

    I installed arduino dev. env. And successfully uploaded wifi and blink code to it, so the board is working. After that I re flashed the espruino binaries, but it's is wrong.

    What can I do to continue develop js code, and can save a new working code?

    regards
    HyGy

  • What is the correct way to clear this part of the flash?

    Now i successfully cleared. But I think this is not the "beauty" way. I reflashed the original NODEMCU flash bin:

    ./esptool -bm qio -bz 512K -bf 40 -cp /dev/ttyUSB0 -cb 115200 -cd nodemcu -ca 0x00000 -cf nodemcu_float_0.9.6-dev_20150704.bin

    than flash back the new espruino flash:

    ./esptool -bm qio -bz 512K -bf 40 -cp /dev/ttyUSB0 -cb 115200 -cd nodemcu -ca 0x00000 -cf espruino_esp8266_board_0x00000.bin -ca 0x10000 -cf espruino_esp8266_board_0x10000.bin

  • Howdy @hygy. See issue #661. (https://github.com/espruino/Espruino/iss­ues/661). Any thoughts and comments in that issue are very welcome.

  • So you don't have to read through that issue: flash blank.bin to 0x7C000.

  • Maybe it will be good, if I can clear the flash from the espruino ide somehow.

  • I am also having trouble with resets. I have cleared 0x00000, through 0x300000.
    This started when I tried to save code to flash. the write seemed successful but after this I've had problems. Kolban's example simple web server crashes/reboots as below whereas before It would run properly. Sadly, I have a second virgin nodemcu module that I also programed with 1.87 and it also resets. Any suggestions on this issue as well as a comprehensive way to clear all flash.? Any help greatfully accepted.
    Regards, Jim Brooks
    ets Jan 8 2013,rst cause:2, boot mode:(3,7)
    load 0x40100000, len 1396, room 16
    tail 4
    chksum 0x89
    load 0x3ffe8000, len 776, room 4
    tail 4
    chksum 0xe8
    load 0x3ffe8308, len 540, room 4
    tail 8
    chksum 0xc0
    csum 0xc0
    2nd boot version : 1.4(b1)
    SPI Speed : 80MHz
    SPI Mode : QIO
    SPI Flash Size & Map: 32Mbit(512KB+512KB)
    jump to run user1 @ 1000
    don't use rtc mem data

  • Moving this one to the ESP8266 section of the forum - I believe this kind if problem is relatively common...

  • You don't say how you flashed the board but would recommend esptool - helpful when you want to completely wipe flash.

    esptool.py erase_flash

  • Hello Ollie,
    Hopefully I'm replying in the write place now. Sorry if not.
    I used the Espruino programmer and last time. I used esptool.py erase_flash this time.
    In either case, after erasing, I used esptool.py to program the module with Espruino code.
    "esptool.py --port COM4 --baud 460800 write_flash --flash_freq 80m --flash_mode qio --flash_size 32m 0x0000 "boot_v1.4(b1).bin" 0x1000 espruino_esp8266_user1.bin 0x37E000 blank.bin"
    I then loaded the simpler web server example from Kolban.
    "function beServer()
    {
    var http = require("http");
    var httpServer = http.createServer(function(request, response)
    {

    print(request);
    if (request.url == "/favicon.ico")
    {
      response.writeHead(404);
      response.end("");
      return;
    }
    
    response.write("<html><body>");
    if (request.url == "/hello")
    {
      response.write("<b>Welcome</b> to the ESP8266 test.");
    } else if (request.url == "/goodbye"){
      response.write("<b>Please</b> come back again soon.");
    } else {
      response.write("Sorry... I didn't understand!");
    }
    response.end("</body></html>");
    

    }); // End of one new browser request

    httpServer.listen(80);
    print("Now being an HTTP server!");
    

    } // End of beServer

    var ssid = "COZYPINES";
    var pwd = "";
    // Slow down clock
    var E =require("ESP8266");
    E.setCPUFreq(80);

    // Connect to the access point
    var wifi = require("Wifi");
    print("Connecting to access point.");
    wifi.connect(ssid, {password:pwd}, function(err)
    {
    if (err)
    {

    print("Error connecting to access point.");
    return;
    

    }
    var ESP8266 = require("ESP8266");
    print("Connect says that we are now connected!!");
    print("Starting web server at http://" + wifi.getIP().ip + ":80");
    beServer();
    });
    "
    In either case, when I upload the server example to the module, first I get success. with an IP acquired.
    A short time 30s? later I get
    ets jan 8 2013, rst cause:, boot mode:(3,6)
    load 0x40100000, len 1396, room 16... there is more but I can't clip out of window.
    Bottom line is the module is rebooting. I have it running off the usb port. Is this the issue?
    I scoped the 3V line of the module and while I see noise (tx bursts) on the rail, it is in the mV are.

  • I tried this using the Arduino Ide.
    Here is the result.
    I was able to browse to the address and get the response from the 8266 but now it is resetting every 30 seconds or so.
    Have I messed up the watchdog settings? Do you need to configure them separately from the code?
    The newbie stage is so painful. Sorry to be such a pain.

    "Connected to COZYPINES
    IP address: 10.1.1.150
    MDNS responder started
    HTTP server started
    "

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

    ctx: sys
    sp: 3ffffd80 end: 3fffffb0 offset: 01a0

    stack>>>
    3fffff20: 4021afcf 005e0001 40210af0 3ffecd28
    3fffff30: 3fff0e4c 00000001 4021b00e 40210b09
    3fffff40: 4021ae1d 3fff15dc 3fffff80 3fff12cc
    3fffff50: 3ffe0000 3fff0e4c 3ffee800 4021b7d0
    3fffff60: 3fff15dc 3fff12cc 3ffe9bbc 4021a56f
    3fffff70: 3fff12cc 00000014 4021ab1a 3fff15dc
    3fffff80: 3fff12cc 3fffdc80 3fff1324 3ffefd10
    3fffff90: 402264d3 3fff15dc 00000000 4020632f
    3fffffa0: 40000f49 3fffdab0 3fffdab0 40000f49
    <<<stack<<<

    ets Jan 8 2013,rst cause:2, boot mode:(3,6)

    load 0x4010f000, len 1264, room 16
    tail 0
    chksum 0x42
    csum 0x42
    ~ld

    ....
    Connected to COZYPINES
    IP address: 10.1.1.150
    MDNS responder started
    HTTP server started

  • Your example does not seem very complex, and you've obtained an IP address.

    The only thing I typically would not have in my code is changing the clock speed. I don't know the implications of that - maybe none. Why do you do that out of interest?

    But if this reboots after a set period, the first thing I'd check would be power. The NodeMCU should not need capacitors - at least I've never needed anything other than the board, but are you confident that the USB supply is providing enough power? Maybe try a wall mounted USB supply, and connect to the board over Telnet to upload the code.

    You are probably aware you can permanently save wifi settings with wifi.save() which makes the boards very convenient to work with wirelessly.

  • I changed the clock code on spec that it may be running too fast. saw somewhere the clock was set higher by Espruino. I have another issue now. Using esptool.py to erase flash, everything is fine but it says this may take a while but ends immediately after. I tried loading the latest 1_89 and get this error. I'm just spinning my wheels now. I've attached a picture of the Espruino IDE reset o/p and my flash program batch file. Any suggestions gratefully appreciated.


    1 Attachment

  • Hm 1 file per post. Here is the reset o/p from the Espruino IDE.


    1 Attachment

    • reset op Espruino 1_89 NodeMCU V3.png
  • And just like that it's working. Left it running. Came back for the college try and it works without rebooting. Still have issue with PinState #defines changed error.

  • @user67974 - there is an open issue 929

    not sure if this a flash problem

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

esp8266 save() wrong js code, auto reset and crash

Posted by Avatar for hygy @hygy

Actions