Littlefs: Is lfs_config need to be persisent?

Created on 17 Aug 2020  路  3Comments  路  Source: littlefs-project/littlefs

Hello. Is it safe to free memory for struct lfs_config after lfs_mount() call?

question

All 3 comments

Hi @blomnik, yes lfs_config needs to persist. littlefs depends on it after mount.

The reason for this is that lfs_config is immutable and can be stored in flash this way, rather than copying the config into RAM in the lfs_t struct.

This may change in the future. The configuration is something that I'd like to look at again, and the idea of enabling compile-time configuration has been floated by other developers. And there's several cases where doing some minor work could reduce the code size (lookahead buffer byte->bit conversion for example, other NULL defaults). But if that happens a persistent lfs_config can still be provided without breaking backwards compatibility.

Oh, thank you for that fast repsonse. :)
Does it mean, that littlefs does not modify any field in struct lfs_config behind my back? So, this structure can be completly const?

Thank you.

Yep! lfs_mount/lfs_format take in a const*. The intention is for lfs_config to be stored in flash.

This doesn't do much if the configuration is calculated dynamically, such as in OSs, but it is a nice benefit for devices with very limited memory.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FrederikTB picture FrederikTB  路  4Comments

davidefer picture davidefer  路  7Comments

e107steved picture e107steved  路  9Comments

husigeza picture husigeza  路  9Comments

nizhq picture nizhq  路  3Comments