Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
include/esp8266/spiffs_config.h
1
/*
2
* spiffs_config.h
3
*
4
* Created on: Jul 3, 2013
5
* Author: petera
6
*/
7
8
#ifndef SPIFFS_CONFIG_H_
9
#define SPIFFS_CONFIG_H_
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>
17
#include <stddef.h>
18
19
// ----------- >8 ------------
20
21
// compile time switches
22
23
// Set generic spiffs debug output call.
24
#ifndef SPIFFS_DBG
25
#define SPIFFS_DBG(...)
//printf(__VA_ARGS__)
26
#endif
27
// Set spiffs debug output call for garbage collecting.
28
#ifndef SPIFFS_GC_DBG
29
#define SPIFFS_GC_DBG(...)
//printf(__VA_ARGS__)
30
#endif
31
// Set spiffs debug output call for caching.
32
#ifndef SPIFFS_CACHE_DBG
33
#define SPIFFS_CACHE_DBG(...)
//printf(__VA_ARGS__)
34
#endif
35
// Set spiffs debug output call for system consistency checks.
36
#ifndef SPIFFS_CHECK_DBG
37
#define SPIFFS_CHECK_DBG(...)
//printf(__VA_ARGS__)
38
#endif
39
40
// Enable/disable API functions to determine exact number of bytes
41
// for filedescriptor and cache buffers. Once decided for a configuration,
42
// this can be disabled to reduce flash.
43
#ifndef SPIFFS_BUFFER_HELP
44
#define SPIFFS_BUFFER_HELP 0
45
#endif
46
47
// Enables/disable memory read caching of nucleus file system operations.
48
// If enabled, memory area must be provided for cache in SPIFFS_mount.
49
#ifndef SPIFFS_CACHE
50
#define SPIFFS_CACHE 1
51
#endif
52
53
#if SPIFFS_CACHE
54
// Enables memory write caching for file descriptors in hydrogen
55
#ifndef SPIFFS_CACHE_WR
56
#define SPIFFS_CACHE_WR 1
57
#endif
58
59
// Enable/disable statistics on caching. Debug/test purpose only.
60
#ifndef SPIFFS_CACHE_STATS
61
#define SPIFFS_CACHE_STATS 1
62
#endif
63
#endif
64
65
// Always check header of each accessed page to ensure consistent state.
66
// If enabled it will increase number of reads, will increase flash.
67
#ifndef SPIFFS_PAGE_CHECK
68
#define SPIFFS_PAGE_CHECK 1
69
#endif
70
71
// Define maximum number of gc runs to perform to reach desired free pages.
72
#ifndef SPIFFS_GC_MAX_RUNS
73
#define SPIFFS_GC_MAX_RUNS 5
74
#endif
75
76
// Enable/disable statistics on gc. Debug/test purpose only.
77
#ifndef SPIFFS_GC_STATS
78
#define SPIFFS_GC_STATS 1
79
#endif
80
81
// Garbage collecting examines all pages in a block which and sums up
82
// to a block score. Deleted pages normally gives positive score and
83
// used pages normally gives a negative score (as these must be moved).
84
// To have a fair wear-leveling, the erase age is also included in score,
85
// whose factor normally is the most positive.
86
// The larger the score, the more likely it is that the block will
87
// picked for garbage collection.
88
89
// Garbage collecting heuristics - weight used for deleted pages.
90
#ifndef SPIFFS_GC_HEUR_W_DELET
91
#define SPIFFS_GC_HEUR_W_DELET (5)
92
#endif
93
// Garbage collecting heuristics - weight used for used pages.
94
#ifndef SPIFFS_GC_HEUR_W_USED
95
#define SPIFFS_GC_HEUR_W_USED (-1)
96
#endif
97
// Garbage collecting heuristics - weight used for time between
98
// last erased and erase of this block.
99
#ifndef SPIFFS_GC_HEUR_W_ERASE_AGE
100
#define SPIFFS_GC_HEUR_W_ERASE_AGE (50)
101
#endif
102
103
// Object name maximum length.
104
#ifndef SPIFFS_OBJ_NAME_LEN
105
#define SPIFFS_OBJ_NAME_LEN (32)
106
#endif
107
108
// Size of buffer allocated on stack used when copying data.
109
// Lower value generates more read/writes. No meaning having it bigger
110
// than logical page size.
111
#ifndef SPIFFS_COPY_BUFFER_STACK
112
#define SPIFFS_COPY_BUFFER_STACK (64)
113
#endif
114
115
// Enable this to have an identifiable spiffs filesystem. This will look for
116
// a magic in all sectors to determine if this is a valid spiffs system or
117
// not on mount point. If not, SPIFFS_format must be called prior to mounting
118
// again.
119
#ifndef SPIFFS_USE_MAGIC
120
#define SPIFFS_USE_MAGIC (0)
121
#endif
122
123
// SPIFFS_LOCK and SPIFFS_UNLOCK protects spiffs from reentrancy on api level
124
// These should be defined on a multithreaded system
125
126
// define this to enter a mutex if you're running on a multithreaded system
127
#ifndef SPIFFS_LOCK
128
#define SPIFFS_LOCK(fs)
129
#endif
130
// define this to exit a mutex if you're running on a multithreaded system
131
#ifndef SPIFFS_UNLOCK
132
#define SPIFFS_UNLOCK(fs)
133
#endif
134
135
136
// Enable if only one spiffs instance with constant configuration will exist
137
// on the target. This will reduce calculations, flash and memory accesses.
138
// Parts of configuration must be defined below instead of at time of mount.
139
#ifndef SPIFFS_SINGLETON
140
#define SPIFFS_SINGLETON 0
141
#endif
142
143
#if SPIFFS_SINGLETON
144
// Instead of giving parameters in config struct, singleton build must
145
// give parameters in defines below.
146
#ifndef SPIFFS_CFG_PHYS_SZ
147
#define SPIFFS_CFG_PHYS_SZ(ignore) (1024*1024*2)
148
#endif
149
#ifndef SPIFFS_CFG_PHYS_ERASE_SZ
150
#define SPIFFS_CFG_PHYS_ERASE_SZ(ignore) (65536)
151
#endif
152
#ifndef SPIFFS_CFG_PHYS_ADDR
153
#define SPIFFS_CFG_PHYS_ADDR(ignore) (0)
154
#endif
155
#ifndef SPIFFS_CFG_LOG_PAGE_SZ
156
#define SPIFFS_CFG_LOG_PAGE_SZ(ignore) (256)
157
#endif
158
#ifndef SPIFFS_CFG_LOG_BLOCK_SZ
159
#define SPIFFS_CFG_LOG_BLOCK_SZ(ignore) (65536)
160
#endif
161
#endif
162
163
// Enable this if your target needs aligned data for index tables
164
#ifndef SPIFFS_ALIGNED_OBJECT_INDEX_TABLES
165
#define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 1
166
#endif
167
168
// Set SPIFFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function
169
// in the api. This function will visualize all filesystem using given printf
170
// function.
171
#ifndef SPIFFS_TEST_VISUALISATION
172
#define SPIFFS_TEST_VISUALISATION 0
173
#endif
174
#if SPIFFS_TEST_VISUALISATION
175
#ifndef spiffs_printf
176
#define spiffs_printf(...) printf(__VA_ARGS__)
177
#endif
178
// spiffs_printf argument for a free page
179
#ifndef SPIFFS_TEST_VIS_FREE_STR
180
#define SPIFFS_TEST_VIS_FREE_STR "_"
181
#endif
182
// spiffs_printf argument for a deleted page
183
#ifndef SPIFFS_TEST_VIS_DELE_STR
184
#define SPIFFS_TEST_VIS_DELE_STR "/"
185
#endif
186
// spiffs_printf argument for an index page for given object id
187
#ifndef SPIFFS_TEST_VIS_INDX_STR
188
#define SPIFFS_TEST_VIS_INDX_STR(id) "i"
189
#endif
190
// spiffs_printf argument for a data page for given object id
191
#ifndef SPIFFS_TEST_VIS_DATA_STR
192
#define SPIFFS_TEST_VIS_DATA_STR(id) "d"
193
#endif
194
#endif
195
196
// Types depending on configuration such as the amount of flash bytes
197
// given to spiffs file system in total (spiffs_file_system_size),
198
// the logical block size (log_block_size), and the logical page size
199
// (log_page_size)
200
201
// Block index type. Make sure the size of this type can hold
202
// the highest number of all blocks - i.e. spiffs_file_system_size / log_block_size
203
typedef
u16_t spiffs_block_ix;
204
// Page index type. Make sure the size of this type can hold
205
// the highest page number of all pages - i.e. spiffs_file_system_size / log_page_size
206
typedef
u16_t spiffs_page_ix;
207
// Object id type - most significant bit is reserved for index flag. Make sure the
208
// size of this type can hold the highest object id on a full system,
209
// i.e. 2 + (spiffs_file_system_size / (2*log_page_size))*2
210
typedef
u16_t spiffs_obj_id;
211
// Object span index type. Make sure the size of this type can
212
// hold the largest possible span index on the system -
213
// i.e. (spiffs_file_system_size / log_page_size) - 1
214
typedef
u16_t spiffs_span_ix;
215
216
#endif
/* SPIFFS_CONFIG_H_ */
include
esp8266
spiffs_config.h
Generated on Sun Feb 2 2025 21:18:13 for Open Model Railroad Network (OpenMRN) by
1.9.8