Why LittleFS lacks fs_format function?

Hi everyone.

I'm using nRF Connect SDK 2.6.1.
I'm implementing LittleFS for file management on an external QSPI-Flash.
I need to format the flash and erase all of data. I searched "zephyr/fs/fs.h", but I couldn't find any function which can do this like as "fs_format".
Before, I've used LittleFS functions directly by other IDEs and MCUs. I used to format the flash using "lfs_format".
I'll be happy to guide me.

Thanks in advance
Mehdi Sadeghian

  • I think it's better to reply my question by myself.

    After some efforts, I found fs_mkfs function can format the file system and there is no fs_format function.

    You can find an example of its using in your NCS samples folder: "\zephyr\samples\subsys\fs\format".

    You must at first enable the format functionality by putting the below config in "prj.conf" file:

    CONFIG_FILE_SYSTEM_MKFS=y

    But just keep in mind that select the correct partition that you want to format, for me the partition name is littlefs_storage (You can find the partition name in "nRF Connect > Memory Report > Partitions" menu):

    #define MKFS_DEV_ID FIXED_PARTITION_ID(littlefs_storage)


    Happy Coding
    Mehdi Sadeghian

Related