@@ -355,7 +355,19 @@ def get_app_flags(app_config):
355
355
}
356
356
357
357
358
- def find_framework_service_files (search_path ):
358
+ def get_sdk_configuration ():
359
+ config_path = join (env .subst ("$BUILD_DIR" ), "config" , "sdkconfig.json" )
360
+ if not isfile (config_path ):
361
+ print ("Warning: Could not find \" sdkconfig.json\" file\n " )
362
+
363
+ try :
364
+ with open (config_path , "r" ) as fp :
365
+ return json .load (fp )
366
+ except :
367
+ return {}
368
+
369
+
370
+ def find_framework_service_files (search_path , sdk_config ):
359
371
result = {}
360
372
result ["lf_files" ] = list ()
361
373
result ["kconfig_files" ] = list ()
@@ -369,9 +381,14 @@ def find_framework_service_files(search_path):
369
381
elif f == "Kconfig" :
370
382
result ["kconfig_files" ].append (join (search_path , d , f ))
371
383
372
- result ["lf_files" ].append (
373
- join (FRAMEWORK_DIR , "components" , "esp32" , "ld" , "esp32_fragments.lf" )
374
- )
384
+ result ["lf_files" ].extend ([
385
+ join (FRAMEWORK_DIR , "components" , "esp32" , "ld" , "esp32_fragments.lf" ),
386
+ join (FRAMEWORK_DIR , "components" , "newlib" , "newlib.lf" )
387
+ ])
388
+
389
+ if sdk_config .get ("SPIRAM_CACHE_WORKAROUND" , False ):
390
+ result ["lf_files" ].append (join (
391
+ FRAMEWORK_DIR , "components" , "newlib" , "esp32-spiram-rom-functions-c.lf" ))
375
392
376
393
return result
377
394
@@ -398,8 +415,9 @@ def create_custom_libraries_list(orignial_ldgen_libraries_file, project_target_n
398
415
return pio_libraries_file
399
416
400
417
401
- def generate_project_ld_script (project_target_name ):
402
- project_files = find_framework_service_files (join (FRAMEWORK_DIR , "components" ))
418
+ def generate_project_ld_script (project_target_name , sdk_config ):
419
+ project_files = find_framework_service_files (
420
+ join (FRAMEWORK_DIR , "components" ), sdk_config )
403
421
404
422
# Create a new file to avoid automatically generated library entry as files from
405
423
# this library are built internally by PlatformIO
@@ -776,6 +794,8 @@ def get_project_elf(target_configs):
776
794
project_codemodel , join (BUILD_DIR , CMAKE_API_REPLY_PATH )
777
795
)
778
796
797
+ sdk_config = get_sdk_configuration ()
798
+
779
799
if all (t in target_configs for t in ("__idf_src" , "__idf_main" )):
780
800
sys .stderr .write (
781
801
(
@@ -791,7 +811,7 @@ def get_project_elf(target_configs):
791
811
sys .stderr .write ("Error: Couldn't find the main target of the project!\n " )
792
812
env .Exit (1 )
793
813
794
- project_ld_scipt = generate_project_ld_script (project_target_name )
814
+ project_ld_scipt = generate_project_ld_script (project_target_name , sdk_config )
795
815
env .Depends ("$BUILD_DIR/$PROGNAME$PROGSUFFIX" , project_ld_scipt )
796
816
797
817
elf_config = get_project_elf (target_configs )
0 commit comments