Skip to content

Conversation

@tjko
Copy link
Contributor

@tjko tjko commented Sep 16, 2025

For your consideration to possibly add in the README.

littlefs-toy is a small command-line tools with tar like syntax for creating and modifying littlefs images. It supports working on littlefs filesystems embedded inside another file (firmware image, etc.) and can auto-detect blocksize when working on existing littlefs images.

@geky-bot
Copy link
Collaborator

Tests passed ✓, Code: 17112 B (+0.0%), Stack: 1448 B (+0.0%), Structs: 812 B (+0.0%)
Code Stack Structs Coverage
Default 17112 B (+0.0%) 1448 B (+0.0%) 812 B (+0.0%) Lines 2435/2595 lines (-0.0%)
Readonly 6230 B (+0.0%) 448 B (+0.0%) 812 B (+0.0%) Branches 1283/1616 branches (+0.0%)
Threadsafe 17964 B (+0.0%) 1448 B (+0.0%) 820 B (+0.0%) Benchmarks
Multiversion 17184 B (+0.0%) 1448 B (+0.0%) 816 B (+0.0%) Readed 29369693876 B (+0.0%)
Migrate 18776 B (+0.0%) 1752 B (+0.0%) 816 B (+0.0%) Proged 1482874766 B (+0.0%)
Error-asserts 17924 B (+0.0%) 1440 B (+0.0%) 812 B (+0.0%) Erased 1568888832 B (+0.0%)

@geky
Copy link
Member

geky commented Sep 23, 2025

Hi @tjko, thanks for the PR, this is a neat tool.

Can add this in on the next patch release, though note the eventual plan is to move the related projects section to its own wiki out-of-tree.

One concern with naming the binary lfs is this may make things confusing with littlefs-fuse (https://github.com/littlefs-project/littlefs-fuse) and I'm sure others using the same name.

I was curious how you auto-detected block size, so had a gander. If I understand correctly you're parsing the warning littlefs prints if it finds mismatched config (L586)? Unfortunately this won't work if after a power-loss the first block is erased. Otherwise we would auto-detect the block size in core littlefs.

The only option I know of currently to auto-detect block size without sacrificing power-loss resilience is to try every block size you want to support (#349).

Also in practice NAND flash tends to break expectations around block size. The most common chips seem to be around ~128KiB which looks like it's just above your expected 64KiB bounds (L591). I've seen block sizes in the MiBs which is what makes this problem so tricky (and unsolvable?). That and littlefs support non-powers-of-2.

@tjko
Copy link
Contributor Author

tjko commented Sep 25, 2025

@geky, you're right current binary name (lfs) could be confusing. It is now renamed to lfst, so it doesn't conflict with littlefs-fuse anymore.

Yes, I am capturing error/warning generated by lfs_mount() and if it reports "Invalid block size", I'll try to parse the actual block size from the error message.

Thanks, for pointing out the possible large block sizes (somehow, I had incorrectly assumed 64KiB was the maximum).
I removed the upper bound check on block size (L591), since doesn't seem it was really necessary.

@geky
Copy link
Member

geky commented Sep 25, 2025

Just to be clear, the binary rename is not a condition for merging. Feel free to keep the lfs name, though I do think it might be confusing for users with multiple tools installed. In the future I think littlefs-fuse's binary should probably be renamed to lfs2-fuse (or lfs2f?) to distinguish it from more general-purpose tools, but littlefs-fuse needs a revisit so it's been low-priority.

Will be bringing this in on the next patch release.

@geky geky changed the base branch from master to devel September 29, 2025 20:08
@geky geky merged commit adad0fb into littlefs-project:devel Sep 29, 2025
95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants