Skip to content
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

Add SPIFFS.unmount() for use in OTA.onEnd() #1657

Closed
andig opened this issue Feb 20, 2016 · 6 comments
Closed

Add SPIFFS.unmount() for use in OTA.onEnd() #1657

andig opened this issue Feb 20, 2016 · 6 comments

Comments

@andig
Copy link
Contributor

andig commented Feb 20, 2016

Use case: allow to store configuration from ram back to freshly updated SPIFFS. Avoid loss on configuration due to OTA wiping the filesystem config files.

Potential flow:

// OTA update overwrites SPIFFS and unmounts the SPIFFS library

ArduinoOTA.onEnd([]() {
  if (SPIFFS.begin()) {
    // write config files to spiffs again
  }
});

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@igrr igrr added this to the 2.2.0 milestone Feb 29, 2016
@igrr igrr self-assigned this Feb 29, 2016
@igrr igrr modified the milestones: 2.2.0, 2.3.0 Apr 18, 2016
igrr added a commit that referenced this issue May 20, 2016
@andig
Copy link
Contributor Author

andig commented Jun 2, 2016

Great stuff, thank you! Please feel free to close.

@andig
Copy link
Contributor Author

andig commented Jul 4, 2016

@igrr once OTA finishes I'm assuming that SPIFFS already is unmounted and I'd need to wrap further writes into SPIFFS begin/end. Is this correct?

@igrr
Copy link
Member

igrr commented Jul 4, 2016

I think you need to unmount SPIFFS before you start OTA, i.e. in ArduinoOTA onBegin handler or similar.
Once OTA is finished, you may mount it again in onEnd handler.

@andig
Copy link
Contributor Author

andig commented Jul 4, 2016

I think you need to unmount SPIFFS before you start OTA

If find that a bit confusing. Shouldn't- if SPIFFS is touched by OTA- the unmount be part of the default OTA code? Remounting is clear for the onEnd handler, but unmounting?

@igrr
Copy link
Member

igrr commented Jul 4, 2016

I see this the other way around. If you happen to use SPIFFS in the sketch, and you call SPIFFS.begin somewhere, you have to make sure you return SPIFFS to uninitialized state before modifying its flash storage.
I would find it confusing if .begin calls were at one level of abstraction (sketch) and .end calls were at lower layer (hidden inside the library).

@andig
Copy link
Contributor Author

andig commented Jul 4, 2016

I see this the other way around. If you happen to use SPIFFS in the sketch, and you call SPIFFS.begin somewhere, you have to make sure you return SPIFFS to uninitialized state before modifying its flash storage.

Right. That makes perfect sense! The only thing is- up to now this wasn't even possible ;) So just wondering if this is worth a note or even a comment line in one the OTA examples (may this would be a good place: https://github.com/esp8266/Arduino/blob/master/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino) to make sure people understand this?

Could do a PR for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants