Skip to content

fix: recover from corrupt littlefs - #3012

Draft
benallfree wants to merge 1 commit into
meshcore-dev:devfrom
MeshEnvy:feature/fs-corruption-check
Draft

fix: recover from corrupt littlefs#3012
benallfree wants to merge 1 commit into
meshcore-dev:devfrom
MeshEnvy:feature/fs-corruption-check

Conversation

@benallfree

@benallfree benallfree commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Hey guys, this is a fix for a rare corner case where littlefs becomes corrupted somehow.

Currently, the device will get locked in a loop the first time it attempts to write to a corrupted littlefs.

This PR does an integrity check at boot. I'm not sure if this is the best approach but here to discuss.

Co-authored-by: Cursor <cursoragent@cursor.com>
@benallfree benallfree changed the title Companion: recover from corrupt littlefs at boot instead of freezing on first write recover from corrupt littlefs Jul 21, 2026
@benallfree benallfree changed the title recover from corrupt littlefs fix: recover from corrupt littlefs Jul 21, 2026
@IoTThinks

Copy link
Copy Markdown
Contributor

So this PR will format FS in case of FS corruption?

My T1000e corrupted FS a few times in last 3 months.

@benallfree

Copy link
Copy Markdown
Contributor Author

@IoTThinks that’s correct. As far as I know, there is no way to recover from a corrupted file system, so you might as well just format it and start again. But if I’m wrong about that, and there is someway to run a file system repair, we should consider that first.

@IoTThinks

IoTThinks commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

It is still better to recover and start over instead of stuck in bootloop.
I guess there is a major flaw in LittleFS. It seems very fragile.

Thanks a lot for the PR.

@benallfree

Copy link
Copy Markdown
Contributor Author

@IoTThinks does this one seem ready to move out of draft?

I think LittleFS v2 is better but upstream seems slow to adopt it.

@IoTThinks

Copy link
Copy Markdown
Contributor

@benallfree I haven't tested it.
I dont have 350+ contacts to simulate the corruption and test.

I guess slowness to go live as we need to export backup, fresh install and import the backup.

@benallfree

benallfree commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

@IoTThinks I'm not actually sure how LittleFS becomes corrupt. Do you know how to repro?

Or maybe we could add a fs corrupt CLI for testing purposes.

@IoTThinks

Copy link
Copy Markdown
Contributor

In another PR, Otalco (sorry for spelling) explained the case.

Have big contact list like 350 contacts.
During sync after connect or edit contact, quickly remove the power.

@benallfree

benallfree commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Yes I see now, #2964

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.

2 participants