Skip to content

Commit dd87deb

Browse files
committed
Add SPIFFS Component to IDF
1 parent 1f8d93f commit dd87deb

21 files changed

+2039
-4
lines changed

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@
2929
[submodule "components/libsodium/libsodium"]
3030
path = components/libsodium/libsodium
3131
url = https://github.com/jedisct1/libsodium.git
32+
33+
[submodule "components/spiffs/spiffs"]
34+
path = components/spiffs/spiffs
35+
url = https://github.com/pellepl/spiffs.git

components/fatfs/src/vfs_fat_spiflash.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ esp_err_t esp_vfs_fat_spiflash_mount(const char* base_path,
3232
const size_t workbuf_size = 4096;
3333
void *workbuf = NULL;
3434

35-
esp_partition_t *data_partition = (esp_partition_t *)esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_FAT, partition_label);
35+
esp_partition_subtype_t subtype = partition_label ?
36+
ESP_PARTITION_SUBTYPE_ANY : ESP_PARTITION_SUBTYPE_DATA_FAT;
37+
const esp_partition_t *data_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,
38+
subtype, partition_label);
3639
if (data_partition == NULL) {
3740
ESP_LOGE(TAG, "Failed to find FATFS partition (type='data', subtype='fat', partition_label='%s'). Check the partition table.", partition_label);
3841
return ESP_ERR_NOT_FOUND;

components/spiffs/Kconfig

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
menu "SPIFFS Configuration"
2+
3+
config SPIFFS_MAX_PARTITIONS
4+
int "Maximum Number of Partitions"
5+
default 3
6+
range 1 10
7+
help
8+
Define maximum number of partitions
9+
that can be mounted.
10+
11+
menu "SPIFFS Cache Configuration"
12+
config SPIFFS_CACHE
13+
bool "Enable SPIFFS Cache"
14+
default "y"
15+
help
16+
Enables/disable memory read
17+
caching of nucleus file system
18+
operations.
19+
20+
config SPIFFS_CACHE_WR
21+
bool "Enable SPIFFS Write Caching"
22+
default "y"
23+
depends on SPIFFS_CACHE
24+
help
25+
Enables memory write caching for
26+
file descriptors in hydrogen.
27+
28+
config SPIFFS_CACHE_STATS
29+
bool "Enable SPIFFS Cache Statistics"
30+
default "n"
31+
depends on SPIFFS_CACHE
32+
help
33+
Enable/disable statistics on caching.
34+
Debug/test purpose only.
35+
36+
endmenu
37+
38+
config SPIFFS_PAGE_CHECK
39+
bool "Enable SPIFFS Page Check"
40+
default "y"
41+
help
42+
Always check header of each
43+
accessed page to ensure consistent state.
44+
If enabled it will increase number
45+
of reads, will increase flash.
46+
47+
config SPIFFS_GC_MAX_RUNS
48+
int "Set Maximum GC Runs"
49+
default 10
50+
range 1 255
51+
help
52+
Define maximum number of gc runs to
53+
perform to reach desired free pages.
54+
55+
config SPIFFS_GC_STATS
56+
bool "Enable SPIFFS GC Statistics"
57+
default "n"
58+
help
59+
Enable/disable statistics on gc.
60+
Debug/test purpose only.
61+
62+
config SPIFFS_OBJ_NAME_LEN
63+
int "Set SPIFFS Maximum Name Length"
64+
default 32
65+
range 1 256
66+
help
67+
Object name maximum length. Note that this length
68+
include the zero-termination character,
69+
meaning maximum string of characters can at most be
70+
SPIFFS_OBJ_NAME_LEN - 1.
71+
72+
config SPIFFS_USE_MAGIC
73+
bool "Enable SPIFFS Filesystem Magic"
74+
default "y"
75+
help
76+
Enable this to have an identifiable spiffs filesystem.
77+
This will look for a magic in all sectors
78+
to determine if this is a valid spiffs system
79+
or not on mount point.
80+
81+
config SPIFFS_USE_MAGIC_LENGTH
82+
bool "Enable SPIFFS Filesystem Length Magic"
83+
default "y"
84+
depends on SPIFFS_USE_MAGIC
85+
help
86+
If this option is enabled, the magic will also be dependent
87+
on the length of the filesystem. For example, a filesystem
88+
configured and formatted for 4 megabytes will not be accepted
89+
for mounting with a configuration defining the filesystem as 2 megabytes.
90+
91+
menu "Debug Configuration"
92+
93+
config SPIFFS_DBG
94+
bool "Enable general SPIFFS debug"
95+
default "n"
96+
help
97+
Enabling this option will print
98+
general debug mesages to the console
99+
100+
config SPIFFS_API_DBG
101+
bool "Enable SPIFFS API debug"
102+
default "n"
103+
help
104+
Enabling this option will print
105+
API debug mesages to the console
106+
107+
config SPIFFS_GC_DBG
108+
bool "Enable SPIFFS Garbage Cleaner debug"
109+
default "n"
110+
help
111+
Enabling this option will print
112+
GC debug mesages to the console
113+
114+
config SPIFFS_CACHE_DBG
115+
bool "Enable SPIFFS Cache debug"
116+
default "n"
117+
depends on SPIFFS_CACHE
118+
help
119+
Enabling this option will print
120+
Cache debug mesages to the console
121+
122+
config SPIFFS_CHECK_DBG
123+
bool "Enable SPIFFS Filesystem Check debug"
124+
default "n"
125+
help
126+
Enabling this option will print
127+
Filesystem Check debug mesages
128+
to the console
129+
130+
config SPIFFS_TEST_VISUALISATION
131+
bool "Enable SPIFFS Filesystem Visualization"
132+
default "n"
133+
help
134+
Enable this option to enable SPIFFS_vis function
135+
in the api.
136+
137+
endmenu
138+
139+
endmenu

components/spiffs/component.mk

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
COMPONENT_ADD_INCLUDEDIRS := include
2+
COMPONENT_PRIV_INCLUDEDIRS := spiffs/src
3+
COMPONENT_SRCDIRS := . spiffs/src

0 commit comments

Comments
 (0)