Skip to content

spiffs auto format selector (true by default) #5255

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

Closed
wants to merge 6 commits into from

Conversation

d-a-v
Copy link
Collaborator

@d-a-v d-a-v commented Oct 17, 2018

To help debugging #2581 (wemos/lolin d1 mini pro and/or 16MB flash):
ESP.setAutoFormatSPIFFS() will not format SPIFFS when mount fails.

Helpers set in ESP:: because this is the most simple way.
SPIFFS real interface is hard to reach from userland.

@d-a-v
Copy link
Collaborator Author

d-a-v commented Oct 18, 2018

To the question: why not SPIFFS.begin((autoFormat=)false), the answer is:
SPIFFS's type is not SPIFFSImpl:: but FS:: and this is a bag of bones.

This PR is mainly here to help debugging.
We can remove that once we have reliable 16MB SPIFFS.
Or rewrite it when FS (sd, spiffs) is refactored.

@earlephilhower
Copy link
Collaborator

earlephilhower commented Dec 26, 2018

@d-a-v, I've got the same issue. Maybe if we did something like make a per-FS configuration object?

class FSConfig {
public:
  FSConfig();
}; // empty base

class SPIFFSConfig : public FSConfig {
public:
 SPIFFSConfig(bool autoFormat = false) {_autoFormat = autoFormat; }
 void disableAutoFormat() { _autoformat = false; }
 bool _autoFormat;
};

class SDFSConfig : public FSConfig {
public:
  SDFSConfig(int cs = 4, SPISettings spi =SPI_MHZ(10)) {
    _cs = cs; _spi = spi;
   }
  int _cs;
  SPISettings spi;
};

Then the FSImpl object begin signature becomes:
begin( FSConfig &cfg = nullptr );

SPIFFS::begin can then static_cast its pointer to SPIFFSConfig, etc.

User code then becomes
SPIFFS.begin() or SPIFFS.begin( SPIFFSConfig(false) ); or SPIFFSConfig cfg; cfg.disableAutoFormat(); SPIFFS.begin(cfg);

@d-a-v
Copy link
Collaborator Author

d-a-v commented Dec 26, 2018

This PR was a proposal,
You are currently mastering FSImpl with new SD, LittleFS, with SPIFFS.
I was thinking of adding a virtual autoformat FSImpl call but @devyte, or you might think differently.
I'm not hitting the Close&Comment button right now, but my finger is burning.
Please do your magic!

@earlephilhower
Copy link
Collaborator

@d-a-v, take a look at #5525 which is my proposal for this (SPIFFS and SDFS now, LittleFS once one or the other merges).

@d-a-v
Copy link
Collaborator Author

d-a-v commented Jan 3, 2019

closed in favor of #5525

@d-a-v d-a-v closed this Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants