1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

examples/filesystem: add support for littlefs2

Just like littlefs, but this is the current version of it.
This commit is contained in:
Benjamin Valentin 2020-06-30 16:23:20 +02:00 committed by Benjamin Valentin
parent af1bb27043
commit f69c0f9758
2 changed files with 21 additions and 4 deletions

View File

@ -33,6 +33,7 @@ USEMODULE += vfs
# Use a file system
USEMODULE += littlefs
# USEMODULE += littlefs2
# USEMODULE += spiffs
# USEMODULE += fatfs_vfs
USEMODULE += constfs

View File

@ -72,6 +72,22 @@ static littlefs_desc_t fs_desc = {
/* littlefs file system driver will be used */
#define FS_DRIVER littlefs_file_system
#elif defined(MODULE_LITTLEFS2)
/* include file system header for driver */
#include "fs/littlefs2_fs.h"
/* file system specific descriptor
* for littlefs2, some fields can be tweaked to define the size
* of the partition, see header documentation.
* In this example, default behavior will be used, i.e. the entire
* memory will be used (parameters come from mtd) */
static littlefs2_desc_t fs_desc = {
.lock = MUTEX_INIT,
};
/* littlefs file system driver will be used */
#define FS_DRIVER littlefs2_file_system
#elif defined(MODULE_SPIFFS)
/* include file system header */
#include "fs/spiffs_fs.h"
@ -153,7 +169,7 @@ static int _mount(int argc, char **argv)
{
(void)argc;
(void)argv;
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_FATFS_VFS))
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_LITTLEFS2) || defined(MODULE_FATFS_VFS))
int res = vfs_mount(&flash_mount);
if (res < 0) {
printf("Error while mounting %s...try format\n", FLASH_MOUNT_POINT);
@ -172,7 +188,7 @@ static int _format(int argc, char **argv)
{
(void)argc;
(void)argv;
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_FATFS_VFS))
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_LITTLEFS2) || defined(MODULE_FATFS_VFS))
int res = vfs_format(&flash_mount);
if (res < 0) {
printf("Error while formatting %s\n", FLASH_MOUNT_POINT);
@ -191,7 +207,7 @@ static int _umount(int argc, char **argv)
{
(void)argc;
(void)argv;
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_FATFS_VFS))
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_LITTLEFS2) || defined(MODULE_FATFS_VFS))
int res = vfs_umount(&flash_mount);
if (res < 0) {
printf("Error while unmounting %s\n", FLASH_MOUNT_POINT);
@ -283,7 +299,7 @@ static const shell_command_t shell_commands[] = {
int main(void)
{
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS))
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_LITTLEFS2))
/* spiffs and littlefs need a mtd pointer
* by default the whole memory is used */
fs_desc.dev = MTD_0;