@@ -128,6 +128,7 @@ def __fetch_spiffs_size(target, source, env):
128
128
env .Replace (
129
129
__get_board_f_flash = _get_board_f_flash ,
130
130
__get_board_flash_mode = _get_board_flash_mode ,
131
+
131
132
AR = "xtensa-esp32-elf-ar" ,
132
133
AS = "xtensa-esp32-elf-as" ,
133
134
CC = "xtensa-esp32-elf-gcc" ,
@@ -137,6 +138,7 @@ def __fetch_spiffs_size(target, source, env):
137
138
platform .get_package_dir ("tool-esptoolpy" ) or "" , "esptool.py" ),
138
139
RANLIB = "xtensa-esp32-elf-ranlib" ,
139
140
SIZETOOL = "xtensa-esp32-elf-size" ,
141
+
140
142
ARFLAGS = ["rc" ],
141
143
ASFLAGS = ["-x" , "assembler-with-cpp" ],
142
144
CFLAGS = ["-std=gnu99" ],
@@ -155,9 +157,15 @@ def __fetch_spiffs_size(target, source, env):
155
157
"-nostdlib" , "-Wl,-static" , "-u" , "call_user_start_cpu0" ,
156
158
"-Wl,--undefined=uxTopUsedPriority" , "-Wl,--gc-sections"
157
159
],
160
+
161
+ SIZEPROGREGEXP = r"^(?:\.iram0\.text|\.dram0\.text|\.flash\.text|\.dram0\.data|\.flash\.rodata|)\s+(\d+).*" ,
162
+ SIZEDATAREGEXP = r"^(?:\.dram0\.data|\.dram0\.bss)\s+(\d+).*" ,
163
+ SIZECHECKCMD = "$SIZETOOL -A -d $SOURCES" ,
164
+ SIZEPRINTCMD = "$SIZETOOL -B -d $SOURCES" ,
165
+
158
166
MKSPIFFSTOOL = "mkspiffs_${PIOPLATFORM}_${PIOFRAMEWORK}" ,
159
- SIZEPRINTCMD = '$SIZETOOL -B -d $SOURCES' ,
160
- PROGSUFFIX = ".elf" )
167
+ PROGSUFFIX = ".elf"
168
+ )
161
169
162
170
# Allow user to override via pre:script
163
171
if env .get ("PROGNAME" , "program" ) == "program" :
@@ -210,7 +218,14 @@ def __fetch_spiffs_size(target, source, env):
210
218
target_buildprog = env .Alias ("buildprog" , target_firm , target_firm )
211
219
212
220
# update max upload size based on CSV file
213
- if "upload" in COMMAND_LINE_TARGETS :
221
+ if env .get ("PIOMAINPROG" ):
222
+ env .AddPreAction (
223
+ "checkprogsize" ,
224
+ env .VerboseAction (
225
+ lambda source , target , env : _update_max_upload_size (env ),
226
+ "Retrieving maximum program size $SOURCES" ))
227
+ # remove after PIO Core 3.6 release
228
+ elif set (["checkprogsize" , "upload" ]) & set (COMMAND_LINE_TARGETS ):
214
229
_update_max_upload_size (env )
215
230
216
231
#
0 commit comments