You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upon power up of embedded device, We are reading some configurations from file and writing some initial data(Reset Counter) immediately in file.
Steps to generate problem
When we power cycle device continuously, Sometime file goes in this state (File is present (We can open it) but we can't Read/Write/Delete it).
Initial Analysis
When file corrupts (Goes in above mentioned state), Page header flag value was 254 or 124 (1st bit from 0th location was present mean writing is not finalized/under modification or 7th bit was zero mean page deleted respectively, Ref File: spiffs_nucleus.h, Line No - 288).
Return with error SPIFFS_ERR_NOT_FINALIZED/SPIFFS_ERR_DELETED respectively while read from below line of code, File : spiffs_nucleus.c, Line No : 27 SPIFFS_VALIDATE_DATA(ph, fd->obj_id & ~SPIFFS_OBJ_ID_IX_FLAG, spix);
Same flag was 252 when file was healthy (Not corrupted).
In Depth Analysis to generate the issue manually in debug mode
Flow of execution related to busy writing flag under
spiffs_object_modify (clearing busy writing flag and then deleting original page)
// write all data
// write partial data
// copy unmodified data
// Clear flag Manual Reset the system (In debug mode)
p_hdr.flags &= ~SPIFFS_PH_FLAG_FINAL;
// delete original data page
=> In the first case if we reset the system manually , File is not corrupting. So I am assuming it will take data from original page which we haven't deleted.
spiffs_object_truncate (deleting original page first and then clearing busy writing flag)
// delete last page, partially
// allocate new page and copy unmodified data
// delete original data page Manual Reset the system (In debug mode)
p_hdr.flags &= ~SPIFFS_PH_FLAG_FINAL;
=> But in second case, If we do manual reset (In debug mode), As original page is deleted it will take data from new page and chance that file is being corrupted.
What we do to recover system
As file number/name is fixed, We have to erase the full chip.
So can you suggest any solution to get out from this situation.
What best I can think of is, Always remove busy flag when user close the file.
The text was updated successfully, but these errors were encountered:
Highlights of operations what we do in our system
Upon power up of embedded device, We are reading some configurations from file and writing some initial data(Reset Counter) immediately in file.
Steps to generate problem
Initial Analysis
SPIFFS_VALIDATE_DATA(ph, fd->obj_id & ~SPIFFS_OBJ_ID_IX_FLAG, spix);
In Depth Analysis to generate the issue manually in debug mode
Flow of execution related to busy writing flag under
spiffs_object_modify (clearing busy writing flag and then deleting original page)
// write all data
// write partial data
// copy unmodified data
// Clear flag
Manual Reset the system (In debug mode)
p_hdr.flags &= ~SPIFFS_PH_FLAG_FINAL;
// delete original data page
=> In the first case if we reset the system manually , File is not corrupting. So I am assuming it will take data from original page which we haven't deleted.
spiffs_object_truncate (deleting original page first and then clearing busy writing flag)
// delete last page, partially
// allocate new page and copy unmodified data
// delete original data page
Manual Reset the system (In debug mode)
p_hdr.flags &= ~SPIFFS_PH_FLAG_FINAL;
=> But in second case, If we do manual reset (In debug mode), As original page is deleted it will take data from new page and chance that file is being corrupted.
What we do to recover system
The text was updated successfully, but these errors were encountered: