@@ -75,7 +75,9 @@ def scons_patched_match_splitext(path, suffixes=None):
7575 "-U__STRICT_ANSI__" ,
7676 "-ffunction-sections" ,
7777 "-fdata-sections" ,
78- "-Wall"
78+ "-Wall" ,
79+ "-free" ,
80+ "-fipa-pta"
7981 ],
8082
8183 CXXFLAGS = [
@@ -279,27 +281,89 @@ def scons_patched_match_splitext(path, suffixes=None):
279281 env .Append (CPPDEFINES = [current_vtables ])
280282assert current_vtables
281283
282- current_mmu_iram_size = None
283- for flag in env ["CPPDEFINES" ]:
284- try :
285- d , val = flag
286- if str (d ).startswith ("MMU_IRAM_SIZE" ):
287- current_mmu_iram_size = "{}={}" .format (d , val )
288- except ValueError :
289- continue
290- if not current_mmu_iram_size :
291- current_mmu_iram_size = "MMU_IRAM_SIZE=0x8000"
292- env .Append (CPPDEFINES = [current_mmu_iram_size ])
293- assert current_mmu_iram_size
284+ #
285+ # MMU
286+ #
287+
288+ mmu_flags = []
289+ required_flags = ("MMU_IRAM_SIZE" , "MMU_ICACHE_SIZE" )
290+ if "PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48" in flatten_cppdefines :
291+ mmu_flags = [("MMU_IRAM_SIZE" , "0xC000" ), ("MMU_ICACHE_SIZE" , "0x4000" )]
292+ elif "PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED" in flatten_cppdefines :
293+ mmu_flags = [
294+ ("MMU_IRAM_SIZE" , "0xC000" ),
295+ ("MMU_ICACHE_SIZE" , "0x4000" ),
296+ "MMU_IRAM_HEAP" ,
297+ ]
298+ elif "PIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM32_SECHEAP_NOTSHARED" in flatten_cppdefines :
299+ mmu_flags = [
300+ ("MMU_IRAM_SIZE" , "0x8000" ),
301+ ("MMU_ICACHE_SIZE" , "0x4000" ),
302+ ("MMU_SEC_HEAP_SIZE" , "0x4000" ),
303+ ("MMU_SEC_HEAP" , "0x40108000" ),
304+ ]
305+ elif "PIO_FRAMEWORK_ARDUINO_MMU_EXTERNAL_128K" in flatten_cppdefines :
306+ mmu_flags = [
307+ ("MMU_IRAM_SIZE" , "0x8000" ),
308+ ("MMU_ICACHE_SIZE" , "0x8000" ),
309+ ("MMU_EXTERNAL_HEAP" , "128" ),
310+ ]
311+ elif "PIO_FRAMEWORK_ARDUINO_MMU_EXTERNAL_1024K" in flatten_cppdefines :
312+ mmu_flags = [
313+ ("MMU_IRAM_SIZE" , "0x8000" ),
314+ ("MMU_ICACHE_SIZE" , "0x8000" ),
315+ ("MMU_EXTERNAL_HEAP" , "256" ),
316+ ]
317+ elif "PIO_FRAMEWORK_ARDUINO_MMU_CUSTOM" in flatten_cppdefines :
318+ if not all (d in flatten_cppdefines for d in required_flags ):
319+ print (
320+ "Error: Missing custom MMU configuration flags (%s)!"
321+ % ", " .join (required_flags )
322+ )
323+ env .Exit (1 )
324+
325+ for flag in env ["CPPDEFINES" ]:
326+ define = flag
327+ if isinstance (flag , (tuple , list )):
328+ define , _ = flag
329+ if define .startswith ("MMU_" ):
330+ mmu_flags .append (flag )
331+ # PIO_FRAMEWORK_ARDUINO_MMU_CACHE32_IRAM32 (default)
332+ else :
333+ mmu_flags = [
334+ ("MMU_IRAM_SIZE" , board .get ("build.mmu_iram_size" , "0x8000" )),
335+ ("MMU_ICACHE_SIZE" , board .get ("build.mmu_icache_size" , "0x8000" ))]
336+ if any (f in flatten_cppdefines for f in required_flags ):
337+ print (
338+ "Warning! Detected custom MMU flags. Please use the "
339+ "`-D PIO_FRAMEWORK_ARDUINO_MMU_CUSTOM` option to disable "
340+ "the default configuration."
341+ )
342+
343+ assert mmu_flags
344+ env .Append (CPPDEFINES = mmu_flags )
294345
295346
296347# Build the eagle.app.v6.common.ld linker file
297348app_ld = env .Command (
298349 join ("$BUILD_DIR" , "ld" , "local.eagle.app.v6.common.ld" ),
299350 join (FRAMEWORK_DIR , "tools" , "sdk" , "ld" , "eagle.app.v6.common.ld.h" ),
300351 env .VerboseAction (
301- "$CC -CC -E -P -D%s -D%s %s $SOURCE -o $TARGET" % (current_vtables , current_mmu_iram_size , fp_in_irom ),
302- "Generating LD script $TARGET" ))
352+ "$CC -CC -E -P -D%s %s %s $SOURCE -o $TARGET"
353+ % (
354+ current_vtables ,
355+ # String representation of MMU flags
356+ " " .join (
357+ [
358+ "-D%s=%s" % f if isinstance (f , (tuple , list )) else "-D" + f
359+ for f in mmu_flags
360+ ]
361+ ),
362+ fp_in_irom ,
363+ ),
364+ "Generating LD script $TARGET" ,
365+ ),
366+ )
303367env .Depends ("$BUILD_DIR/$PROGNAME$PROGSUFFIX" , app_ld )
304368
305369if not env .BoardConfig ().get ("build.ldscript" , "" ):
@@ -309,6 +373,7 @@ def scons_patched_match_splitext(path, suffixes=None):
309373# Dynamic core_version.h for staging builds
310374#
311375
376+
312377def platform_txt_version (default ):
313378 with open (join (FRAMEWORK_DIR , "platform.txt" ), "r" ) as platform_txt :
314379 for line in platform_txt :
@@ -322,6 +387,7 @@ def platform_txt_version(default):
322387
323388 return default
324389
390+
325391if isdir (join (FRAMEWORK_DIR , ".git" )):
326392 cmd = '"$PYTHONEXE" "{script}" -b "$BUILD_DIR" -p "{framework_dir}" -v {version}'
327393 fmt = {
0 commit comments