8
8
#ifndef SPIFFS_CONFIG_H_
9
9
#define SPIFFS_CONFIG_H_
10
10
11
+ // ----------- 8< ------------
12
+ // Following includes are for the linux test build of spiffs
13
+ // These may/should/must be removed/altered/replaced in your target
14
+ #include <stdio.h>
15
+ #include <stdlib.h>
16
+ #include <string.h>
11
17
#include <stddef.h>
12
18
#include <stdint.h>
13
19
#include <stdbool.h>
14
- #include <string.h>
15
- #include <stdio.h>
16
-
17
- typedef int16_t file_t ;
18
- typedef int32_t s32_t ;
19
- typedef uint32_t u32_t ;
20
- typedef int16_t s16_t ;
21
- typedef uint16_t u16_t ;
22
- typedef int8_t s8_t ;
23
- typedef uint8_t u8_t ;
24
-
25
- #ifndef SEEK_SET
26
- #define SEEK_SET 0 /* set file offset to offset */
27
- #endif
28
-
29
- #ifndef SEEK_CUR
30
- #define SEEK_CUR 1 /* set file offset to current plus offset */
31
- #endif
32
-
33
- #ifndef SEEK_END
34
- #define SEEK_END 2 /* set file offset to EOF plus offset */
35
- #endif
36
-
37
- #ifndef EOF
38
- #define EOF (-1)
39
- #endif
40
-
41
- // compile time switches
20
+ #include <unistd.h>
42
21
43
22
// Set generic spiffs debug output call.
44
23
#ifndef SPIFFS_DBG
45
- #define SPIFFS_DBG (...) //printf(__VA_ARGS__)
24
+ #define SPIFFS_DBG (_f , ...) //printf(_f, ## __VA_ARGS__)
46
25
#endif
47
26
// Set spiffs debug output call for garbage collecting.
48
27
#ifndef SPIFFS_GC_DBG
49
- #define SPIFFS_GC_DBG (...) //printf(__VA_ARGS__)
28
+ #define SPIFFS_GC_DBG (_f , ...) //printf(_f, ## __VA_ARGS__)
50
29
#endif
51
30
// Set spiffs debug output call for caching.
52
31
#ifndef SPIFFS_CACHE_DBG
53
- #define SPIFFS_CACHE_DBG (...) //printf(__VA_ARGS__)
32
+ #define SPIFFS_CACHE_DBG (_f , ...) //printf(_f, ## __VA_ARGS__)
54
33
#endif
55
34
// Set spiffs debug output call for system consistency checks.
56
35
#ifndef SPIFFS_CHECK_DBG
57
- #define SPIFFS_CHECK_DBG (...) //printf(__VA_ARGS__)
36
+ #define SPIFFS_CHECK_DBG (_f , ...) //printf(_f, ## __VA_ARGS__)
58
37
#endif
59
-
60
38
// Set spiffs debug output call for all api invocations.
61
39
#ifndef SPIFFS_API_DBG
62
- #define SPIFFS_API_DBG (...) //printf(__VA_ARGS__)
40
+ #define SPIFFS_API_DBG (_f , ...) //printf(_f, ## __VA_ARGS__)
63
41
#endif
64
42
43
+ // needed types
44
+ typedef int16_t file_t ;
45
+ typedef int32_t s32_t ;
46
+ typedef uint32_t u32_t ;
47
+ typedef int16_t s16_t ;
48
+ typedef uint16_t u16_t ;
49
+ typedef int8_t s8_t ;
50
+ typedef uint8_t u8_t ;
51
+
65
52
// Defines spiffs debug print formatters
66
53
// some general signed number
67
- #ifndef _SPIPRIi
68
54
#define _SPIPRIi "%d"
69
- #endif
70
55
// address
71
- #ifndef _SPIPRIad
72
56
#define _SPIPRIad "%08x"
73
- #endif
74
57
// block
75
- #ifndef _SPIPRIbl
76
58
#define _SPIPRIbl "%04x"
77
- #endif
78
59
// page
79
- #ifndef _SPIPRIpg
80
60
#define _SPIPRIpg "%04x"
81
- #endif
82
61
// span index
83
- #ifndef _SPIPRIsp
84
62
#define _SPIPRIsp "%04x"
85
- #endif
86
63
// file descriptor
87
- #ifndef _SPIPRIfd
88
64
#define _SPIPRIfd "%d"
89
- #endif
90
65
// file object id
91
- #ifndef _SPIPRIid
92
66
#define _SPIPRIid "%04x"
93
- #endif
94
67
// file flags
95
- #ifndef _SPIPRIfl
96
68
#define _SPIPRIfl "%02x"
97
- #endif
69
+
98
70
99
71
// Enable/disable API functions to determine exact number of bytes
100
72
// for filedescriptor and cache buffers. Once decided for a configuration,
@@ -127,9 +99,7 @@ typedef uint8_t u8_t;
127
99
#endif
128
100
129
101
// Define maximum number of gc runs to perform to reach desired free pages.
130
- #ifndef SPIFFS_GC_MAX_RUNS
131
- #define SPIFFS_GC_MAX_RUNS 5
132
- #endif
102
+ #define SPIFFS_GC_MAX_RUNS 10
133
103
134
104
// Enable/disable statistics on gc. Debug/test purpose only.
135
105
#ifndef SPIFFS_GC_STATS
@@ -145,23 +115,17 @@ typedef uint8_t u8_t;
145
115
// picked for garbage collection.
146
116
147
117
// Garbage collecting heuristics - weight used for deleted pages.
148
- #ifndef SPIFFS_GC_HEUR_W_DELET
149
118
#define SPIFFS_GC_HEUR_W_DELET (5)
150
- #endif
151
119
// Garbage collecting heuristics - weight used for used pages.
152
- #ifndef SPIFFS_GC_HEUR_W_USED
153
120
#define SPIFFS_GC_HEUR_W_USED (-1)
154
- #endif
155
121
// Garbage collecting heuristics - weight used for time between
156
122
// last erased and erase of this block.
157
- #ifndef SPIFFS_GC_HEUR_W_ERASE_AGE
158
123
#define SPIFFS_GC_HEUR_W_ERASE_AGE (50)
159
- #endif
160
124
161
- // Object name maximum length.
162
- #ifndef SPIFFS_OBJ_NAME_LEN
125
+ // Object name maximum length. Note that this length include the
126
+ // zero-termination character, meaning maximum string of characters
127
+ // can at most be SPIFFS_OBJ_NAME_LEN - 1.
163
128
#define SPIFFS_OBJ_NAME_LEN (32)
164
- #endif
165
129
166
130
// Maximum length of the metadata associated with an object.
167
131
// Setting to non-zero value enables metadata-related API but also
@@ -173,15 +137,13 @@ typedef uint8_t u8_t;
173
137
// This is derived from following:
174
138
// logical_page_size - (SPIFFS_OBJ_NAME_LEN + sizeof(spiffs_page_header) +
175
139
// spiffs_object_ix_header fields + at least some LUT entries)
176
- #ifndef SPIFFS_OBJ_META_LEN
177
140
#define SPIFFS_OBJ_META_LEN (0)
178
- #endif
179
141
180
142
// Size of buffer allocated on stack used when copying data.
181
143
// Lower value generates more read/writes. No meaning having it bigger
182
144
// than logical page size.
183
145
#ifndef SPIFFS_COPY_BUFFER_STACK
184
- #define SPIFFS_COPY_BUFFER_STACK (64 )
146
+ #define SPIFFS_COPY_BUFFER_STACK (256 )
185
147
#endif
186
148
187
149
// Enable this to have an identifiable spiffs filesystem. This will look for
@@ -207,50 +169,23 @@ typedef uint8_t u8_t;
207
169
// These should be defined on a multithreaded system
208
170
209
171
// define this to enter a mutex if you're running on a multithreaded system
210
- #ifndef SPIFFS_LOCK
211
172
#define SPIFFS_LOCK (fs )
212
- #endif
213
173
// define this to exit a mutex if you're running on a multithreaded system
214
- #ifndef SPIFFS_UNLOCK
215
174
#define SPIFFS_UNLOCK (fs )
216
- #endif
217
-
218
175
219
176
// Enable if only one spiffs instance with constant configuration will exist
220
177
// on the target. This will reduce calculations, flash and memory accesses.
221
178
// Parts of configuration must be defined below instead of at time of mount.
222
- #ifndef SPIFFS_SINGLETON
223
179
#define SPIFFS_SINGLETON 0
224
- #endif
225
-
226
- #if SPIFFS_SINGLETON
227
- // Instead of giving parameters in config struct, singleton build must
228
- // give parameters in defines below.
229
- #ifndef SPIFFS_CFG_PHYS_SZ
230
- #define SPIFFS_CFG_PHYS_SZ (ignore ) (1024*1024*2)
231
- #endif
232
- #ifndef SPIFFS_CFG_PHYS_ERASE_SZ
233
- #define SPIFFS_CFG_PHYS_ERASE_SZ (ignore ) (65536)
234
- #endif
235
- #ifndef SPIFFS_CFG_PHYS_ADDR
236
- #define SPIFFS_CFG_PHYS_ADDR (ignore ) (0)
237
- #endif
238
- #ifndef SPIFFS_CFG_LOG_PAGE_SZ
239
- #define SPIFFS_CFG_LOG_PAGE_SZ (ignore ) (256)
240
- #endif
241
- #ifndef SPIFFS_CFG_LOG_BLOCK_SZ
242
- #define SPIFFS_CFG_LOG_BLOCK_SZ (ignore ) (65536)
243
- #endif
244
- #endif
245
180
246
181
// Enable this if your target needs aligned data for index tables
247
182
#ifndef SPIFFS_ALIGNED_OBJECT_INDEX_TABLES
248
- #define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 1
183
+ #define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 0
249
184
#endif
250
185
251
186
// Enable this if you want the HAL callbacks to be called with the spiffs struct
252
187
#ifndef SPIFFS_HAL_CALLBACK_EXTRA
253
- #define SPIFFS_HAL_CALLBACK_EXTRA 0
188
+ #define SPIFFS_HAL_CALLBACK_EXTRA 0
254
189
#endif
255
190
256
191
// Enable this if you want to add an integer offset to all file handles
@@ -260,7 +195,7 @@ typedef uint8_t u8_t;
260
195
// NB: This adds config field fh_ix_offset in the configuration struct when
261
196
// mounting, which must be defined.
262
197
#ifndef SPIFFS_FILEHDL_OFFSET
263
- #define SPIFFS_FILEHDL_OFFSET 0
198
+ #define SPIFFS_FILEHDL_OFFSET 0
264
199
#endif
265
200
266
201
// Enable this to compile a read only version of spiffs.
@@ -274,7 +209,7 @@ typedef uint8_t u8_t;
274
209
// returned.
275
210
// Might be useful for e.g. bootloaders and such.
276
211
#ifndef SPIFFS_READ_ONLY
277
- #define SPIFFS_READ_ONLY 0
212
+ #define SPIFFS_READ_ONLY 0
278
213
#endif
279
214
280
215
// Enable this to add a temporal file cache using the fd buffer.
@@ -296,7 +231,7 @@ typedef uint8_t u8_t;
296
231
// directly. If all available descriptors become opened, all cache memory is
297
232
// lost.
298
233
#ifndef SPIFFS_TEMPORAL_FD_CACHE
299
- #define SPIFFS_TEMPORAL_FD_CACHE 1
234
+ #define SPIFFS_TEMPORAL_FD_CACHE 1
300
235
#endif
301
236
302
237
// Temporal file cache hit score. Each time a file is opened, all cached files
@@ -305,7 +240,7 @@ typedef uint8_t u8_t;
305
240
// value for the specific access patterns of the application. However, it must
306
241
// be between 1 (no gain for hitting a cached entry often) and 255.
307
242
#ifndef SPIFFS_TEMPORAL_CACHE_HIT_SCORE
308
- #define SPIFFS_TEMPORAL_CACHE_HIT_SCORE 4
243
+ #define SPIFFS_TEMPORAL_CACHE_HIT_SCORE 4
309
244
#endif
310
245
311
246
// Enable to be able to map object indices to memory.
@@ -321,12 +256,12 @@ typedef uint8_t u8_t;
321
256
// file is modified in some way. The index buffer is tied to the file
322
257
// descriptor.
323
258
#ifndef SPIFFS_IX_MAP
324
- #define SPIFFS_IX_MAP 1
259
+ #define SPIFFS_IX_MAP 1
325
260
#endif
326
261
327
262
// Set SPIFFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function
328
263
// in the api. This function will visualize all filesystem using given printf
329
- // function.
264
+ // function..
330
265
#ifndef SPIFFS_TEST_VISUALISATION
331
266
#define SPIFFS_TEST_VISUALISATION 1
332
267
#endif
@@ -335,22 +270,14 @@ typedef uint8_t u8_t;
335
270
#define spiffs_printf (...) printf(__VA_ARGS__)
336
271
#endif
337
272
// spiffs_printf argument for a free page
338
- #ifndef SPIFFS_TEST_VIS_FREE_STR
339
273
#define SPIFFS_TEST_VIS_FREE_STR "_"
340
- #endif
341
274
// spiffs_printf argument for a deleted page
342
- #ifndef SPIFFS_TEST_VIS_DELE_STR
343
275
#define SPIFFS_TEST_VIS_DELE_STR "/"
344
- #endif
345
276
// spiffs_printf argument for an index page for given object id
346
- #ifndef SPIFFS_TEST_VIS_INDX_STR
347
277
#define SPIFFS_TEST_VIS_INDX_STR (id ) "i"
348
- #endif
349
278
// spiffs_printf argument for a data page for given object id
350
- #ifndef SPIFFS_TEST_VIS_DATA_STR
351
279
#define SPIFFS_TEST_VIS_DATA_STR (id ) "d"
352
280
#endif
353
- #endif
354
281
355
282
// Types depending on configuration such as the amount of flash bytes
356
283
// given to spiffs file system in total (spiffs_file_system_size),
0 commit comments