|
58 | 58 | mcu = board.get("build.mcu", "esp32")
|
59 | 59 | idf_variant = mcu.lower()
|
60 | 60 |
|
61 |
| -# Required until Arduino switches to v5 |
62 |
| -IDF5 = ( |
63 |
| - platform.get_package_version("framework-espidf") |
64 |
| - .split(".")[1] |
65 |
| - .startswith("5") |
66 |
| -) |
| 61 | +IDF_version = platform.get_package_version("framework-espidf") |
| 62 | +IDF5 = IDF_version.split(".")[1].startswith("5") # bool; Major IDF5 ? |
| 63 | +IDF_minor = int(("".join(IDF_version.split(".")[1]))[1:3]) # Minor version as int |
67 | 64 | IDF_ENV_VERSION = "1.0.0"
|
68 | 65 | FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
|
69 | 66 | TOOLCHAIN_DIR = platform.get_package_dir(
|
@@ -248,7 +245,7 @@ def populate_idf_env_vars(idf_env):
|
248 | 245 | os.path.dirname(get_python_exe()),
|
249 | 246 | ]
|
250 | 247 |
|
251 |
| - if mcu not in ("esp32c2", "esp32c3", "esp32c6","esp32h2"): |
| 248 | + if mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): |
252 | 249 | additional_packages.append(
|
253 | 250 | os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
|
254 | 251 | )
|
@@ -503,7 +500,7 @@ def extract_linker_script_fragments_backup(framework_components_dir, sdk_config)
|
503 | 500 | sys.stderr.write("Error: Failed to extract paths to linker script fragments\n")
|
504 | 501 | env.Exit(1)
|
505 | 502 |
|
506 |
| - if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"): |
| 503 | + if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): |
507 | 504 | result.append(os.path.join(framework_components_dir, "riscv", "linker.lf"))
|
508 | 505 |
|
509 | 506 | # Add extra linker fragments
|
@@ -644,16 +641,30 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
|
644 | 641 | '--objdump "{objdump}"'
|
645 | 642 | ).format(**args)
|
646 | 643 |
|
| 644 | + initial_ld_script = os.path.join( |
| 645 | + FRAMEWORK_DIR, |
| 646 | + "components", |
| 647 | + "esp_system", |
| 648 | + "ld", |
| 649 | + idf_variant, |
| 650 | + "sections.ld.in", |
| 651 | + ) |
| 652 | + |
| 653 | + if IDF5 and IDF_minor > 2: |
| 654 | + initial_ld_script = preprocess_linker_file( |
| 655 | + initial_ld_script, |
| 656 | + os.path.join( |
| 657 | + BUILD_DIR, |
| 658 | + "esp-idf", |
| 659 | + "esp_system", |
| 660 | + "ld", |
| 661 | + "sections.ld.in", |
| 662 | + ) |
| 663 | + ) |
| 664 | + |
647 | 665 | return env.Command(
|
648 | 666 | 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 |
| - ), |
| 667 | + initial_ld_script, |
657 | 668 | env.VerboseAction(cmd, "Generating project linker script $TARGET"),
|
658 | 669 | )
|
659 | 670 |
|
@@ -1103,6 +1114,46 @@ def get_app_partition_offset(pt_table, pt_offset):
|
1103 | 1114 | return app_params.get("offset", "0x10000")
|
1104 | 1115 |
|
1105 | 1116 |
|
| 1117 | +def preprocess_linker_file(src_ld_script, target_ld_script): |
| 1118 | + return env.Command( |
| 1119 | + target_ld_script, |
| 1120 | + src_ld_script, |
| 1121 | + env.VerboseAction( |
| 1122 | + " ".join( |
| 1123 | + [ |
| 1124 | + os.path.join( |
| 1125 | + platform.get_package_dir("tool-cmake"), |
| 1126 | + "bin", |
| 1127 | + "cmake", |
| 1128 | + ), |
| 1129 | + "-DCC=%s" |
| 1130 | + % os.path.join( |
| 1131 | + TOOLCHAIN_DIR, |
| 1132 | + "bin", |
| 1133 | + "$CC", |
| 1134 | + ), |
| 1135 | + "-DSOURCE=$SOURCE", |
| 1136 | + "-DTARGET=$TARGET", |
| 1137 | + "-DCONFIG_DIR=%s" % os.path.join(BUILD_DIR, "config"), |
| 1138 | + "-DLD_DIR=%s" |
| 1139 | + % os.path.join( |
| 1140 | + FRAMEWORK_DIR, "components", "esp_system", "ld" |
| 1141 | + ), |
| 1142 | + "-P", |
| 1143 | + os.path.join( |
| 1144 | + "$BUILD_DIR", |
| 1145 | + "esp-idf", |
| 1146 | + "esp_system", |
| 1147 | + "ld", |
| 1148 | + "linker_script_generator.cmake", |
| 1149 | + ), |
| 1150 | + ] |
| 1151 | + ), |
| 1152 | + "Generating LD script $TARGET", |
| 1153 | + ), |
| 1154 | + ) |
| 1155 | + |
| 1156 | + |
1106 | 1157 | def generate_mbedtls_bundle(sdk_config):
|
1107 | 1158 | bundle_path = os.path.join("$BUILD_DIR", "x509_crt_bundle")
|
1108 | 1159 | if os.path.isfile(env.subst(bundle_path)):
|
@@ -1349,19 +1400,30 @@ def get_python_exe():
|
1349 | 1400 | #
|
1350 | 1401 |
|
1351 | 1402 | 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", |
| 1403 | + initial_ld_script = board.get("build.esp-idf.ldscript", os.path.join( |
| 1404 | + FRAMEWORK_DIR, |
| 1405 | + "components", |
| 1406 | + "esp_system", |
| 1407 | + "ld", |
| 1408 | + idf_variant, |
| 1409 | + "memory.ld.in", |
| 1410 | + )) |
| 1411 | + |
| 1412 | + if IDF5 and IDF_minor > 2: |
| 1413 | + initial_ld_script = preprocess_linker_file( |
| 1414 | + initial_ld_script, |
1356 | 1415 | os.path.join(
|
1357 |
| - FRAMEWORK_DIR, |
1358 |
| - "components", |
| 1416 | + BUILD_DIR, |
| 1417 | + "esp-idf", |
1359 | 1418 | "esp_system",
|
1360 | 1419 | "ld",
|
1361 |
| - idf_variant, |
1362 | 1420 | "memory.ld.in",
|
1363 |
| - ), |
1364 |
| - ), |
| 1421 | + ) |
| 1422 | + ) |
| 1423 | + |
| 1424 | + linker_script = env.Command( |
| 1425 | + os.path.join("$BUILD_DIR", "memory.ld"), |
| 1426 | + initial_ld_script, |
1365 | 1427 | env.VerboseAction(
|
1366 | 1428 | '$CC -I"$BUILD_DIR/config" -I"%s" -C -P -x c -E $SOURCE -o $TARGET'
|
1367 | 1429 | % os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld"),
|
@@ -1601,7 +1663,7 @@ def _skip_prj_source_files(node):
|
1601 | 1663 | (
|
1602 | 1664 | board.get(
|
1603 | 1665 | "upload.bootloader_offset",
|
1604 |
| - "0x0" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32s3", "esp32h2") else "0x1000", |
| 1666 | + "0x0" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32s3", "esp32h2") else ("0x2000" if mcu in ("esp32p4") else "0x1000"), |
1605 | 1667 | ),
|
1606 | 1668 | os.path.join("$BUILD_DIR", "bootloader.bin"),
|
1607 | 1669 | ),
|
@@ -1712,7 +1774,7 @@ def _skip_prj_source_files(node):
|
1712 | 1774 | #
|
1713 | 1775 |
|
1714 | 1776 | ulp_dir = os.path.join(PROJECT_DIR, "ulp")
|
1715 |
| -if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32h2"): |
| 1777 | +if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): |
1716 | 1778 | env.SConscript("ulp.py", exports="env sdk_config project_config idf_variant")
|
1717 | 1779 |
|
1718 | 1780 | #
|
|
0 commit comments