littlefs2_fs.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 OTA keys S.A.
3  * SPDX-FileCopyrightText: 2020 Inria
4  * SPDX-License-Identifier: LGPL-2.1-only
5  */
6 
7 #pragma once
8 
23 #include <stdalign.h>
24 
25 #include "vfs.h"
26 #include "lfs.h"
27 #include "mtd.h"
28 #include "mutex.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
39 #ifndef CONFIG_LITTLEFS2_LOOKAHEAD_SIZE
41 #define CONFIG_LITTLEFS2_LOOKAHEAD_SIZE (16)
42 #endif
43 
44 #ifndef CONFIG_LITTLEFS2_FILE_BUFFER_SIZE
48 #define CONFIG_LITTLEFS2_FILE_BUFFER_SIZE (0)
49 #endif
50 
51 #ifndef CONFIG_LITTLEFS2_READ_BUFFER_SIZE
55 #define CONFIG_LITTLEFS2_READ_BUFFER_SIZE (0)
56 #endif
57 
58 #ifndef CONFIG_LITTLEFS2_PROG_BUFFER_SIZE
61 #define CONFIG_LITTLEFS2_PROG_BUFFER_SIZE (0)
62 #endif
63 
64 #ifndef CONFIG_LITTLEFS2_CACHE_PAGES
67 #define CONFIG_LITTLEFS2_CACHE_PAGES (1)
68 #endif
69 
70 #ifndef CONFIG_LITTLEFS2_BLOCK_CYCLES
73 #define CONFIG_LITTLEFS2_BLOCK_CYCLES (512)
74 #endif
75 
76 #ifndef CONFIG_LITTLEFS2_MIN_BLOCK_SIZE_EXP
80 #define CONFIG_LITTLEFS2_MIN_BLOCK_SIZE_EXP (-1)
81 #endif
87 typedef struct {
88  lfs_t fs;
89  struct lfs_config config;
95  uint32_t base_addr;
96 #if CONFIG_LITTLEFS2_FILE_BUFFER_SIZE || DOXYGEN
99  alignas(uint32_t) uint8_t file_buf[CONFIG_LITTLEFS2_FILE_BUFFER_SIZE];
100 #endif
101 #if CONFIG_LITTLEFS2_READ_BUFFER_SIZE || DOXYGEN
104  alignas(uint32_t) uint8_t read_buf[CONFIG_LITTLEFS2_READ_BUFFER_SIZE];
105 #endif
106 #if CONFIG_LITTLEFS2_PROG_BUFFER_SIZE || DOXYGEN
109  alignas(uint32_t) uint8_t prog_buf[CONFIG_LITTLEFS2_PROG_BUFFER_SIZE];
110 #endif
112  alignas(uint32_t) uint8_t lookahead_buf[CONFIG_LITTLEFS2_LOOKAHEAD_SIZE];
113  uint16_t sectors_per_block;
115 
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
#define CONFIG_LITTLEFS2_READ_BUFFER_SIZE
Read buffer size, if 0, dynamic allocation is used.
Definition: littlefs2_fs.h:55
#define CONFIG_LITTLEFS2_PROG_BUFFER_SIZE
Prog buffer size, if 0, dynamic allocation is used.
Definition: littlefs2_fs.h:61
#define CONFIG_LITTLEFS2_LOOKAHEAD_SIZE
Default lookahead size.
Definition: littlefs2_fs.h:41
#define CONFIG_LITTLEFS2_FILE_BUFFER_SIZE
File buffer size, if 0, dynamic allocation is used.
Definition: littlefs2_fs.h:48
const vfs_file_system_t littlefs2_file_system
The littlefs vfs driver.
Mutex for thread synchronization.
littlefs descriptor for vfs integration
Definition: littlefs2_fs.h:87
mtd_dev_t * dev
mtd device to use
Definition: littlefs2_fs.h:90
uint16_t sectors_per_block
number of sectors per block
Definition: littlefs2_fs.h:113
uint32_t base_addr
first block number to use, total number of block is defined in config.
Definition: littlefs2_fs.h:95
mutex_t lock
mutex
Definition: littlefs2_fs.h:91
MTD device descriptor.
Definition: mtd.h:111
Mutex structure.
Definition: mutex.h:36
A file system driver.
Definition: vfs.h:386