|
58 | 58 | mcu = board.get("build.mcu", "esp32")
|
59 | 59 | idf_variant = mcu.lower()
|
60 | 60 |
|
61 |
| -# Required until Arduino switches to v5 |
62 | 61 | IDF5 = (
|
63 | 62 | platform.get_package_version("framework-espidf")
|
64 | 63 | .split(".")[1]
|
@@ -248,13 +247,13 @@ def populate_idf_env_vars(idf_env):
|
248 | 247 | os.path.dirname(get_python_exe()),
|
249 | 248 | ]
|
250 | 249 |
|
251 |
| - if mcu not in ("esp32c2", "esp32c3", "esp32c6","esp32h2"): |
| 250 | + if mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): |
252 | 251 | additional_packages.append(
|
253 | 252 | os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
|
254 | 253 | )
|
255 | 254 |
|
256 |
| - if IS_WINDOWS: |
257 |
| - additional_packages.append(platform.get_package_dir("tool-mconf")) |
| 255 | +# if IS_WINDOWS: |
| 256 | +# additional_packages.append(platform.get_package_dir("tool-mconf")) |
258 | 257 |
|
259 | 258 | idf_env["PATH"] = os.pathsep.join(additional_packages + [idf_env["PATH"]])
|
260 | 259 |
|
@@ -503,7 +502,7 @@ def extract_linker_script_fragments_backup(framework_components_dir, sdk_config)
|
503 | 502 | sys.stderr.write("Error: Failed to extract paths to linker script fragments\n")
|
504 | 503 | env.Exit(1)
|
505 | 504 |
|
506 |
| - if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"): |
| 505 | + if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): |
507 | 506 | result.append(os.path.join(framework_components_dir, "riscv", "linker.lf"))
|
508 | 507 |
|
509 | 508 | # Add extra linker fragments
|
@@ -644,16 +643,31 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
|
644 | 643 | '--objdump "{objdump}"'
|
645 | 644 | ).format(**args)
|
646 | 645 |
|
| 646 | + initial_ld_script = os.path.join( |
| 647 | + FRAMEWORK_DIR, |
| 648 | + "components", |
| 649 | + "esp_system", |
| 650 | + "ld", |
| 651 | + idf_variant, |
| 652 | + "sections.ld.in", |
| 653 | + ) |
| 654 | + |
| 655 | + framework_version = [int(v) for v in get_framework_version().split(".")] |
| 656 | + if framework_version[:2] > [5, 2]: |
| 657 | + initial_ld_script = preprocess_linker_file( |
| 658 | + initial_ld_script, |
| 659 | + os.path.join( |
| 660 | + BUILD_DIR, |
| 661 | + "esp-idf", |
| 662 | + "esp_system", |
| 663 | + "ld", |
| 664 | + "sections.ld.in", |
| 665 | + ) |
| 666 | + ) |
| 667 | + |
647 | 668 | return env.Command(
|
648 | 669 | os.path.join("$BUILD_DIR", "sections.ld"),
|
649 |
| - os.path.join( |
650 |
| - FRAMEWORK_DIR, |
651 |
| - "components", |
652 |
| - "esp_system", |
653 |
| - "ld", |
654 |
| - idf_variant, |
655 |
| - "sections.ld.in", |
656 |
| - ), |
| 670 | + initial_ld_script, |
657 | 671 | env.VerboseAction(cmd, "Generating project linker script $TARGET"),
|
658 | 672 | )
|
659 | 673 |
|
@@ -1103,6 +1117,46 @@ def get_app_partition_offset(pt_table, pt_offset):
|
1103 | 1117 | return app_params.get("offset", "0x10000")
|
1104 | 1118 |
|
1105 | 1119 |
|
| 1120 | +def preprocess_linker_file(src_ld_script, target_ld_script): |
| 1121 | + return env.Command( |
| 1122 | + target_ld_script, |
| 1123 | + src_ld_script, |
| 1124 | + env.VerboseAction( |
| 1125 | + " ".join( |
| 1126 | + [ |
| 1127 | + os.path.join( |
| 1128 | + platform.get_package_dir("tool-cmake"), |
| 1129 | + "bin", |
| 1130 | + "cmake", |
| 1131 | + ), |
| 1132 | + "-DCC=%s" |
| 1133 | + % os.path.join( |
| 1134 | + TOOLCHAIN_DIR, |
| 1135 | + "bin", |
| 1136 | + "$CC", |
| 1137 | + ), |
| 1138 | + "-DSOURCE=$SOURCE", |
| 1139 | + "-DTARGET=$TARGET", |
| 1140 | + "-DCONFIG_DIR=%s" % os.path.join(BUILD_DIR, "config"), |
| 1141 | + "-DLD_DIR=%s" |
| 1142 | + % os.path.join( |
| 1143 | + FRAMEWORK_DIR, "components", "esp_system", "ld" |
| 1144 | + ), |
| 1145 | + "-P", |
| 1146 | + os.path.join( |
| 1147 | + "$BUILD_DIR", |
| 1148 | + "esp-idf", |
| 1149 | + "esp_system", |
| 1150 | + "ld", |
| 1151 | + "linker_script_generator.cmake", |
| 1152 | + ), |
| 1153 | + ] |
| 1154 | + ), |
| 1155 | + "Generating LD script $TARGET", |
| 1156 | + ), |
| 1157 | + ) |
| 1158 | + |
| 1159 | + |
1106 | 1160 | def generate_mbedtls_bundle(sdk_config):
|
1107 | 1161 | bundle_path = os.path.join("$BUILD_DIR", "x509_crt_bundle")
|
1108 | 1162 | if os.path.isfile(env.subst(bundle_path)):
|
@@ -1238,16 +1292,16 @@ def _get_installed_pip_packages(python_exe_path):
|
1238 | 1292 | )
|
1239 | 1293 | )
|
1240 | 1294 |
|
1241 |
| - # A special "esp-windows-curses" python package is required on Windows |
1242 |
| - # for Menuconfig on IDF <5 |
1243 |
| - if not IDF5 and "esp-windows-curses" not in installed_packages: |
1244 |
| - env.Execute( |
1245 |
| - env.VerboseAction( |
1246 |
| - '"%s" -m pip install "file://%s/tools/kconfig_new/esp-windows-curses"' |
1247 |
| - % (python_exe_path, FRAMEWORK_DIR), |
1248 |
| - "Installing windows-curses package", |
1249 |
| - ) |
1250 |
| - ) |
| 1295 | +# # A special "esp-windows-curses" python package is required on Windows |
| 1296 | +# # for Menuconfig on IDF <5 |
| 1297 | +# if not IDF5 and "esp-windows-curses" not in installed_packages: |
| 1298 | +# env.Execute( |
| 1299 | +# env.VerboseAction( |
| 1300 | +# '"%s" -m pip install "file://%s/tools/kconfig_new/esp-windows-curses"' |
| 1301 | +# % (python_exe_path, FRAMEWORK_DIR), |
| 1302 | +# "Installing windows-curses package", |
| 1303 | +# ) |
| 1304 | +# ) |
1251 | 1305 |
|
1252 | 1306 |
|
1253 | 1307 | def get_idf_venv_dir():
|
@@ -1349,19 +1403,31 @@ def get_python_exe():
|
1349 | 1403 | #
|
1350 | 1404 |
|
1351 | 1405 | if not board.get("build.ldscript", ""):
|
1352 |
| - linker_script = env.Command( |
1353 |
| - os.path.join("$BUILD_DIR", "memory.ld"), |
1354 |
| - board.get( |
1355 |
| - "build.esp-idf.ldscript", |
| 1406 | + initial_ld_script = board.get("build.esp-idf.ldscript", os.path.join( |
| 1407 | + FRAMEWORK_DIR, |
| 1408 | + "components", |
| 1409 | + "esp_system", |
| 1410 | + "ld", |
| 1411 | + idf_variant, |
| 1412 | + "memory.ld.in", |
| 1413 | + )) |
| 1414 | + |
| 1415 | + framework_version = [int(v) for v in get_framework_version().split(".")] |
| 1416 | + if framework_version[:2] > [5, 2]: |
| 1417 | + initial_ld_script = preprocess_linker_file( |
| 1418 | + initial_ld_script, |
1356 | 1419 | os.path.join(
|
1357 |
| - FRAMEWORK_DIR, |
1358 |
| - "components", |
| 1420 | + BUILD_DIR, |
| 1421 | + "esp-idf", |
1359 | 1422 | "esp_system",
|
1360 | 1423 | "ld",
|
1361 |
| - idf_variant, |
1362 | 1424 | "memory.ld.in",
|
1363 |
| - ), |
1364 |
| - ), |
| 1425 | + ) |
| 1426 | + ) |
| 1427 | + |
| 1428 | + linker_script = env.Command( |
| 1429 | + os.path.join("$BUILD_DIR", "memory.ld"), |
| 1430 | + initial_ld_script, |
1365 | 1431 | env.VerboseAction(
|
1366 | 1432 | '$CC -I"$BUILD_DIR/config" -I"%s" -C -P -x c -E $SOURCE -o $TARGET'
|
1367 | 1433 | % os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld"),
|
@@ -1523,7 +1589,9 @@ def get_python_exe():
|
1523 | 1589 |
|
1524 | 1590 | # Extra flags which need to be explicitly specified in LINKFLAGS section because SCons
|
1525 | 1591 | # cannot merge them correctly
|
1526 |
| -extra_flags = filter_args(link_args["LINKFLAGS"], ["-T", "-u"]) |
| 1592 | +extra_flags = filter_args( |
| 1593 | + link_args["LINKFLAGS"], ["-T", "-u", "-Wl,--start-group", "-Wl,--end-group"] |
| 1594 | +) |
1527 | 1595 | link_args["LINKFLAGS"] = sorted(list(set(link_args["LINKFLAGS"]) - set(extra_flags)))
|
1528 | 1596 |
|
1529 | 1597 | # remove the main linker script flags '-T memory.ld'
|
@@ -1599,7 +1667,7 @@ def _skip_prj_source_files(node):
|
1599 | 1667 | (
|
1600 | 1668 | board.get(
|
1601 | 1669 | "upload.bootloader_offset",
|
1602 |
| - "0x0" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32s3", "esp32h2") else "0x1000", |
| 1670 | + "0x0" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32s3", "esp32h2") else ("0x2000" if mcu in ("esp32p4") else "0x1000"), |
1603 | 1671 | ),
|
1604 | 1672 | os.path.join("$BUILD_DIR", "bootloader.bin"),
|
1605 | 1673 | ),
|
@@ -1710,7 +1778,7 @@ def _skip_prj_source_files(node):
|
1710 | 1778 | #
|
1711 | 1779 |
|
1712 | 1780 | ulp_dir = os.path.join(PROJECT_DIR, "ulp")
|
1713 |
| -if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"): |
| 1781 | +if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): |
1714 | 1782 | env.SConscript("ulp.py", exports="env sdk_config project_config idf_variant")
|
1715 | 1783 |
|
1716 | 1784 | #
|
|
0 commit comments