Pkg.LittleFS — API for parsing LittleFS file system images¶
Overview¶
The Pkg.LittleFS module contains the API for parsing LittleFS file system images.
LittleFS is a block-based file system designed for microcontrollers, with a focus on power-loss resilience and wear leveling. It is widely used in embedded devices built on platforms such as ESP32, STM32, nRF52, RP2040, and Mbed OS. The module supports both inline files and CTZ skip-list files, with CRC-32 verified metadata and redundant block pairs.
Enumerating LittleFS Files¶
The following code example demonstrates how to enumerate files in a LittleFS file system:
from Pro.Core import *
from Pkg.LittleFS import *
def enumerateFiles(fname):
c = createContainerFromFile(fname)
if c.isNull():
return
obj = LittleFSObject()
if not obj.Load(c) or not obj.Initialize():
return
print("Block size:", obj.GetBlockSize())
print("Block count:", obj.GetBlockCount())
nre = CFSNonRecursiveEnum(obj)
nre.AddPath(obj.FSRootDirectory())
while True:
f = nre.Next(None)
if not f:
break
entry = obj.FSGetEntry(f, None)
if not entry.IsNull():
print(entry.Name(), entry.DataSize())
Module API¶
Pkg.LittleFS module API.
Classes:
This class represents a LittleFS file system image.
- class LittleFSObject¶
Bases:
Pro.Core.CFFObjectThis class represents a LittleFS file system image.
LittleFS is a block-based file system designed for microcontrollers with power-loss resilience and wear leveling. The class provides file system support through the CFS interface inherited from
CFFObject, with support for both inline and CTZ skip-list file storage.Methods:
Returns the total number of blocks in the file system.
Returns the block size of the file system in bytes.
Returns the number of directories in the file system.
Returns the number of regular files in the file system.
Returns the on-disk version of the file system.
- GetBlockCount() → int¶
Returns the total number of blocks in the file system.
- Returns
Returns the block count.
- Return type
int
- GetBlockSize() → int¶
Returns the block size of the file system in bytes.
- Returns
Returns the block size.
- Return type
int
- GetDirectoryCount() → int¶
Returns the number of directories in the file system.
- Returns
Returns the directory count.
- Return type
int
- GetFileCount() → int¶
Returns the number of regular files in the file system.
- Returns
Returns the file count.
- Return type
int
- GetVersion() → int¶
Returns the on-disk version of the file system.
The upper 16 bits contain the major version, the lower 16 bits the minor version.
- Returns
Returns the version.
- Return type
int