Problem building v1.96 + filesystem to ESP8266

Posted on
  • Hello, I'm fairly new to Espruino and recently bought a NodeMCUv3(esp8266). I've downloaded the latest releases and tested a few codes. I was developing a simple web server that would serve an html/css/js page, and the plan was to store them on an SD card.

    The problem is that ESP8266 doesn't have FS by default, so I've set to build my own firmware with fs enabled. While I can build and get all my binaries, if i ever type save() on the web IDE and hard reset the board, it prints like crazy "fatal exception(3)"

    Here are my codes:

    compile.sh

     #!/bin/bash
    export FAMILY=ESP8266
    export BOARD=ESP8266_BOARD
    export FLASH_4MB=1
    export ESP8266_SDK_ROOT=/espruino/ESP8266_NONOS­_SDK-1.5.4
    export PATH=$PATH:/espruino/esp-open-sdk/xtensa­-lx106-elf/bin/
    export COMPORT=/dev/ttyS2
    export USE_FILESYSTEM=1
    export USE_NET=1
    export USE_ESP8266=1
    export DEBUG=1
    make clean && make $*
    

    flashing command:

    esptool.py --port COM8 --baud 115200 write_flash --flash_freq 80m --flash_mode qio --flash_size 4MB 0x0000 boot_v1.6.bin 0x1000 espruino_esp8266_user1.bin 0x3FC000 esp_init_data_default.bin 0x3FE000 blank.bin
    

    I am running ubuntu on windows for compiling, and had to modify the ESP8266_NONOS_SDK c_types.h lines:

    //typedef unsigned long       uint32_t;
    typedef unsigned int       uint32_t;
    //typedef signed long         int32_t;
    typedef signed int         int32_t;
    

    Beyond that, I couldn't find how to not use a certain module, for example neopixel, which made me modify the c_types.h

    I'm also uploading my binaries if anyone wants to test them

    Any help on this matter is greatly appreciated.

    Thanks!


    1 Attachment

  • Beyond what I posted earlier, here is a web IDE console output whenever I upload a code:

    My code:

    var wifi = require("Wifi");
    wifi.setHostname("Espruino");
    wifi.stopAP();
    wifi.setIP({ip:"192.168.1.20",gw:"192.16­8.0.1",netmask:"255.255.255.0"},function­(err){});
    wifi.connect("SSID",{password:"PASS"},fu­nction(err){
        console.log("connected? err=",err,"info=", wifi.getIP());
      
        wifi.save();
    });
    
    SPI1.setup({mosi:D7,miso:D6,sck:D5});
    E.connectSDCard(SPI1,D8);
    
    var files = require('fs').readdirSync();
    for (var i in files)
      console.log("Found File" + files[i]);
    

    Console Output:

    >
     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     1v96 (c) 2017 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 0x20 chip 0x4016
    >ASSERT(jsvGetLocks(var)>0) FAILED AT src/jsvar.c:674
      #1[r1,l2] Object {
        #2[r1,l2] Name String [1 blocks] "\xFF"      #3[r1,l2] Object {
            #6[r1,l2] Name String [2 blocks] "timers"          #8[r2,l1] Array(0) [ ]
            #9[r1,l2] Name String [2 blocks] "watches"          #11[r2,l1] Array(0) [ ]
            #13[r1,l2] Name String [1 blocks] "net"          #14[r1,l2] String [1 blocks] "\x04\x00\x00\x00\x00\xFF\xFF\xFF"
            #21[r1,l2] Name String [2 blocks] "modules"          #23[r1,l1] Object {
                #25[r1,l2] Name String [1 blocks] "Wifi"              #24[r5,l3] ...
     
              }
            #15[r1,l2] Name String [2 blocks] "history"          #26[r1,l1] Array(3) [
                #27[r1,l2] Name Integer 0              #17[r1,l1] String [3 blocks] "var wifi = require(\"Wifi\");"
                #29[r1,l2] Name Integer 1              #30[r1,l1] String [3 blocks] "wifi.setHostname(\"Espruino\");"
                #28[r1,l2] Name Integer 2              #34[r1,l1] String [2 blocks] "wifi.stopAP();"
              ]
          }
        #16[r1,l2] Name String [1 blocks] "wifi"      #24[r5,l3] NativeFunction 0x4021bc6c (0) { }
      }
    ---console end---
     ets Jan  8 2013,rst cause:2, boot mode:(3,6)
    load 0x40100000, len 2408, room 16
    tail 8
    chksum 0xe5
    load 0x3ffe8000, len 776, room 0
    tail 8
    chksum 0x84
    load 0x3ffe8310, len 632, room 0
    tail 8
    chksum 0xd8
    csum 0xd8
    2nd boot version : 1.6
      SPI Speed      : 80MHz
      SPI Mode       : QIO
      SPI Flash Size & Map: 32Mbit(512KB+512KB)
    jump to run user1 @ 1000
    sp 0x3ffffcb0
    epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0xffffffef, depc=0x00000000
    Fatal exception (28):
    epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0xffffffef, depc=0x00000000
    Fatal exception (28):
    epc1=0x40001800, epc2=0x00000000, epc3=0x00000000, excvaddr=0xffffffef, depc=0x00000000
    Fatal exception (28):
    ...
    

    this last 2 lines repeat indefinetly, no matter if I hard reset the device. The only way out of this loop is to erase the flash and reupload the firmware

  • I thînk you are creating a firmware to large to fit on the board.

    Which modules get applied is controlled in the .py board file. Since you are have a 4mb module, you should use the esp8266_4mb firmware which also needs to be flashed a certain way.

    See here- the flash size parameter

    http://www.espruino.com/EspruinoESP8266

  • Add export RELEASE=1

  • Hello @MaBe, I've also tried building with export RELEASE=1, and got the same error.

    @Wilberforce Thanks for the insight, I may tweak a little on the packages. So far I don't need the graphics, do you know a way to omit it from the build?

  • Use the 4mb build and see here:

    https://github.com/espruino/Espruino/blo­b/9ffc5162047e93200e1356c3334b05f5ab67db­53/boards/ESP8266_4MB.py#L25

    Comment out and uncomment - and do a make clean

  • Thanks @Wilberforce, that worked. I can now use the save() and on reboot everything work fine.

    To be clear on the process, this is my modified python script:

    import os;
    import pinutils;
    info = {
     'name'            : "ESP8266",
     'espruino_page_link' : 'EspruinoESP8266',
     'default_console' : "EV_SERIAL1",
     'default_console_baudrate' : "115200",
     'variables'       : 1600,
     'binary_name'     : 'espruino_%v_esp8266_4mb',
     'build' : {
       'libraries' : [
         'NET',
         'TELNET',
         #'GRAPHICS',
         'CRYPTO',
         'NEOPIXEL',
         'FILESYSTEM',
         'FLASHFS'
       ],
       'makefile' : [
         'FLASH_4MB=1',
         'ESP_FLASH_MAX=962560',
         'FLASH_BAUD=460800'
        ]
     }
    ...
    

    This is my compile.sh

     #!/bin/bash
    export FAMILY=ESP8266
    export BOARD=ESP8266_4MB
    export FLASH_4MB=1
    export ESP8266_SDK_ROOT=/espruino/ESP8266_NONOS­_SDK-1.5.4
    export PATH=$PATH:/espruino/esp-open-sdk/xtensa­-lx106-elf/bin/
    export COMPORT=/dev/ttyS2
    export USE_ESP8266=1
    export RELEASE=1
    make clean && make $*
    

    And this is my flashing command using 1024/1024:

    esptool.py --port COM8 --baud 115200 write_flash --flash_freq 80m --flash_mode qio --flash_size 4MB-c1 0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 0x3FC000  esp_init_data_default.bin 0x3FE000 blank.bin
    

    There is only one question remaining, I've added the RELEASE=1 again to compress a little bit more the binary, and upon restarting if I'm connected do espruino IDE I get the following output

    >s$l<dà|lä#|ìÛsbcÄò'oß$g'ãäcpìÇdsdsdxóoàd[#g](http://forum.espruino.com/search/?q­=%23g)ã|#Äónoï$l Ø'o$`g{ol`pò'à{Üâàcoã|ìcûo'çl Ø'o$`gso$pò'à{Üâàälcoã|cûo'çl Ø'o$`gsol`rÛgl`{loû'oã{no'Äd#$älìl$l~;lìddlgâ$$l$äloàÇgä'dlàÀcäÄllxccx#{cpÄcc$lo'Äãgd|$l`{lãäoì;ûg|ìll`ã;ddþLoading 3627 bytes from flash...
    Running onInit()...
    

    If I open a PuTTY session, with a baud rate of 75600, I can read the printed message:

     ets Jan  8 2013,rst cause:2, boot mode:(3,7)
    
    load 0x40100000, len 2408, room 16
    tail 8
    chksum 0xe5
    load 0x3ffe8000, len 776, room 0
    tail 8
    chksum 0x84
    load 0x3ffe8310, len 632, room 0
    tail 8
    chksum 0xd8
    csum 0xd8
    
    2nd boot version : 1.6
      SPI Speed      : 80MHz
      SPI Mode       : QIO
      SPI Flash Size & Map: 32Mbit(1024KB+1024KB)
    jump to run user1 @ 1000
    
    rf cal sector: 128
    

    Is there any way to remove that from startup?

    Thanks again.

  • ah - so you have turned on flashfs - this will use the flash memory as a filesystem, and disable the code that uses the sd card. I guess you have not tested the sd card yet? You might need to reduce the number of variables as the flashes support creates a 4K buffer for the sectors in the flash memory.

    With regards to suppressing the boot messages- I'm not sure there is an easy way. On the esp32 you can hold a pin low to suppress the messages. Do some googling!

  • I have tried the SD card and it didn't work, now I know why.

    I have just asked about turning off those boot messages because I didn't recall them appearing on the stock Espruino firmware.

    I will recompile it turning flashfs off, and since the messages aren't really doing anything negative, I'll just leave them there.

    Thanks again for all the help.

  • Hi
    Sorry, can anyone share esp8266 nodeMCU firmware with working SDCard?
    i dont now, how to compile it :(
    Thanks, and sorry for bad english

  • Hello @Joshua_Sturmvogel, sorry for the delay in the response. I can share the firmware with you. Attached is my compiled version, based on the v1.96 release. This version is compiled with the following modules:

    NET
    TELNET
    CRYPTO
    NEOPIXEL
    FILESYSTEM
    

    Note that it will only work in a 4mb ESP8266. Mine specifically is a NodeMCU V3.

    Best Regards.

    EDIT:

    To be able to flash it without problems, you have to use the 1024/1024 flash map. Here is the esptool.py command for that:

    esptool.py --port [/dev/ttyUSB0|COM1] --baud 115200 write_flash 
      --flash_freq 80m --flash_mode qio --flash_size 4MB-c1 
      0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 
      0x3FC000  esp_init_data_default.bin 0x3FE000 blank.bin
    

    EDIT 2: Corrected the baud rate for the flashing command.


    1 Attachment

  • Thanks
    i try to flash board with Yours coomand, but as result i have:

                               <address> <filename> [<address> <filename> ...]
    esptool write_flash: error: argument --flash_size/-fs: invalid choice: '4mb-c1' (choose from '4m', '2m', '8m', '16m', '32m', '16m-c1', '32m-c1', '32m-c2')
    

    after change 4MB-c1 to 4m
    all flashed succses, but IDE don't recognize board

  • I think you might be using a different version of esptool.py.

    4M = 32 mBit so you could try 32m-c1

  • @Joshua_Sturmvogel If you flash only with 4m, the flash map will be set to 512/512, and the firmware will be too big to fit on the ESP memory, which will make it crash and printout a lot of errors. Try what Willberforce suggested, or updating your esptool.py to a more recent one. Just don't flash with the single 4m for it will not work.

  • Hi @Joshua_Sturmvogel,

    check your flash_id and lookup your memory

    esptool.py --port "$COMPORT" --baud 460800 flash_id
    
        Manufacturer: e0
        Device: 4016
        Detected flash size: 4MB
    
    • get a new release of esptool.py
    • read README_flash.txt which is part of the tgz file in comment #11

    Hope this helps you to find the correct setting to flash your board.

  • Thanks for all for answers

    on this moment:
    esptool.py v2.3.1
    erase and flash - all ok

    flash id output:

    C:\Users\Joshua\Desktop\espruino>python "../esptool/esptool.py" --port COM46 flash_id
    esptool.py v2.3.1
    Connecting....
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    Uploading stub...
    Running stub...
    Stub running...
    Manufacturer: 20
    Device: 4016
    Detected flash size: 4MB
    Hard resetting via RTS pin...
    

    flash log and command line ooutput:

    C:\Users\Joshua\Desktop\espruino>python "../esptool/esptool.py" --port COM46--baud 460800 write_flash --flash_freq 80m --flash_mode qio --flash_size 4MB-c1 0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 0x3FC000  esp_init_data_default.bin 0x3FE000 blank.bin
    esptool.py v2.3.1
    Connecting....
    Detecting chip type... ESP8266
    Chip is ESP8266EX
    Features: WiFi
    Uploading stub...
    Running stub...
    Stub running...
    Changing baud rate to 460800
    Changed.
    Configuring flash size...
    Flash params set to 0x006f
    Compressed 3856 bytes to 2763...
    Wrote 3856 bytes (2763 compressed) at 0x00000000 in 0.1 seconds (effective 482.0 kbit/s)...
    Hash of data verified.
    Compressed 533204 bytes to 351868...
    Wrote 533204 bytes (351868 compressed) at 0x00001000 in 7.9 seconds (effective 539.4 kbit/s)...
    Hash of data verified.
    Compressed 128 bytes to 77...
    Wrote 128 bytes (77 compressed) at 0x003fc000 in 0.0 seconds (effective 204.8 kbit/s)...
    Hash of data verified.
    Compressed 4096 bytes to 26...
    Wrote 4096 bytes (26 compressed) at 0x003fe000 in 0.0 seconds (effective 6553.5 kbit/s)...
    Hash of data verified.
    
    Leaving...
    Hard resetting via RTS pin...
    
    

    IDE still dont recognize board

    if i flash stock esp8266 4mb firmware - everething work ok, but without 'fs' support

  • Okay, so the error here appears to be on the baud rate. Set it 115200 instead of 460800. The espruino IDE can't recognize such a high baud rate, and won't be able to communicate with the board. This is what the command should look like:

    python "../esptool/esptool.py" --port COM46 --baud 115200 write_flash --flash_freq 80m --flash_mode qio --flash_size 4MB-c1 0x0000 "boot_v1.6.bin" 0x1000 espruino_esp8266_user1.bin 0x3FC000  esp_init_data_default.bin 0x3FE000 blank.bin
    

    By the way, you can install esptool using the pip manager for python. For me it's just a little bit more convenient.

    EDIT: grammar.

  • @Joshua_Sturmvogel

    can you attach

    • WEBIDE SETTINGS CONSOLE output
    • WED IDE output while trying to connect

    for further trouble shooting

  • Sorry for long time waiting
    in attach IDE settings and console output


    3 Attachments

    • 2018-04-21 (1).png
    • 2018-04-21 (3).png
    • 2018-04-21.png
  • Try changing the flash mode from qio to dio.

    I need to use dio on the nodemcu board I have.

  • This output still looks like a baud rate problem. Did you reflash the firmware with 115200? If you open a putty on 460800 does the output change?

  • I had the same problem, changing qio to dio solved my problem :)
    Thank you!

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

Problem building v1.96 + filesystem to ESP8266

Posted by Avatar for FStech @FStech

Actions