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

ESP8266 flash write cycle limit #1147

Closed
GelirDurum opened this issue Mar 10, 2016 · 18 comments
Closed

ESP8266 flash write cycle limit #1147

GelirDurum opened this issue Mar 10, 2016 · 18 comments
Assignees

Comments

@GelirDurum
Copy link

I have a problem with ESP8266 12E and 12F series about write commands. When I need to write data to the flash in ESP8266 it only allows to around 6800 times with (w+) command. I am using both integer and float and lastest and previous firmwares but nothing changes. An example simple code is below. With ESPlorer I run the codes and when both test1 lua and test2 lua reaches to 3400 file system starts to reset the module. I only activate module by formatting it. If I use just one file it reaches around 6800 cycle of writing. With (a+) command and 2 files I only managed to write up to total 13600 number somehow. Then again a format is needed. I do not how to erase and where to erase flash form lua file. Any help would be appreciated.

test=0
tmr.alarm(6, 100, 1, function() 
             file.open("test1.lua","w+")       
              file.writeline(test)
            file.close()
             file.open("test2.lua","w+")       
              file.writeline(test)      
            file.close()

            test=test+1
end)
@akalinin-ms
Copy link

I have this problem too. And in native C (not only in lua module).

@pjsg
Copy link
Member

pjsg commented Mar 10, 2016

On lua, does the module reset? If so, then can you provide the output of node.bootreason() and the contents of the mapfile that was output by the build.....

@akalinin-ms
Copy link

I have other observation(suspicion). With SPIFFS_DGB. I saw next picture.

page index byte len:         256
object lookup pages:         1
page pages per block:        16
page header length:          5
object header index entries: 107
object index entries:        125
available file descriptors:  4
free blocks:                 135

All static but except "free blocks".


free blocks:                 133
free blocks:                 131
free blocks:                 129
...

free blocks:                 5
free blocks:                 3
Reset reason: REASON_EXCEPTION_RST
free blocks:                 3
Reset reason: REASON_EXCEPTION_RST
...

"free blocks" have leaks. It is happened if we run timer once and reset device. Sorry for my bad grammar.

@pjsg
Copy link
Member

pjsg commented Mar 12, 2016

I'm trying to debug this issue -- I suspect that it is another alignment error. It turns out that the current version of spiffs from the master repo has a (difference) alignment error in it. Unfortunately, I'm finding it difficult to build the nodemcu flavor of spiffs with the testcases. I'm trying to build it on my linux system. The other option would be to move to the newer version of spiffs and move it over, being careful not to edit most of the files (to make it easy to bring new patches over in the future).

Thoughts?

@devyte
Copy link

devyte commented Mar 12, 2016

For what it's worth, in my experience, it pays off in the long run to bite the bullet in these cases, meaning go to the newer spiffs version, and pave the way for easier upgrades later.

@pjsg
Copy link
Member

pjsg commented Mar 13, 2016

I suspect that you are right -- but this will require significant testing. I'm reluctant to do this in a hurry. The good news is that there are some changes in the base source to deal with systems that have alignment constraints.

@GelirDurum
Copy link
Author

I try same code with dev branch for 30 hours. I wrote over then 1000000 cycle. Dev branch have no error for this issue.

@akalinin-ms
Copy link

I found my fix: pellepl/spiffs@7c54937

My spiffs before fail on spiffs_gc_check when fs.free_blocks < 3.

@akalinin-ms
Copy link

I suggest to take over the bug fix for pellepl/spiffs@7c54937

@pjsg
Copy link
Member

pjsg commented Mar 15, 2016

My feeling is that we want to take the real spiffs master code rather than cherry-picking individual commits. However, the spiffs code currently fails the spiffs self-tests when using our settings for block/sector/page sizes. I filed a ticket: pellepl/spiffs#77 for them to investigate.

@pjsg pjsg self-assigned this Mar 15, 2016
@pjsg
Copy link
Member

pjsg commented Mar 17, 2016

With the new master code, the lua code above runs for over 6300 iterations before I got bored. This would seem to be an improvement! There will be a PR for this fix soon.

@TerryE
Copy link
Collaborator

TerryE commented Mar 17, 2016

Philip, the OP quoted 6800 as the failure point.

@pjsg
Copy link
Member

pjsg commented Mar 17, 2016

The 6800 was with one file, it was 3400 with two files as in the sample code (or at least that is what I understood)

@jmattsson
Copy link
Member

@pjsg The spiffs version used in spiffsimg matches our current NodeMCU version and does run the test suite, if that helps?

@pjsg
Copy link
Member

pjsg commented Mar 18, 2016

There is a format change in the latest version of spiffs. I was thinking of binding the spiffsimg code much more tightly to the nodemcu code -- making it use the same set of sources so that we are assured that it is binary compatible.

@pjsg
Copy link
Member

pjsg commented Mar 19, 2016

I ran the test for 32000 cycles -- still working fine!

@TerryE
Copy link
Collaborator

TerryE commented Mar 19, 2016

Philip, have a look at my luac.cross patch. This works the issue of how to dual use, in ESP and on host.

marcelstoer pushed a commit that referenced this issue Jun 5, 2016
Fixes #1164 and thus also #1150, #1149, #1147 and #898.

* Move to latest version of SPIFFS
* Add SPIFFS porting layer for NodeMCU
* Add option to delete output if it doesn't fit
* Change FLASHSIZE to be in bits by default: default 4mb 32mb
* Add SPIFFS_MAX_FILESYSTEM_SIZE override
* Add notes on SPIFFS_FIXED_LOCATION
* Add 1M boundary
* Include the current version of the LICENSE
@marcelstoer
Copy link
Member

Fixed by #1226.

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

No branches or pull requests

7 participants