-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug SPI arbitration between FS and MCU? #1576
Comments
Are you reading from SPIFFS inside a ticker-function? If yes, then you shouldn't be doing that. Ticker-functions are supposed to be kept real short and you shouldn't be performing blocking actions in them and instead just set a flag there and perform the actual blocking action inside the loop(). |
Ah that's a valid point, thanks. I tried moving the code to loop(), but it really doesn't make a difference. ESP stops sending IP packets after 2-5 minutes with SPIFFS access, so I'm still leaning in the direction of arbitration. |
Well, I have no idea what's wrong. I serve files from SPIFFS all the time without an issue and I also allow for uploading of files to SPIFFS via the web-server. |
If you are using spiffs with me-no-dev's async webserver, then crashes are On Fri, Feb 5, 2016, 13:18 WereCatf notifications@github.com wrote:
|
Uhm, I may not completely understand. The webserver never reads SPIFFS, it just I'm not using AsyncWebserver, but AsyncTCP with a tiny GET parser with small c string functions, just to eliminate causes. I had the one and only SPIFFS read access ( And when IP stack is frozen, SPIFFS access still works, I checked via interactive shell on UART. If I do not use SPIFFS read in loop(), system has been running for 30 minutes with TCP request "bombardments" with no error and still delivering the sprintf'ed dynamic content. At times, 2-3 connections wait for web content in a connection queue, works without problems. I can try to use SyncTCP again, performance should be the same (if LWIP.a has a too small tcp_snd_buf compiled in, I'll have the 200ms Windows ACK delay). Will update as soon as I have something. |
Alright, after a lot of testing, here goes. The project is for WS2812 LEDs, therefore I use adafruits function to write the LEDs. The data sent to LEDs is read from an SPIFFS file, which also stores a delay until new LED data is to be sent ("animation"). Sending of LED data will only work flickerfree for a single frame of an animation (60 LEDs), if I disable and re-enable interrupts before and after the output function. I removed everything asynchronous from the sketch, only ESP8266 Webserver with its volatile bool loop_loadNewFrame;
void setup() { ... };
void loop() {
webserver.handleClient();
if (loop_loadNewFrame) {
loop_loadNewFrame = false;
ws2812_displayCurrentFrame();
ws2812_loadNextFrameFromSPIFFS();
animationDisplayTicker.once(ws2812_currentFrameDelay, animationDisplayTimer);
}
}
TickerCallback animationDisplayTimer() {
loop_loadNewFrame = true;
}
ws2812_displayCurrentFrame() {
noInterrupts(); ws8212_write(); interrupts();
} If I put the ws2812 code from loop() inside the ticker and access SPIFFS from there, the sketch will lockup WiFi IP core eventually and shortly after WDT reset. On the other hand, I need the webserver to run independently from the animation. Perhaps I'm doing something wrong? Loading the whole animation into RAM does not seem feasible... |
@igrr where is that optimistic_yield in SPIFFS that you think is making SPIFFS usage not thread safe? |
Hmm, I may have been wrong after all. Even when reading from loop() the sketch (above pseudo code structure) was leaking memory every second. I then removed the I then put the I've seen the source of the |
use the i2s implementation or maybe even the serial :) |
Small update here. I'm using @cnlohr s I2S implementation (stripped of his unnecessary stuff). It seems to work stable only if I'm making sure that only one single SPIFFS function is "active" at a time. If I'm reading a file and that gets interrupted by e.g. a SPIFFS dirlist ==> crash the ESP. The drawback obviously being no serial input anymore :( but I can live with that. |
I am curious what you think may cause that? I am unaware of any times buffer underflows, etc. can cause a reboot! |
Greetings advanced dev's,
I was having trouble with a sketch that serves HTTP requests while at the same time reading from SPIFFS (~200 bytes every 10ms from one single open file) for a Ticker based background task.
I assume that there are three parties accessing SPI flash:
PROGMEM
stored data independently from SPIFFS via different methods (webserversend_P()
,strcpy_P()
+send()
).This scenario crashes the ESP randomly, as described here. Either the IP subsystem freezes (not sending any wifi frames anymore), while background tickers continue to run (LED blinks, buttons work, serial output fine) or the ESP crashes with a stack trace completely.
I tracked this down to the SPIFFS. When I stop reading from the file completely (and increasing reading period interval just prolongs lifetime, but does not prevent the crashes, perhaps b/c at some point by random chance there is a clash), the webserver will continue to run indefinitely without any problems.
Is there any way to debug this ("SPIFFS" does not seem to be in the Debug-Level select list)?
The text was updated successfully, but these errors were encountered: