littlefs block size configurable?

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
MicroRichard
Posts: 15
Joined: Tue Aug 09, 2022 11:32 am

littlefs block size configurable?

Post by MicroRichard » Tue Aug 09, 2022 12:42 pm

I'm wondering if the littlefs block size can be configured in micropython. I am using logfiles to write to.
The command: 'info = os.statvfs("/data")' returns "File system block size: 4096, free blocks: 345"
Does this mean that every created file on the littlefs filesystem is by default 4096 bytes in size? Is it possible to reduce this size?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: littlefs block size configurable?

Post by Roberthh » Tue Aug 09, 2022 1:14 pm

block_size is that of the underlying flash chip, e.g. for erase. It does not affect the number and sizes of file. lfs can have more files than blocks.

MicroRichard
Posts: 15
Joined: Tue Aug 09, 2022 11:32 am

Re: littlefs block size configurable?

Post by MicroRichard » Tue Aug 09, 2022 1:25 pm

It was my understanding that with a blocksize of 4096 it does not matter if the filesize is 1 byte or 4000 bytes. The file will be 4096 bytes in size...or isn't this correct?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: littlefs block size configurable?

Post by Roberthh » Tue Aug 09, 2022 2:03 pm

Don’t think so. I just made a little test for confirmation. On a lfs file system with 255 blocks of 4096 byte size I have created 500 files of 256 byte size with different content. I could read them back properly with the right content, and delete them.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: littlefs block size configurable?

Post by jimmo » Thu Aug 11, 2022 1:20 am

Yeah the block size for littlefs is just so that it manages the underlying flash device correctly.

Unlike fatfs where a single file must own the entire cluster.

Post Reply