Skip to content

littlefs

sipke edited this page Jun 11, 2019 · 23 revisions

https://github.com/ARMmbed/littlefs

Uses for loops with initialisation, so C99 is required. -std=c99 will need to be added to compiler options.

lfs_util.h contains a few debug/error macros, which utilise printf, so depending on whether your system has printf you may get warnings to deal with.

Suggested option in lfs_utils.h is to write your own config file and use -DLFS_CONFIG=lfs_config.h to have it included instead of lfs_utils.h, which means you need to copy and adjust anything needed.

If your compiler and associated system files does not have inttypes.h (see for example https://github.com/openbsd/src/blob/master/include/inttypes.h) you will need to add one or just define the following few which are needed by the debug macros.

#define PRIu16 "u" /* uint16_t */

#define PRIu32 "u" /* uint32_t */

If your system does not have printf, you can take the easy option at least initially and disable them using compiler defines (see lfs_util.h). LFS_NO_DEBUG, LFS_NO_WARN, LFS_NO_ERROR, LFS_NO_ASSERT Alternatively you need to provide a printf, or if you have created an lfs_config.h file replace printf with an appropriate debug print function on your system.

Additionally if you have a very restricted microcontroller, its likely you will want to set both or one of define LFS_NO_MALLOC, LFS_NO_ASSERT The first ensuring that memory allocation is not used, and the second if you do not want assert functionality.

If you want assert, then you will also need uintptr_t which is an optional C99 type, so may not exist in your system. Again you will need to typedef this yourself to the appropriate 'pointer size' for your system.

If you do provide your own lfs_config.h file, LFS_CONFIG will not be defined, so the lfs_crc function will not be built either. This means you need to create your own, or copy the implementation to a file which is going to build this into your image.

Clone this wiki locally