-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
SPIFFs File Corruption #3096
Comments
I have just tried: function wf(n,r)
local f,s = file.open(n..'.txt','w'), ('0123456789abcdef'):rep(64)
for i=1,32 do f:write(s) end
file.remove(r..'.txt')
end
function cf()
local t = tmr.now(); wf(c, c-6); c=c+1
print("%u %8.2f" % {c, (tmr.now() - t)/1000000})
if c<l then node.task.post(cf) end
end
c = 0 l = 500 cf() and this chunders away happily recycling the FS and doing GC without any obvious errors. |
What does for k,v in pairs(node.getpartitiontable()) do print("%s=0x%x" % {k,v}) end printout? |
`For the SPIFFS almost "no free and never touched page" case (no corruption yet)....
|
Single page writes do not seem to cause the problem. I repeated the presented test case with smaller files. Corruption occurred if I approached the cliff from my stated starting point (image 06) with three 8k byte files each. I then reduced this to two 8ks, followed by one 4k, followed by two 2ks and no corruption occurred. Then followed with one 8k for good measure and all was fine. It appears the edge case is when a larger file (say 8k or more) forces the gc. |
If I recall, block size is 8k (the eraseable unit). |
Try aligning the FS on a 1Mb boundary: node.setpartitiontable{spiffs_addr=0x100000,spiffs_size=0x300000} This will set the SPIFFS partition to be the last 3Mb and reboot the module. If this doesn't trigger a format then do a PS: sorry about using the string % operator: this was introduced in a recent |
Thanks for the try. No Go Though Here is a more credible MVCE of the issue
Find attached a serial console listing of the above process and f0509d.lua. |
Thanks. I'll give it a try |
The prior case (200509.zip) comes pretty close to filling SPIFFS. Here is a more representative case of real life: several files close to the beginning of the FS, then a bunch of deleted pages and finally several larger files (representing LFS uploads). Few "free" pages are left (plus a few used pages and a whole bunch of deleted pages in the middle). process flow
Of greatest interest in the attached listing
|
Oops, forgot the attachement. |
See also #3147. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Expected behavior
Actual behavior
Supplied cases show this occurs when all SPIFFs pages have been written once.
For a 4MB module, this usually takes awhile.
When no SPIFFs pages are free, but are either used or deleted, a garbage collection
operation must be performed to free the deleted pages. Sometimes this results in
Test code
Provide a Minimal, Complete, and Verifiable example which will reproduce the problem.
NodeMCU startup banner
You MUST include the firmware startup banner to describe the version you are using. We reserve the right to immediately close any bug that doesn't.
Nodemcu-build.com provided by frightanic.com
branch: master
commit: 3d91785
release:
release DTS: 202002231746
SSL: false
build type: float
LFS: 0x40000
modules: adc,bit,cron,dht,enduser_setup,file,gpio,mqtt,net,node,ow,pwm2,rtcmem,rtctime,sntp,struct,tmr,uart,wifi
build 2020-05-01 13:41 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)
Hardware
Describe which ESP8266/ESP32 device you use and document any special hardware setup
required to reproduce the problem.
Wemos D1 mini (4MB), aka esp-21 ref. below
Nodemcu V0.9 (4MB), aka esp-01 ref. below
Other Resources Used
FTP
https://nodemcu.readthedocs.io/en/master/lua-modules/ftpserver/
with several added hooks
use default user and pwd: "test","12345"
Serial Interface Software
Lua Loader 0.91
Flasher, Unloader
esptool.py
Local LUA code
as listed below to help reveal issue but does not cause it
Detailed Notes
How to find the "issue" locations?
Find the 4 locations below with "-->" in the left margin.
This is where expectations do not match reality.
Setup Process
What we have at this point
Corruption Process Steps for FTP
Corruption process Steps for serial upload
ESP-01 Tests
File contents corruption
Possible misreporting of remaining and used space
Final Notes
Attachments
ticket files.zip
The text was updated successfully, but these errors were encountered: