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

Allow SPIFFS update via ESP8266HTTPUpdateServer #3234

Closed
wants to merge 2 commits into from

Conversation

sandeen
Copy link

@sandeen sandeen commented May 11, 2017

This adds capability to update the SPIFFS image via
the same mechanism as firmware in the
ESP8266HTTPUpdateServer.

It does not provide any dependency or linkage between
firmware and spiffs image updating; they are each taken
on their own, each followed by a reboot.

(I wrote this before seeing the other PR #2701 for similar
functionality; I like this a bit better, because it uses
the available SPIFFS size, and does not hide magic numbers
(U_SPIFFS) in the html...)

(It also cleans up a stray \n from commit ace0622)

We'd really like to see this functionality in the library for the
OpenEVSE wifi project

This is my first try at this, mostly cribbing from the ESP8266httpUpdate version of the updater - happy to fix up anything as needed.

Thanks,
-Eric

This adds capability to update the SPIFFS image via
the same mechansism as firmware in the 
ESP8266HTTPUpdateServer.

It does not provide any dependency or linkage between
firmware and spiffs image updating; they are each taken
on their own, each followed by a reboot.

(I wrote this before seeing the other PR for similar
functionality; I like this a bit better, becaue it uses
the available SPIFFS size, and does not hide magic numbers
(U_SPIFFS) in the html...)

(It also cleans up a stray \n from commit ace0622)
@codecov-io
Copy link

Codecov Report

Merging #3234 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #3234   +/-   ##
======================================
  Coverage    27.6%   27.6%           
======================================
  Files          20      20           
  Lines        3655    3655           
  Branches      678     678           
======================================
  Hits         1009    1009           
  Misses       2468    2468           
  Partials      178     178

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ace0622...b08d896. Read the comment docs.

_setUpdaterError();
if (upload.name == "spiffs") {
size_t spiffsSize = ((size_t) &_SPIFFS_end - (size_t) &_SPIFFS_start);
if (!Update.begin(spiffsSize, U_SPIFFS)){//start with max available size
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call SPIFFS.end() here, or check that this is done by the caller?
In this default example this is likely to be not an issue, as we are resetting after the update. But may be an issue in other scenarios.

Copy link
Author

@sandeen sandeen May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting. The README does say Use this method before updating SPIFFS using OTA.
I didn't see anything like that in ./libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp either - should it get added to both?
With my filesystem developer hat on, yes, it seems crazy to be updating the storage behind a live, mounted filesystem, but I'm not that familiar with this particular situation.
I can add it and test a bit if you like.
Thanks,
-Eric

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think SPIFFS.end was only added recently, precisely for this use case. The libraries haven't been updated to take advantage of it, however. So updating the behavior of OTA libraries would indeed be welcome.

@devyte
Copy link
Collaborator

devyte commented Sep 6, 2017

Any progress with this? This is a very nice feature.

@caverna
Copy link
Contributor

caverna commented Oct 12, 2017

@sandeen great piece of software!!!
I was facing this issue: I have a ESP-01 (black), but I was limited to write only 512KB and 64KB of SPIFF.
But now I can unleash the whole 1MB!
Thank you a lot!
Do you need any help to prepare/adjust this PR to be able to merge to core?

</body></html>\n)";
<form method='POST' action='' enctype='multipart/form-data'>
Spiffs:<br>
<input type='file' name='spiffs'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about to include accept='.bin' in both fields to filter a little?

@caverna
Copy link
Contributor

caverna commented Oct 17, 2017

Hi @sandeen !
Would you like some help with the conflict?
It will be great to have this feature in next release...

@sandeen
Copy link
Author

sandeen commented Oct 17, 2017

I'm not currently working on this project and unfortunately don't have time to pick it up again right now, so I can't do proper testing a the moment. If anyone wants to take my patch as a base and get it done, go right ahead.

@caverna
Copy link
Contributor

caverna commented Oct 17, 2017

OK, I'll do it!

@earlephilhower earlephilhower added this to the 2.6.0 milestone May 2, 2019
@earlephilhower
Copy link
Collaborator

Seems like a reasonable, minor addition and looks like it's already in a state to use (modulo whenever LittleFS gets in and SPIFFS_end turns into FS_end). Let's consider this for 2.6.

@d-a-v
Copy link
Collaborator

d-a-v commented Aug 29, 2019

Closing, replaced by #3732

@d-a-v d-a-v closed this Aug 29, 2019
d-a-v pushed a commit that referenced this pull request Sep 20, 2019
* Allow SPIFFS update via ESP8266HTTPUpdateServer

This adds capability to update the SPIFFS image via
the same mechansism as firmware in the 
ESP8266HTTPUpdateServer.

It does not provide any dependency or linkage between
firmware and spiffs image updating; they are each taken
on their own, each followed by a reboot.

(I wrote this before seeing the other PR for similar
functionality; I like this a bit better, becaue it uses
the available SPIFFS size, and does not hide magic numbers
(U_SPIFFS) in the html...)

(It also cleans up a stray \n from commit ace0622)

* A simple filter

* Review #3234 (review)

* Including suggestions for mobile first #3961

* SPIFFS rennamed to FS

* including comments from @earlephihower

* button renaming

* missing #include for LittleFS

* generic names as suggested by @d-a-v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants