Comments (8)
Yes, you're correct in your reasoning. Creating an fs with e.g 32 blocks
and then mount it with 16 blocks at a later point would succeed at mount
point. However, if all 32 blocks contain data, the fs mounted with 16
would most certainly be corrupt, giving errors when reading and writing.
In fact, it might be impossible to do anything as spiffs must have at
least two blocks free.
Den 19 nov 2015 17:58 skrev "hreintke" [email protected]:
When mounting a FS with the the SPIFFS_USE_MAGIC set to 1, is then only
checked whether all blocks within the "FS range" having a magic number ?If so, would you detect a failure when FS is created with size 1000 and
mounted with size 500 ?If I missed the documentation for this, please point me to the location
and I will work from that.β
Reply to this email directly or view it on GitHub
#59.
from spiffs.
Btw, just out of curiosity, is there an actual case of this? I always presumed the user would know the size of the fs.
(Damn it's hard answering issues on the mobile with swedish autocorrection π)
from spiffs.
Thanks for the quick answer.
I am working on the sming framework for esp8266.
In there, there is the possibility to
- download (Over The Air) a pre-filled filesystem to the esp.
- when flashing the application,on the esp, a FS can also be flashed over serial.
- and of course, esp8266 come with different flash sizes, I would like to keep the application the same on all.
This means that the application using the FS is not the same as the application which created it.
-> There might be a mismatch
I was wondering whether it would be possible to have a :
- first page magic number
- middle pages magic number
- last page magic number
And so create an almost no overhead possibility to check FS size.
I am (not yet) into the details of Spiffs implementation. Could you point me to the part of the code I should be investigating for this.
from spiffs.
Hmm, yes, it would be possible to have certain magics depending on block placement. But, it is a bit trickier than that: among all blocks, spiffs allow one block to have no magic. This is for the case of power-loss during block erase. If such a block is found during mount, it is properly erased and magic is written.
In worst case, this could be the first or the last block, confusing a naive algorithm.
You'll find the code for this @ https://github.com/pellepl/spiffs/blob/master/src/spiffs_nucleus.c#L290
Alas, I am certainly no expert on the Sming framework, but perhaps it is possible to write the fs-size on some other place in the SPI-flash instead, e.g. some parameter/config area?
from spiffs.
Yes, sure there are also other possibilities, f.e. the config area you mentioned.
I am now in the investigation phase, and as such also understanding the possibilities of the frameworks we use.
One more question :
If such a block is found during mount, it is properly erased and magic is written.
Doesn't this way of working break FS consistency, or can you recreate the contents from other locations?
from spiffs.
When spiffs finds one block not being properly erased it assumes this was due to an aborted garbage collection. Spiffs only erases a block when any essential info has been moved (or a user calls format).
So, I really hope it does not break anything ;)
When spiffs finds more than one block not being properly erased, it assumes corrupt filesystem and formats the lot.
Oh, and by properly erased it means the magic is found in the block. Spiffs always writes the magic directly after it erased a block.
Considering unexpected power losses, erasing is the most time consuming operation, so it should statistically be more prone to be aborted.
from spiffs.
Great and well thought design and implementation.
Will close the issue and continue with my design investigation.
Thanks a lot for answering my questions so quickly and extensive.
from spiffs.
Thanks. Don't hesitate to ask if you have more questions. Cheers!
from spiffs.
Related Issues (20)
- What I think is a good idea for spiffs HOT 1
- Garbage collection issues HOT 1
- Cache size calculations are inconsistent?
- error -10027 HOT 1
- Corruption with multiple live object index pages
- Slow GC performance with frequent writes
- File write on ESP8266 using SPIFFS sometimes puts incorrect characters in file HOT 1
- Question on SPIFFS_ERR_BAD_DESCRIPTOR(-10010) error HOT 1
- Question about spiffs_obj_id sizing HOT 1
- Question on validating the files/CRC
- SPIFFS flash memory addresses
- Split Garbage Collection (SPIFFS_gc) Into Smaller Chunks
- Hardfault writing to work buffer pages
- Forcing garbage collection by creating files result in NMI handler, fixable by making some fields volatile
- SPIFFS_tell returns wrong position after write HOT 4
- Question regarding overwriting data
- SPIFFS says, File is present but not able to Read/Write/Delete.
- datalog value shows double
- Π‘annot use keywords as the variable name! HOT 1
- -10010 on example
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spiffs.