|
67 | 67 | IDF_ENV_VERSION = "1.0.0"
|
68 | 68 | FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
|
69 | 69 | TOOLCHAIN_DIR = platform.get_package_dir(
|
70 |
| - "toolchain-%s" % ("riscv32-esp" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2") else ("xtensa-%s" % mcu)) |
| 70 | + "toolchain-riscv32-esp" |
| 71 | + if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4") |
| 72 | + else "toolchain-xtensa-esp-elf" |
71 | 73 | )
|
72 | 74 |
|
73 | 75 |
|
@@ -248,7 +250,7 @@ def populate_idf_env_vars(idf_env):
|
248 | 250 | os.path.dirname(get_python_exe()),
|
249 | 251 | ]
|
250 | 252 |
|
251 |
| - if mcu not in ("esp32c2", "esp32c3", "esp32c6","esp32h2"): |
| 253 | + if mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): |
252 | 254 | additional_packages.append(
|
253 | 255 | os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
|
254 | 256 | )
|
@@ -503,7 +505,7 @@ def extract_linker_script_fragments_backup(framework_components_dir, sdk_config)
|
503 | 505 | sys.stderr.write("Error: Failed to extract paths to linker script fragments\n")
|
504 | 506 | env.Exit(1)
|
505 | 507 |
|
506 |
| - if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"): |
| 508 | + if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): |
507 | 509 | result.append(os.path.join(framework_components_dir, "riscv", "linker.lf"))
|
508 | 510 |
|
509 | 511 | # Add extra linker fragments
|
@@ -644,16 +646,30 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
|
644 | 646 | '--objdump "{objdump}"'
|
645 | 647 | ).format(**args)
|
646 | 648 |
|
| 649 | + initial_ld_script = os.path.join( |
| 650 | + FRAMEWORK_DIR, |
| 651 | + "components", |
| 652 | + "esp_system", |
| 653 | + "ld", |
| 654 | + idf_variant, |
| 655 | + "sections.ld.in", |
| 656 | + ) |
| 657 | + |
| 658 | + if IDF5: |
| 659 | + initial_ld_script = preprocess_linker_file( |
| 660 | + initial_ld_script, |
| 661 | + os.path.join( |
| 662 | + BUILD_DIR, |
| 663 | + "esp-idf", |
| 664 | + "esp_system", |
| 665 | + "ld", |
| 666 | + "sections.ld.in", |
| 667 | + ) |
| 668 | + ) |
| 669 | + |
647 | 670 | return env.Command(
|
648 | 671 | 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 |
| - ), |
| 672 | + initial_ld_script, |
657 | 673 | env.VerboseAction(cmd, "Generating project linker script $TARGET"),
|
658 | 674 | )
|
659 | 675 |
|
@@ -1103,6 +1119,46 @@ def get_app_partition_offset(pt_table, pt_offset):
|
1103 | 1119 | return app_params.get("offset", "0x10000")
|
1104 | 1120 |
|
1105 | 1121 |
|
| 1122 | +def preprocess_linker_file(src_ld_script, target_ld_script): |
| 1123 | + return env.Command( |
| 1124 | + target_ld_script, |
| 1125 | + src_ld_script, |
| 1126 | + env.VerboseAction( |
| 1127 | + " ".join( |
| 1128 | + [ |
| 1129 | + os.path.join( |
| 1130 | + platform.get_package_dir("tool-cmake"), |
| 1131 | + "bin", |
| 1132 | + "cmake", |
| 1133 | + ), |
| 1134 | + "-DCC=%s" |
| 1135 | + % os.path.join( |
| 1136 | + TOOLCHAIN_DIR, |
| 1137 | + "bin", |
| 1138 | + "$CC", |
| 1139 | + ), |
| 1140 | + "-DSOURCE=$SOURCE", |
| 1141 | + "-DTARGET=$TARGET", |
| 1142 | + "-DCONFIG_DIR=%s" % os.path.join(BUILD_DIR, "config"), |
| 1143 | + "-DLD_DIR=%s" |
| 1144 | + % os.path.join( |
| 1145 | + FRAMEWORK_DIR, "components", "esp_system", "ld" |
| 1146 | + ), |
| 1147 | + "-P", |
| 1148 | + os.path.join( |
| 1149 | + "$BUILD_DIR", |
| 1150 | + "esp-idf", |
| 1151 | + "esp_system", |
| 1152 | + "ld", |
| 1153 | + "linker_script_generator.cmake", |
| 1154 | + ), |
| 1155 | + ] |
| 1156 | + ), |
| 1157 | + "Generating LD script $TARGET", |
| 1158 | + ), |
| 1159 | + ) |
| 1160 | + |
| 1161 | + |
1106 | 1162 | def generate_mbedtls_bundle(sdk_config):
|
1107 | 1163 | bundle_path = os.path.join("$BUILD_DIR", "x509_crt_bundle")
|
1108 | 1164 | if os.path.isfile(env.subst(bundle_path)):
|
@@ -1349,19 +1405,30 @@ def get_python_exe():
|
1349 | 1405 | #
|
1350 | 1406 |
|
1351 | 1407 | 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", |
| 1408 | + initial_ld_script = board.get("build.esp-idf.ldscript", os.path.join( |
| 1409 | + FRAMEWORK_DIR, |
| 1410 | + "components", |
| 1411 | + "esp_system", |
| 1412 | + "ld", |
| 1413 | + idf_variant, |
| 1414 | + "memory.ld.in", |
| 1415 | + )) |
| 1416 | + |
| 1417 | + if IDF5: |
| 1418 | + initial_ld_script = preprocess_linker_file( |
| 1419 | + initial_ld_script, |
1356 | 1420 | os.path.join(
|
1357 |
| - FRAMEWORK_DIR, |
1358 |
| - "components", |
| 1421 | + BUILD_DIR, |
| 1422 | + "esp-idf", |
1359 | 1423 | "esp_system",
|
1360 | 1424 | "ld",
|
1361 |
| - idf_variant, |
1362 | 1425 | "memory.ld.in",
|
1363 |
| - ), |
1364 |
| - ), |
| 1426 | + ) |
| 1427 | + ) |
| 1428 | + |
| 1429 | + linker_script = env.Command( |
| 1430 | + os.path.join("$BUILD_DIR", "memory.ld"), |
| 1431 | + initial_ld_script, |
1365 | 1432 | env.VerboseAction(
|
1366 | 1433 | '$CC -I"$BUILD_DIR/config" -I"%s" -C -P -x c -E $SOURCE -o $TARGET'
|
1367 | 1434 | % os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld"),
|
@@ -1601,7 +1668,7 @@ def _skip_prj_source_files(node):
|
1601 | 1668 | (
|
1602 | 1669 | board.get(
|
1603 | 1670 | "upload.bootloader_offset",
|
1604 |
| - "0x0" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32s3", "esp32h2") else "0x1000", |
| 1671 | + "0x0" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32s3", "esp32h2") else ("0x2000" if mcu in ("esp32p4") else "0x1000"), |
1605 | 1672 | ),
|
1606 | 1673 | os.path.join("$BUILD_DIR", "bootloader.bin"),
|
1607 | 1674 | ),
|
@@ -1712,7 +1779,7 @@ def _skip_prj_source_files(node):
|
1712 | 1779 | #
|
1713 | 1780 |
|
1714 | 1781 | 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"): |
| 1782 | +if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"): |
1716 | 1783 | env.SConscript("ulp.py", exports="env sdk_config project_config idf_variant")
|
1717 | 1784 |
|
1718 | 1785 | #
|
|
0 commit comments