50
50
idf_variant = mcu .lower ()
51
51
52
52
FRAMEWORK_DIR = platform .get_package_dir ("framework-espidf" )
53
-
54
- # Legacy toolchains for mixed IDF/Arduino projects
55
- if "arduino" in env .subst ("$PIOFRAMEWORK" ):
56
- TOOLCHAIN_DIR = platform .get_package_dir ("toolchain-xtensa32" )
57
- else :
58
- TOOLCHAIN_DIR = platform .get_package_dir (
59
- "toolchain-%s"
60
- % (
61
- "riscv32-esp"
62
- if mcu == "esp32c3"
63
- else ("xtensa-esp32s2" if mcu == "esp32s2" else "xtensa-esp32" )
64
- )
65
- )
53
+ TOOLCHAIN_DIR = platform .get_package_dir (
54
+ "toolchain-%s" % ("riscv32-esp" if mcu == "esp32c3" else ("xtensa-%s" % mcu ))
55
+ )
66
56
67
57
68
58
assert os .path .isdir (FRAMEWORK_DIR )
@@ -233,7 +223,7 @@ def populate_idf_env_vars(idf_env):
233
223
os .path .dirname (env .subst ("$PYTHONEXE" )),
234
224
]
235
225
236
- if mcu != "esp32c3" :
226
+ if mcu not in ( "esp32c3" , "esp32s3" ) :
237
227
additional_packages .append (
238
228
os .path .join (platform .get_package_dir ("toolchain-%sulp" % mcu ), "bin" ),
239
229
)
@@ -857,9 +847,11 @@ def generate_default_component():
857
847
file(GLOB component_sources *.c* *.S)
858
848
idf_component_register(SRCS ${component_sources})
859
849
"""
860
- dummy_component_path = os .path .join (BUILD_DIR , "__pio_env" )
861
- if not os .path .isdir (dummy_component_path ):
862
- os .makedirs (dummy_component_path )
850
+ dummy_component_path = os .path .join (FRAMEWORK_DIR , "components" , "__pio_env" )
851
+ if os .path .isdir (dummy_component_path ):
852
+ return
853
+
854
+ os .makedirs (dummy_component_path )
863
855
864
856
for ext in (".cpp" , ".c" , ".S" ):
865
857
dummy_file = os .path .join (dummy_component_path , "__dummy" + ext )
@@ -871,8 +863,6 @@ def generate_default_component():
871
863
with open (component_cmake , "w" ) as fp :
872
864
fp .write (prj_cmake_tpl )
873
865
874
- return dummy_component_path
875
-
876
866
877
867
def find_default_component (target_configs ):
878
868
for config in target_configs :
@@ -1098,66 +1088,45 @@ def _get_installed_pip_packages():
1098
1088
1099
1089
install_python_deps ()
1100
1090
1101
-
1102
1091
# ESP-IDF package doesn't contain .git folder, instead package version is specified
1103
1092
# in a special file "version.h" in the root folder of the package
1104
1093
1105
1094
create_version_file ()
1106
1095
1096
+ # Generate a default component with dummy C/C++/ASM source files in the framework
1097
+ # folder. This component is used to force the IDF build system generate build
1098
+ # information for generic C/C++/ASM sources regardless of whether such files are used in project
1099
+
1100
+ generate_default_component ()
1101
+
1107
1102
#
1108
1103
# Generate final linker script
1109
1104
#
1110
1105
1111
1106
if not board .get ("build.ldscript" , "" ):
1112
- linker_common = os .path .join (FRAMEWORK_DIR , "components" , "esp_system" , "ld" )
1113
1107
linker_script = env .Command (
1114
1108
os .path .join ("$BUILD_DIR" , "memory.ld" ),
1115
1109
board .get (
1116
1110
"build.esp-idf.ldscript" ,
1117
1111
os .path .join (
1118
- FRAMEWORK_DIR , "components" , "esp_system" , "ld" , idf_variant , "memory.ld.in"
1112
+ FRAMEWORK_DIR ,
1113
+ "components" ,
1114
+ "esp_system" ,
1115
+ "ld" ,
1116
+ idf_variant ,
1117
+ "memory.ld.in" ,
1119
1118
),
1120
1119
),
1121
1120
env .VerboseAction (
1122
- f'$CC -I"$BUILD_DIR/config" -I"{ linker_common } " -C -P -x c -E $SOURCE -o $TARGET' ,
1121
+ '$CC -I"$BUILD_DIR/config" -I"%s" -C -P -x c -E $SOURCE -o $TARGET'
1122
+ % os .path .join (FRAMEWORK_DIR , "components" , "esp_system" , "ld" ),
1123
1123
"Generating LD script $TARGET" ,
1124
1124
),
1125
1125
)
1126
1126
1127
1127
env .Depends ("$BUILD_DIR/$PROGNAME$PROGSUFFIX" , linker_script )
1128
1128
env .Replace (LDSCRIPT_PATH = "memory.ld" )
1129
1129
1130
- #
1131
- # Generate partition table
1132
- #
1133
-
1134
- fwpartitions_dir = os .path .join (FRAMEWORK_DIR , "components" , "partition_table" )
1135
- partitions_csv = board .get ("build.partitions" , "partitions_singleapp.csv" )
1136
-
1137
- env .Replace (
1138
- PARTITIONS_TABLE_CSV = os .path .abspath (
1139
- os .path .join (fwpartitions_dir , partitions_csv )
1140
- if os .path .isfile (os .path .join (fwpartitions_dir , partitions_csv ))
1141
- else partitions_csv
1142
- )
1143
- )
1144
-
1145
- partition_table = env .Command (
1146
- os .path .join ("$BUILD_DIR" , "partitions.bin" ),
1147
- "$PARTITIONS_TABLE_CSV" ,
1148
- env .VerboseAction (
1149
- '"$PYTHONEXE" "%s" -q --flash-size "%s" $SOURCE $TARGET'
1150
- % (
1151
- os .path .join (
1152
- FRAMEWORK_DIR , "components" , "partition_table" , "gen_esp32part.py"
1153
- ),
1154
- board .get ("upload.flash_size" , "4MB" ),
1155
- ),
1156
- "Generating partitions $TARGET" ,
1157
- ),
1158
- )
1159
-
1160
- env .Depends ("$BUILD_DIR/$PROGNAME$PROGSUFFIX" , partition_table )
1161
1130
1162
1131
#
1163
1132
# Current build script limitations
@@ -1195,7 +1164,7 @@ def _get_installed_pip_packages():
1195
1164
# By default 'main' folder is used to store source files. In case when a user has
1196
1165
# default 'src' folder we need to add this as an extra component. If there is no 'main'
1197
1166
# folder CMake won't generate dependencies properly
1198
- extra_components = [generate_default_component () ]
1167
+ extra_components = []
1199
1168
if PROJECT_SRC_DIR != os .path .join (PROJECT_DIR , "main" ):
1200
1169
extra_components .append (PROJECT_SRC_DIR )
1201
1170
if "arduino" in env .subst ("$PIOFRAMEWORK" ):
@@ -1309,7 +1278,7 @@ def _get_installed_pip_packages():
1309
1278
extra_flags = filter_args (link_args ["LINKFLAGS" ], ["-T" , "-u" ])
1310
1279
link_args ["LINKFLAGS" ] = sorted (list (set (link_args ["LINKFLAGS" ]) - set (extra_flags )))
1311
1280
1312
- # remove the main linker script flags '-T esp32_out .ld'
1281
+ # remove the main linker script flags '-T memory .ld'
1313
1282
try :
1314
1283
ld_index = extra_flags .index ("memory.ld" )
1315
1284
extra_flags .pop (ld_index )
@@ -1358,7 +1327,44 @@ def _skip_prj_source_files(node):
1358
1327
)
1359
1328
)
1360
1329
1330
+ #
1331
+ # Generate partition table
1332
+ #
1333
+
1334
+ fwpartitions_dir = os .path .join (FRAMEWORK_DIR , "components" , "partition_table" )
1335
+ partitions_csv = board .get ("build.partitions" , "partitions_singleapp.csv" )
1361
1336
partition_table_offset = sdk_config .get ("PARTITION_TABLE_OFFSET" , 0x8000 )
1337
+
1338
+ env .Replace (
1339
+ PARTITIONS_TABLE_CSV = os .path .abspath (
1340
+ os .path .join (fwpartitions_dir , partitions_csv )
1341
+ if os .path .isfile (os .path .join (fwpartitions_dir , partitions_csv ))
1342
+ else partitions_csv
1343
+ )
1344
+ )
1345
+
1346
+ partition_table = env .Command (
1347
+ os .path .join ("$BUILD_DIR" , "partitions.bin" ),
1348
+ "$PARTITIONS_TABLE_CSV" ,
1349
+ env .VerboseAction (
1350
+ '"$PYTHONEXE" "%s" -q --offset "%s" --flash-size "%s" $SOURCE $TARGET'
1351
+ % (
1352
+ os .path .join (
1353
+ FRAMEWORK_DIR , "components" , "partition_table" , "gen_esp32part.py"
1354
+ ),
1355
+ partition_table_offset ,
1356
+ board .get ("upload.flash_size" , "4MB" ),
1357
+ ),
1358
+ "Generating partitions $TARGET" ,
1359
+ ),
1360
+ )
1361
+
1362
+ env .Depends ("$BUILD_DIR/$PROGNAME$PROGSUFFIX" , partition_table )
1363
+
1364
+ #
1365
+ # Main environment configuration
1366
+ #
1367
+
1362
1368
project_flags .update (link_args )
1363
1369
env .MergeFlags (project_flags )
1364
1370
env .Prepend (
@@ -1369,7 +1375,8 @@ def _skip_prj_source_files(node):
1369
1375
FLASH_EXTRA_IMAGES = [
1370
1376
(
1371
1377
board .get (
1372
- "upload.bootloader_offset" , "0x0" if mcu == "esp32c3" else "0x1000"
1378
+ "upload.bootloader_offset" ,
1379
+ "0x0" if mcu in ("esp32c3" , "esp32s3" ) else "0x1000" ,
1373
1380
),
1374
1381
os .path .join ("$BUILD_DIR" , "bootloader.bin" ),
1375
1382
),
0 commit comments