-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Question: Can I open two files from SPIFFS at same time? #4140
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
Comments
@drschlaumeier You can have multiple open files. Run this sketch to see how many open files your flash chip supports. //Good tec data here: https://nurdspace.nl/ESP8266 #include "FS.h" void setup() { SPIFFS.begin(); float fileTotalKB = (float)fs_info.totalBytes / 1024.0; float flashChipSize = (float)ESP.getFlashChipSize() / 1024.0 / 1024.0; Serial.println("=========================================================="); Serial.printf("__________________________\n\n"); Serial.println("Flash chip information: "); Serial.println("File system (SPIFFS): "); Dir dir = SPIFFS.openDir("/"); } void loop() { |
@drschlaumeier you do this: |
@ondabeach |
@ondabeach also, I believe that loop opens one file at a time during the iteration. |
Thanks @jonhp, I hadn't noticed that. I just went in to add the escapes and they were already there... I could swear I didn't fix it already so maybe my IDE has auto syntax correct :) Or maybe I had more glasses of vino that I thought ;) Sorry @devyte, I was only answering OP's question of whether it was possible or not, and giving a way to check his chip's specs. I wasn't offering to rewrite his code for him. Is that considered poor form?? I agree, that sketch or something similar would be a good addition to examples. Especially since there's a flood of esp-01 (and probably other) modules with a new brand/family of flash chips( PUYA) hitting the market that aren't supported by the current(any?) version of SPIFFS. Having that sketch in examples would be a good way to get peeps to check their flash chip. |
@ondabeach not at all, I'm just saying that OPs question was about multiple files opened simultaneously, while you said:
Your example seems to open all files, but only one is open at any given moment. Unless I'm missing something? It could be modified to open multiple files to test, though. But like I said above, I think OPs problem is elsewhere. |
All good @devyte. The sketch tells you how many files can be open simultaneously using fs_info.maxOpenFiles, I guess it would've been more helpful to actually demonstrate doing so... but hey, call me lazy ;) |
@ondabeach oh I did in fact miss that. But in older core versions there were other reasons that you couldn't have multiple files opened at the same time related to implementation details. I was thinking of that, and of of a test I did ages ago to check precisely if you could have multiple files opened simultaneously. |
@drschlaumeier I might add a bit more to it first. |
Hallo all, thanks a lot for all the input. @devyte , was right: It was the PROGMEM. @ondabeach , thanks for the sketch. fs_info.maxOpenFiles says max 5 open files. Interresting. I did not know the limit. It helped to further optimize the code. It took some days to rewrite some code to save RAM/Stack but now I have more than 5k free and all works very stable. I also had to move some code from esp into html - javascript (e.g. dynamic generation of form data with jquery) to save space and improve the performance. The limits of esp82xx are reached very fast :-(. DRS |
@drschlaumeier the ESP32 comes with a whole host of problems. I will be sticking with ESP8266 for now. |
Hallo,
I'm trying to optimize my code since I need to save RAM/Stack. See #4115
I came to the idea that I could move some stuff to SPIFFS. I want to read a file line by line and at the same time save some of that lines modified into another/new file on SPIFFS. So I have two files open, one for reading and one for writing.
However, If I try to open the second file for writing the ESP crashes.
Exception 3: LoadStoreError: Processor internal physical address or data error during load or store
Is it NOT allowed to have two files open the same time? So I need to search somewhere else why my code crashes?
Thanx in advance DRS
Here some code:
The text was updated successfully, but these errors were encountered: