@@ -157,11 +157,21 @@ def build_component(path, component_config):
157
157
CPPDEFINES = component_config .get ("cpp_defines" , []),
158
158
)
159
159
160
- return envsafe .BuildLibrary (
160
+ component = envsafe .BuildLibrary (
161
161
join ("$BUILD_DIR" , "%s" % basename (path )), path ,
162
- src_filter = component_config .get ("src_filter" , "+<*> -<test*>" )
162
+ src_filter = component_config .get ("src_filter" , "+<*> -<test*>" ))
163
+
164
+ component_sections = env .Command (
165
+ "${SOURCE}.sections_info" , component ,
166
+ env .VerboseAction (
167
+ "xtensa-esp32-elf-objdump -h $SOURCE > $TARGET" , "Generating $TARGET" )
163
168
)
164
169
170
+ # Section files are used in linker script generation process
171
+ env .Depends ("$BUILD_DIR/esp32.project.ld" , component_sections )
172
+
173
+ return component
174
+
165
175
166
176
def get_sdk_configuration (config_path ):
167
177
if not isfile (config_path ):
@@ -180,13 +190,13 @@ def get_sdk_configuration(config_path):
180
190
return config
181
191
182
192
183
- def find_valid_config_file ( ):
193
+ def find_valid_example_file ( filename ):
184
194
search_path = join (
185
- platform .get_dir (), "examples" , "*" , "src" , "sdkconfig.h" )
195
+ platform .get_dir (), "examples" , "*" , "src" , filename )
186
196
files = glob (search_path )
187
197
if not files :
188
198
sys .stderr .write (
189
- "Error: Could not find default \" sdkconfig.h \" file\n " )
199
+ "Error: Could not find default %s file\n " % filename )
190
200
env .Exit (1 )
191
201
return files [0 ]
192
202
@@ -302,6 +312,26 @@ def build_wpa_supplicant_lib():
302
312
join (FRAMEWORK_DIR , "components" , "wpa_supplicant" ), config )
303
313
304
314
315
+ def build_wifi_provisioning_lib ():
316
+ src_filter = "-<*>"
317
+ for d in ["proto-c" , "src" ]:
318
+ src_filter += " +<%s>" % d
319
+
320
+ if not (is_set ("CONFIG_BT_ENABLED" , sdk_params ) and is_set (
321
+ "CONFIG_BLUEDROID_ENABLED" , sdk_params )):
322
+ src_filter += " -<src/scheme_ble.c>"
323
+
324
+ inc_dirs = ["src" , "proto-c" , "../protocomm/proto-c" ]
325
+
326
+ config = {
327
+ "inc_dirs" : inc_dirs ,
328
+ "src_filter" : src_filter
329
+ }
330
+
331
+ return build_component (
332
+ join (FRAMEWORK_DIR , "components" , "wifi_provisioning" ), config )
333
+
334
+
305
335
def build_heap_lib (sdk_params ):
306
336
src_filter = "+<*> -<test*>"
307
337
if is_set ("CONFIG_HEAP_POISONING_DISABLED" , sdk_params ):
@@ -375,11 +405,68 @@ def build_espidf_bootloader():
375
405
join ("$BUILD_DIR" , "bootloader.elf" ),
376
406
envsafe .CollectBuildFiles (
377
407
join ("$BUILD_DIR" , "bootloader" ),
378
- join (FRAMEWORK_DIR , "components" , "bootloader" , "subproject" , "main" )
408
+ join (FRAMEWORK_DIR , "components" , "bootloader" , "subproject" ,
409
+ "main" )
379
410
)
380
411
)
381
412
382
413
414
+ def generate_section_info (target , source , env ):
415
+ with open (target [0 ].get_path (), "w" ) as fp :
416
+ fp .write ("\n " .join (s .get_path () + ".sections_info" for s in source ))
417
+
418
+ return None
419
+
420
+
421
+ def find_framework_service_files (search_path ):
422
+ result = {}
423
+ result ['lf_files' ] = list ()
424
+ result ['kconfig_files' ] = list ()
425
+ result ['kconfig_build_files' ] = list ()
426
+ for d in listdir (search_path ):
427
+ for f in listdir (join (search_path , d )):
428
+ if f == "linker.lf" :
429
+ result ['lf_files' ].append (join (search_path , d , f ))
430
+ elif f == "Kconfig.projbuild" :
431
+ result ['kconfig_build_files' ].append (join (search_path , d , f ))
432
+ elif f == "Kconfig" :
433
+ result ['kconfig_files' ].append (join (search_path , d , f ))
434
+
435
+ result ['lf_files' ].append (
436
+ join (FRAMEWORK_DIR , "components" , "esp32" , "ld" , "esp32_fragments.lf" ))
437
+
438
+ return result
439
+
440
+
441
+ def generate_project_ld_script (target , source , env ):
442
+ project_files = find_framework_service_files (
443
+ join (FRAMEWORK_DIR , "components" ))
444
+
445
+ args = {
446
+ "script" : join (FRAMEWORK_DIR , "tools" , "ldgen" , "ldgen.py" ),
447
+ "sections" : source [0 ].get_path (),
448
+ "input" : join (
449
+ FRAMEWORK_DIR , "components" , "esp32" , "ld" , "esp32.project.ld.in" ),
450
+ "sdk_header" : join (env .subst ("$PROJECTSRC_DIR" ), "sdkconfig.h" ),
451
+ "fragments" : " " .join (
452
+ ["\" %s\" " % f for f in project_files .get ("lf_files" )]),
453
+ "output" : target [0 ].get_path (),
454
+ "kconfig" : join (FRAMEWORK_DIR , "Kconfig" ),
455
+ "kconfigs_projbuild" : "COMPONENT_KCONFIGS_PROJBUILD=%s" % "#" .join (
456
+ ["%s" % f for f in project_files .get ("kconfig_build_files" )]),
457
+ "kconfig_files" : "COMPONENT_KCONFIGS=%s" % "#" .join (
458
+ ["%s" % f for f in project_files .get ("kconfig_files" )]),
459
+ }
460
+
461
+ cmd = ('"$PYTHONEXE" "{script}" --sections "{sections}" --input "{input}" '
462
+ '--config "{sdk_header}" --fragments {fragments} --output "{output}" '
463
+ '--kconfig "{kconfig}" --env "{kconfigs_projbuild}" '
464
+ '--env "{kconfig_files}" --env "IDF_CMAKE=n" '
465
+ '--env "IDF_TARGET=\\ \" esp32\\ \" "' ).format (** args )
466
+
467
+ env .Execute (cmd )
468
+
469
+
383
470
def build_arduino_framework ():
384
471
core = env .BoardConfig ().get ("build.core" )
385
472
@@ -473,14 +560,18 @@ def configure_exceptions(sdk_params):
473
560
"libcoap" , "include" , "coap" ),
474
561
join (FRAMEWORK_DIR , "components" , "console" ),
475
562
join (FRAMEWORK_DIR , "components" , "driver" , "include" ),
563
+ join (FRAMEWORK_DIR , "components" , "efuse" , "include" ),
564
+ join (FRAMEWORK_DIR , "components" , "efuse" , "esp32" , "include" ),
476
565
join (FRAMEWORK_DIR , "components" , "esp-tls" ),
477
566
join (FRAMEWORK_DIR , "components" , "esp_adc_cal" , "include" ),
478
567
join (FRAMEWORK_DIR , "components" , "esp_event" , "include" ),
479
568
join (FRAMEWORK_DIR , "components" , "esp_http_client" , "include" ),
480
569
join (FRAMEWORK_DIR , "components" , "esp_http_server" , "include" ),
570
+ join (FRAMEWORK_DIR , "components" , "esp_https_server" , "include" ),
481
571
join (FRAMEWORK_DIR , "components" , "esp_https_ota" , "include" ),
482
572
join (FRAMEWORK_DIR , "components" , "esp_ringbuf" , "include" ),
483
573
join (FRAMEWORK_DIR , "components" , "esp32" , "include" ),
574
+ join (FRAMEWORK_DIR , "components" , "espcoredump" , "include" ),
484
575
join (FRAMEWORK_DIR , "components" , "ethernet" , "include" ),
485
576
join (FRAMEWORK_DIR , "components" , "expat" , "expat" , "lib" ),
486
577
join (FRAMEWORK_DIR , "components" , "expat" , "port" , "include" ),
@@ -525,6 +616,8 @@ def configure_exceptions(sdk_params):
525
616
join (FRAMEWORK_DIR , "components" , "spiffs" , "include" ),
526
617
join (FRAMEWORK_DIR , "components" , "tcp_transport" , "include" ),
527
618
join (FRAMEWORK_DIR , "components" , "tcpip_adapter" , "include" ),
619
+ join (FRAMEWORK_DIR , "components" , "unity" , "include" ),
620
+ join (FRAMEWORK_DIR , "components" , "unity" , "unity" , "src" ),
528
621
join (FRAMEWORK_DIR , "components" , "ulp" , "include" ),
529
622
join (FRAMEWORK_DIR , "components" , "vfs" , "include" ),
530
623
join (FRAMEWORK_DIR , "components" , "wear_levelling" , "include" ),
@@ -557,14 +650,17 @@ def configure_exceptions(sdk_params):
557
650
if (d == "include" ):
558
651
env .Prepend (CPPPATH = [join (root , d )])
559
652
560
-
561
653
env .Prepend (
562
654
CFLAGS = ["-Wno-old-style-declaration" ],
563
655
564
656
CPPDEFINES = [
565
657
"WITH_POSIX" ,
658
+ "UNITY_INCLUDE_CONFIG_H" ,
566
659
("IDF_VER" , '\\ "%s\\ "' %
567
- platform .get_package_version ("framework-espidf" ))
660
+ platform .get_package_version ("framework-espidf" )),
661
+ ("PROJECT_VER" , '\\ "%s\\ "' % "1.0.0" ),
662
+ ("PROJECT_NAME" , '\\ "%s\\ "' % basename (env .subst ("$PROJECT_DIR" )))
663
+
568
664
],
569
665
570
666
CCFLAGS = [
@@ -582,8 +678,9 @@ def configure_exceptions(sdk_params):
582
678
env .Append (
583
679
LINKFLAGS = [
584
680
"-u" , "__cxa_guard_dummy" ,
681
+ "-u" , "esp_app_desc" ,
585
682
"-u" , "ld_include_panic_highint_hdl" ,
586
- "-T" , "esp32.common .ld" ,
683
+ "-T" , "esp32.project .ld" ,
587
684
"-T" , "esp32.rom.ld" ,
588
685
"-T" , "esp32.peripherals.ld" ,
589
686
"-T" , "esp32.rom.libgcc.ld" ,
@@ -607,35 +704,40 @@ def configure_exceptions(sdk_params):
607
704
env .Replace (ASFLAGS = [])
608
705
609
706
#
610
- # Handle missing sdkconfig.h
707
+ # Handle missing sdkconfig files
611
708
#
612
709
613
- sdk_config_file = join (env .subst ("$PROJECTSRC_DIR" ), "sdkconfig.h" )
614
710
615
- if not isfile (sdk_config_file ):
616
- print ("Warning! Cannot find \" sdkconfig.h\" file. "
617
- "Default \" sdkconfig.h\" will be added to your project!" )
618
- copy (find_valid_config_file (), sdk_config_file )
619
- else :
620
- is_new = False
621
- with open (sdk_config_file ) as fp :
622
- for l in fp .readlines ():
623
- if "CONFIG_PTHREAD_STACK_MIN" in l :
624
- is_new = True
625
- break
626
-
627
- if not is_new :
628
- print ("Warning! Detected an outdated \" sdkconfig.h\" file. "
629
- "The old \" sdkconfig.h\" will be replaced by the new one." )
630
-
631
- new_config = find_valid_config_file ()
632
- copy (
633
- sdk_config_file ,
634
- join (env .subst ("$PROJECTSRC_DIR" ), "sdkconfig.h.bak" )
635
- )
636
- copy (new_config , sdk_config_file )
711
+ def process_project_configs (filename ):
712
+ config = join (env .subst ("$PROJECTSRC_DIR" ), filename )
713
+ if not isfile (config ):
714
+ print ("Warning! Cannot find %s file. Default "
715
+ "file will be added to your project!" % filename )
716
+ copy (find_valid_example_file (filename ), config )
717
+ else :
718
+ is_new = False
719
+ with open (config ) as fp :
720
+ for l in fp .readlines ():
721
+ if "CONFIG_APP_COMPILE_TIME_DATE" in l :
722
+ is_new = True
723
+ break
724
+
725
+ if not is_new :
726
+ print ("Warning! Detected an outdated %s file. The old "
727
+ "file will be replaced by the new one." % filename )
728
+
729
+ new_config = find_valid_example_file (filename )
730
+ copy (config , join (
731
+ env .subst ("$PROJECTSRC_DIR" ), "%s.bak" % filename ))
732
+ copy (new_config , config )
733
+
637
734
638
- sdk_params = get_sdk_configuration (sdk_config_file )
735
+ process_project_configs ("sdkconfig" )
736
+ sdk_config = join (env .subst ("$PROJECTSRC_DIR" ), "sdkconfig" )
737
+
738
+ process_project_configs ("sdkconfig.h" )
739
+ sdk_config_header = join (env .subst ("$PROJECTSRC_DIR" ), "sdkconfig.h" )
740
+ sdk_params = get_sdk_configuration (sdk_config_header )
639
741
640
742
configure_exceptions (sdk_params )
641
743
@@ -689,35 +791,23 @@ def configure_exceptions(sdk_params):
689
791
690
792
libs = []
691
793
692
- if ulp_lib :
693
- if not is_ulp_enabled (sdk_params ):
694
- print ("Warning! ULP is not properly configured. "
695
- "Add the next configuration lines to your sdkconfig.h:" )
696
- print (" #define CONFIG_ULP_COPROC_ENABLED 1" )
697
- print (" #define CONFIG_ULP_COPROC_RESERVE_MEM 1024" )
698
-
699
- libs .append (ulp_lib )
700
- env .Append (
701
- CPPPATH = [join ("$BUILD_DIR" , "ulp_app" )],
702
- LIBPATH = [join ("$BUILD_DIR" , "ulp_app" )],
703
- LINKFLAGS = ["-T" , "ulp_main.ld" ]
704
- )
705
-
706
794
ignore_dirs = (
707
795
"bootloader" ,
708
796
"esptool_py" ,
709
- "espcoredump" ,
710
797
"idf_test" ,
711
798
"partition_table"
712
799
)
713
800
714
801
special_src_filter = {
715
802
"app_trace" : "+<*> -<test> -<sys_view> -<gcov>" ,
803
+ "asio" : "-<*> +<asio/asio/src/asio.cpp>" ,
716
804
"aws_iot" : "-<*> +<port> +<aws-iot-device-sdk-embedded-C/src>" ,
717
805
"esp32" : "-<*> +<*.[sSc]*> +<hwcrypto>" ,
718
806
"bootloader_support" : "+<*> -<test> -<src/bootloader_init.c>" ,
719
807
"soc" : "+<*> -<test> -<esp32/test>" ,
720
- "spi_flash" : "+<*> -<test*> -<sim>"
808
+ "spi_flash" : "+<*> -<test*> -<sim>" ,
809
+ "efuse" : "+<*> -<test*>" ,
810
+ "unity" : "-<*> +<unity/src> +<*.c>"
721
811
}
722
812
723
813
special_env = (
@@ -726,17 +816,17 @@ def configure_exceptions(sdk_params):
726
816
"lwip" ,
727
817
"protocomm" ,
728
818
"libsodium" ,
729
- "wpa_supplicant"
819
+ "wpa_supplicant" ,
820
+ "wifi_provisioning"
730
821
)
731
822
732
823
for d in listdir (join (FRAMEWORK_DIR , "components" )):
733
824
if d in special_src_filter or d in special_env or d in ignore_dirs :
734
825
continue
735
826
component_dir = join (FRAMEWORK_DIR , "components" , d )
736
827
if isdir (component_dir ):
737
- libs .append (
738
- build_component (component_dir ,
739
- extract_component_config (component_dir )))
828
+ libs .append (build_component (
829
+ component_dir , extract_component_config (component_dir )))
740
830
741
831
742
832
for component , src_filter in special_src_filter .items ():
@@ -751,9 +841,35 @@ def configure_exceptions(sdk_params):
751
841
build_heap_lib (sdk_params ),
752
842
build_rtos_lib (),
753
843
build_libsodium_lib (),
754
- build_wpa_supplicant_lib ()
844
+ build_wpa_supplicant_lib (),
845
+ build_wifi_provisioning_lib ()
755
846
))
756
847
848
+ project_sections = env .Command (
849
+ join ("$BUILD_DIR" , "ldgen.section_infos" ), libs , generate_section_info )
850
+
851
+ project_linker_script = env .Command (
852
+ join ("$BUILD_DIR" , "esp32.project.ld" ),
853
+ project_sections , generate_project_ld_script ,
854
+ ENV = {"PYTHONPATH" : join (FRAMEWORK_DIR , "platformio" , "package_deps" ,
855
+ "py%d" % sys .version_info .major )})
856
+
857
+ env .Depends ("$BUILD_DIR/$PROGNAME$PROGSUFFIX" , project_linker_script )
858
+
859
+ if ulp_lib :
860
+ if not is_ulp_enabled (sdk_params ):
861
+ print ("Warning! ULP is not properly configured."
862
+ "Add next configuration lines to your sdkconfig.h:" )
863
+ print (" #define CONFIG_ULP_COPROC_ENABLED 1" )
864
+ print (" #define CONFIG_ULP_COPROC_RESERVE_MEM 1024" )
865
+
866
+ libs .append (ulp_lib )
867
+ env .Append (
868
+ CPPPATH = [join ("$BUILD_DIR" , "ulp_app" )],
869
+ LIBPATH = [join ("$BUILD_DIR" , "ulp_app" )],
870
+ LINKFLAGS = ["-T" , "ulp_main.ld" ]
871
+ )
872
+
757
873
#
758
874
# Process Arduino core
759
875
#
0 commit comments