-
• #2
It could be that the read/write file does time wise not fit into the window the ESP8266's wifi stack provides for other code to run before it has to answer its next own interrupt. An ESP8266 has just not much cycles left to do other (demanding) things. To stay (far or absolutely) away from this issue, go for a two processor setup: an Espruino board and just for wifi pair it with any ESP8266... that lets you skip a lot of issues and saves you tons of time... way beyond the money you spend. Reliable (1 'wire', and radio/RF IS one wire) communication requires dedicated resources, because it is all time sensitive serialized...
-
• #3
Choose the correct spi pins for ESP8266
-
• #4
Do you think that software SPI does not work as expected?
-
• #5
Could you pls share the complete code? How do you get your code onto the board?
-
• #6
Thats all my code, what else you need. I can upload here to my binaries. https://www.upload.ee/download/10990396/d43c5ce2825416a80736/espruino_2v04_esp8266_4mb.tgz
Accordingly PINs are right as hardware SPI. -
• #7
sorry, was obviously not clear in my post - my bad: With complete code I was looking just for the JavaScript source and the description of the process how you uploaded it to the board.
(I was not expecting the firmware / bin that you custom-build and flashed onto the board).
-
• #8
I was using Espruino IDE as expected :) And it does matter if I execute code into flash or ram, crashes both ways. I suspect something else in deeper, but I 'm not able to debug it :(
-
• #9
Did you put your code into an the
onInit(){...}
function or into a function (path) that is called from withinonInit(){...}
function? -
• #10
I've already tried it, many different ways. Still crashing each time. Perhaps someone can try my binaries :) ?
-
• #11
If hadware SPI does not work than try software SPI and start like this and change the pins as needed.
var spi = new SPI(); spi.setup({sck:NodeMCU.D2, miso:NodeMCU.D4, mosi:NodeMCU.D3}); E.connectSDCard(SPI1, NodeMCU.D8 /*CS*/); console.log(require("fs").readdirSync());
-
• #12
Well well well... now this is strange. I'm able to list content of SD card, but still unable to read or write.
I formatted SD card to FAT32 and wrote a empty file test.txt and then executed same example. Also I tried to use SoftwareSPI, different pins ... but still same behavior .
____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v04 (c) 2019 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:1024/1024, manuf 0x5e chip 0x4016 >[ "System Volume Information", "test.txt" ] >require("fs").readFileSync("test.txt") 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 : DIO SPI Flash Size & Map: 32Mbit(1024KB+1024KB) jump to run user1 @ 1000 ãägä;ón|ìldll`cÛ<slgàgãd`ãsldþ ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v04 (c) 2019 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:1024/1024, manuf 0x5e chip 0x4016
What I'm doing wrong :(
-
• #13
Just tried once to use fs but figured out in needs too much memory.
so maybe you are running out of memory.
you can remove Graphic from you build
use process.memory() and check the difference
ESP8266 for this commands
require("ESP8266").logDebug(enable) require("ESP8266").setLog(2)
Is there a reason why you use cmd and not the WebIDE?
-
• #14
I'm using WebIDE, there is possible to use "console" also :) But, still no luck. I recompiled without Graphics and still same behavior. Using this following test code:
function onInit(){ console.log(JSON.stringify(process.env)); console.log('A: ', process.memory()); require("ESP8266").logDebug(true); require("ESP8266").setLog(2); console.log(require("ESP8266").getState()); console.log('B: ', process.memory()); var fs = require("fs"); console.log('C: ', process.memory()); SPI1.setup({ sck:NodeMCU.D5, miso:NodeMCU.D6, mosi:NodeMCU.D7 }); E.connectSDCard(SPI1, NodeMCU.D8 /*CS*/); console.log('D: ', process.memory()); console.log(fs.readdirSync()); console.log('E: ', process.memory()); console.log(fs.readFileSync("test.txt")); console.log('F: ', process.memory()); }
And here is a result:
____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v04 (c) 2019 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:1024/1024, manuf 0x5e chip 0x4016 {"VERSION":"2v04","GIT_COMMIT":"3956264e","BOARD":"ESP8266_4MB","FLASH":0,"RAM":81920,"SERIAL":"500291c3-483d","CONSOLE":"Serial1","MODULES":"Flash,Storage,heatshrink,fs,net,dgram,http,NetworkJS,Wifi,ESP8266,TelnetServer,crypto,neopixel","EXPTR":1073643640} A: { "free": 1508, "usage": 92, "total": 1600, "history": 62, "gc": 0, "gctime": 1.913 } { "sdkVersion": "2.2.0-dev(9422289)", "cpuFrequency": 160, "freeHeap": 12888, "maxCon": 10, "flashMap": "4MB:1024/1024", "flashKB": 4096, "flashChip": "0x5e 0x4016" } B: { "free": 1505, "usage": 95, "total": 1600, "history": 62, "gc": 0, "gctime": 1.915 } C: { "free": 1502, "usage": 98, "total": 1600, "history": 62, "gc": 0, "gctime": 1.897 } D: { "free": 1479, "usage": 121, "total": 1600, "history": 62, "gc": 0, "gctime": 1.934 } [ "System Volume Information", "test.txt" ] E: { "free": 1479, "usage": 121, "total": 1600, "history": 62, "gc": 0, "gctime": 1.936 } 53313> Fatal exception 3(LoadStoreErrorCause): ÿ53314> epc1=0x4000bdcb, epc2=0x00000000, epc3=0x00000000, excvaddr=0x4026e0d0, depc=0x00000000 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 : DIO SPI Flash Size & Map: 32Mbit(1024KB+1024KB) jump to run user1 @ 1000 âägä{ón|ìldll`cÛ|slgàoãd`ãsllþ ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v04 (c) 2019 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:1024/1024, manuf 0x5e chip 0x4016 >
And xtensa doc says that error "Fatal exception 3(LoadStoreErrorCause)" is described as "Processor internal physical address or data error during load or store [Exception Option]".
-
• #15
Yes I see.....
Now we get into very deep water's ...... some code is not aligned well for the ESP8266.
To be honest for device with low vars and small heap a 4k oriented filesystem is a killer, as you painful figure out by yourself.
Is using the internal memory mapped storage an alternative for you to use?
Storage space is 48 x 4096 byte = 196.608 byte
I use it to store code, modules, configs, web pages and images.
What do you think?
Hello
I've compiled my own v204 version of Espruino, using following params:
And code in Espruino:
And constantly it crashes after "reading" or "writing" a file.
Any ideas why it crashes?