@@ -60,8 +60,12 @@ def _parse_ld_sizes(ldscript_path):
60
60
61
61
appsize_re = re .compile (
62
62
r"irom0_0_seg\s*:.+len\s*=\s*(0x[\da-f]+)" , flags = re .I )
63
- spiffs_re = re .compile (
64
- r"PROVIDE\s*\(\s*_SPIFFS_(\w+)\s*=\s*(0x[\da-f]+)\s*\)" , flags = re .I )
63
+ filesystem_re = re .compile (
64
+ r"PROVIDE\s*\(\s*_%s_(\w+)\s*=\s*(0x[\da-f]+)\s*\)" % "FS"
65
+ if "arduino" in env .subst ("$PIOFRAMEWORK" )
66
+ else "SPIFFS" ,
67
+ flags = re .I ,
68
+ )
65
69
with open (ldscript_path ) as fp :
66
70
for line in fp .readlines ():
67
71
line = line .strip ()
@@ -71,9 +75,9 @@ def _parse_ld_sizes(ldscript_path):
71
75
if match :
72
76
result ['app_size' ] = _parse_size (match .group (1 ))
73
77
continue
74
- match = spiffs_re .search (line )
78
+ match = filesystem_re .search (line )
75
79
if match :
76
- result ['spiffs_ %s' % match .group (1 )] = _parse_size (
80
+ result ['fs_ %s' % match .group (1 )] = _parse_size (
77
81
match .group (2 ))
78
82
return result
79
83
@@ -85,19 +89,19 @@ def _get_flash_size(env):
85
89
return "%dM" % (ldsizes ['flash_size' ] / 1048576 )
86
90
87
91
88
- def fetch_spiffs_size (env ):
92
+ def fetch_fs_size (env ):
89
93
ldsizes = _parse_ld_sizes (env .GetActualLDScript ())
90
94
for key in ldsizes :
91
- if key .startswith ("spiffs_ " ):
95
+ if key .startswith ("fs_ " ):
92
96
env [key .upper ()] = ldsizes [key ]
93
97
94
98
assert all ([
95
99
k in env
96
- for k in ["SPIFFS_START " , "SPIFFS_END " , "SPIFFS_PAGE " , "SPIFFS_BLOCK " ]
100
+ for k in ["FS_START " , "FS_END " , "FS_PAGE " , "FS_BLOCK " ]
97
101
])
98
102
99
103
# esptool flash starts from 0
100
- for k in ("SPIFFS_START " , "SPIFFS_END " ):
104
+ for k in ("FS_START " , "FS_END " ):
101
105
_value = 0
102
106
if env [k ] < 0x40300000 :
103
107
_value = env [k ] & 0xFFFFF
@@ -111,8 +115,8 @@ def fetch_spiffs_size(env):
111
115
env [k ] = _value
112
116
113
117
114
- def __fetch_spiffs_size (target , source , env ):
115
- fetch_spiffs_size (env )
118
+ def __fetch_fs_size (target , source , env ):
119
+ fetch_fs_size (env )
116
120
return (target , source )
117
121
118
122
@@ -140,6 +144,8 @@ def get_esptoolpy_reset_flags(resetmethod):
140
144
env = DefaultEnvironment ()
141
145
env .SConscript ("compat.py" , exports = "env" )
142
146
platform = env .PioPlatform ()
147
+ board = env .BoardConfig ()
148
+ filesystem = board .get ("build.filesystem" , "spiffs" )
143
149
144
150
env .Replace (
145
151
__get_flash_size = _get_flash_size ,
@@ -157,10 +163,16 @@ def get_esptoolpy_reset_flags(resetmethod):
157
163
ARFLAGS = ["rc" ],
158
164
159
165
#
160
- # Misc
166
+ # Filesystem
161
167
#
162
168
163
- MKSPIFFSTOOL = "mkspiffs" ,
169
+ MKFSTOOL = "mk%s" % filesystem ,
170
+ ESP8266_FS_IMAGE_NAME = env .get ("ESP8266_FS_IMAGE_NAME" , env .get (
171
+ "SPIFFSNAME" , filesystem )),
172
+
173
+ #
174
+ # Misc
175
+ #
164
176
165
177
SIZEPROGREGEXP = r"^(?:\.irom0\.text|\.text|\.text1|\.data|\.rodata|)\s+([0-9]+).*" ,
166
178
SIZEDATAREGEXP = r"^(?:\.data|\.rodata|\.bss)\s+([0-9]+).*" ,
@@ -195,14 +207,14 @@ def get_esptoolpy_reset_flags(resetmethod):
195
207
BUILDERS = dict (
196
208
DataToBin = Builder (
197
209
action = env .VerboseAction (" " .join ([
198
- '"$MKSPIFFSTOOL "' ,
210
+ '"$MKFSTOOL "' ,
199
211
"-c" , "$SOURCES" ,
200
- "-p" , "$SPIFFS_PAGE " ,
201
- "-b" , "$SPIFFS_BLOCK " ,
202
- "-s" , "${SPIFFS_END - SPIFFS_START }" ,
212
+ "-p" , "$FS_PAGE " ,
213
+ "-b" , "$FS_BLOCK " ,
214
+ "-s" , "${FS_END - FS_START }" ,
203
215
"$TARGET"
204
- ]), "Building SPIFFS image from '$SOURCES' directory to $TARGET" ),
205
- emitter = __fetch_spiffs_size ,
216
+ ]), "Building file system image from '$SOURCES' directory to $TARGET" ),
217
+ emitter = __fetch_fs_size ,
206
218
source_factory = env .Dir ,
207
219
suffix = ".bin"
208
220
)
@@ -211,22 +223,25 @@ def get_esptoolpy_reset_flags(resetmethod):
211
223
212
224
213
225
#
214
- # Target: Build executable and linkable firmware or SPIFFS image
226
+ # Target: Build executable and linkable firmware or file system image
215
227
#
216
228
217
229
target_elf = None
218
230
if "nobuild" in COMMAND_LINE_TARGETS :
219
231
target_elf = join ("$BUILD_DIR" , "${PROGNAME}.elf" )
220
232
if set (["uploadfs" , "uploadfsota" ]) & set (COMMAND_LINE_TARGETS ):
221
- fetch_spiffs_size (env )
222
- target_firm = join ("$BUILD_DIR" , "%s .bin" % env . get ( "SPIFFSNAME" , "spiffs" ) )
233
+ fetch_fs_size (env )
234
+ target_firm = join ("$BUILD_DIR" , "${ESP8266_FS_IMAGE_NAME} .bin" )
223
235
else :
224
236
target_firm = join ("$BUILD_DIR" , "${PROGNAME}.bin" )
225
237
else :
226
238
target_elf = env .BuildProgram ()
227
239
if set (["buildfs" , "uploadfs" , "uploadfsota" ]) & set (COMMAND_LINE_TARGETS ):
240
+ if filesystem not in ("littlefs" , "spiffs" ):
241
+ sys .stderr .write ("Filesystem %s is not supported!\n " % filesystem )
242
+ env .Exit (1 )
228
243
target_firm = env .DataToBin (
229
- join ("$BUILD_DIR" , env . get ( "SPIFFSNAME" , "spiffs" ) ), "$PROJECTDATA_DIR" )
244
+ join ("$BUILD_DIR" , "${ESP8266_FS_IMAGE_NAME}" ), "$PROJECTDATA_DIR" )
230
245
AlwaysBuild (target_firm )
231
246
else :
232
247
target_firm = env .ElfToBin (
@@ -260,7 +275,7 @@ def get_esptoolpy_reset_flags(resetmethod):
260
275
)
261
276
262
277
#
263
- # Target: Upload firmware or SPIFFS image
278
+ # Target: Upload firmware or filesystem image
264
279
#
265
280
266
281
upload_protocol = env .subst ("$UPLOAD_PROTOCOL" )
@@ -318,7 +333,7 @@ def get_esptoolpy_reset_flags(resetmethod):
318
333
"--port" , '"$UPLOAD_PORT"' ,
319
334
"--baud" , "$UPLOAD_SPEED" ,
320
335
"write_flash" ,
321
- "$SPIFFS_START "
336
+ "$FS_START "
322
337
],
323
338
UPLOADCMD = '"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS $SOURCE' ,
324
339
)
0 commit comments