Backport from upstream supporting all IDF 5.X
This commit is contained in:
@@ -58,12 +58,9 @@ board = env.BoardConfig()
|
|||||||
mcu = board.get("build.mcu", "esp32")
|
mcu = board.get("build.mcu", "esp32")
|
||||||
idf_variant = mcu.lower()
|
idf_variant = mcu.lower()
|
||||||
|
|
||||||
# Required until Arduino switches to v5
|
IDF_version = platform.get_package_version("framework-espidf")
|
||||||
IDF5 = (
|
IDF5 = IDF_version.split(".")[1].startswith("5") # bool; Major IDF5 ?
|
||||||
platform.get_package_version("framework-espidf")
|
IDF_minor = int(("".join(IDF_version.split(".")[1]))[1:3]) # Minor version as int
|
||||||
.split(".")[1]
|
|
||||||
.startswith("5")
|
|
||||||
)
|
|
||||||
IDF_ENV_VERSION = "1.0.0"
|
IDF_ENV_VERSION = "1.0.0"
|
||||||
FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
|
FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
|
||||||
TOOLCHAIN_DIR = platform.get_package_dir(
|
TOOLCHAIN_DIR = platform.get_package_dir(
|
||||||
@@ -248,7 +245,7 @@ def populate_idf_env_vars(idf_env):
|
|||||||
os.path.dirname(get_python_exe()),
|
os.path.dirname(get_python_exe()),
|
||||||
]
|
]
|
||||||
|
|
||||||
if mcu not in ("esp32c2", "esp32c3", "esp32c6","esp32h2"):
|
if mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"):
|
||||||
additional_packages.append(
|
additional_packages.append(
|
||||||
os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
|
os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
|
||||||
)
|
)
|
||||||
@@ -503,7 +500,7 @@ def extract_linker_script_fragments_backup(framework_components_dir, sdk_config)
|
|||||||
sys.stderr.write("Error: Failed to extract paths to linker script fragments\n")
|
sys.stderr.write("Error: Failed to extract paths to linker script fragments\n")
|
||||||
env.Exit(1)
|
env.Exit(1)
|
||||||
|
|
||||||
if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"):
|
if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"):
|
||||||
result.append(os.path.join(framework_components_dir, "riscv", "linker.lf"))
|
result.append(os.path.join(framework_components_dir, "riscv", "linker.lf"))
|
||||||
|
|
||||||
# Add extra linker fragments
|
# Add extra linker fragments
|
||||||
@@ -644,16 +641,30 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
|
|||||||
'--objdump "{objdump}"'
|
'--objdump "{objdump}"'
|
||||||
).format(**args)
|
).format(**args)
|
||||||
|
|
||||||
|
initial_ld_script = os.path.join(
|
||||||
|
FRAMEWORK_DIR,
|
||||||
|
"components",
|
||||||
|
"esp_system",
|
||||||
|
"ld",
|
||||||
|
idf_variant,
|
||||||
|
"sections.ld.in",
|
||||||
|
)
|
||||||
|
|
||||||
|
if IDF5 and IDF_minor > 2:
|
||||||
|
initial_ld_script = preprocess_linker_file(
|
||||||
|
initial_ld_script,
|
||||||
|
os.path.join(
|
||||||
|
BUILD_DIR,
|
||||||
|
"esp-idf",
|
||||||
|
"esp_system",
|
||||||
|
"ld",
|
||||||
|
"sections.ld.in",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return env.Command(
|
return env.Command(
|
||||||
os.path.join("$BUILD_DIR", "sections.ld"),
|
os.path.join("$BUILD_DIR", "sections.ld"),
|
||||||
os.path.join(
|
initial_ld_script,
|
||||||
FRAMEWORK_DIR,
|
|
||||||
"components",
|
|
||||||
"esp_system",
|
|
||||||
"ld",
|
|
||||||
idf_variant,
|
|
||||||
"sections.ld.in",
|
|
||||||
),
|
|
||||||
env.VerboseAction(cmd, "Generating project linker script $TARGET"),
|
env.VerboseAction(cmd, "Generating project linker script $TARGET"),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1103,6 +1114,46 @@ def get_app_partition_offset(pt_table, pt_offset):
|
|||||||
return app_params.get("offset", "0x10000")
|
return app_params.get("offset", "0x10000")
|
||||||
|
|
||||||
|
|
||||||
|
def preprocess_linker_file(src_ld_script, target_ld_script):
|
||||||
|
return env.Command(
|
||||||
|
target_ld_script,
|
||||||
|
src_ld_script,
|
||||||
|
env.VerboseAction(
|
||||||
|
" ".join(
|
||||||
|
[
|
||||||
|
os.path.join(
|
||||||
|
platform.get_package_dir("tool-cmake"),
|
||||||
|
"bin",
|
||||||
|
"cmake",
|
||||||
|
),
|
||||||
|
"-DCC=%s"
|
||||||
|
% os.path.join(
|
||||||
|
TOOLCHAIN_DIR,
|
||||||
|
"bin",
|
||||||
|
"$CC",
|
||||||
|
),
|
||||||
|
"-DSOURCE=$SOURCE",
|
||||||
|
"-DTARGET=$TARGET",
|
||||||
|
"-DCONFIG_DIR=%s" % os.path.join(BUILD_DIR, "config"),
|
||||||
|
"-DLD_DIR=%s"
|
||||||
|
% os.path.join(
|
||||||
|
FRAMEWORK_DIR, "components", "esp_system", "ld"
|
||||||
|
),
|
||||||
|
"-P",
|
||||||
|
os.path.join(
|
||||||
|
"$BUILD_DIR",
|
||||||
|
"esp-idf",
|
||||||
|
"esp_system",
|
||||||
|
"ld",
|
||||||
|
"linker_script_generator.cmake",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
"Generating LD script $TARGET",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def generate_mbedtls_bundle(sdk_config):
|
def generate_mbedtls_bundle(sdk_config):
|
||||||
bundle_path = os.path.join("$BUILD_DIR", "x509_crt_bundle")
|
bundle_path = os.path.join("$BUILD_DIR", "x509_crt_bundle")
|
||||||
if os.path.isfile(env.subst(bundle_path)):
|
if os.path.isfile(env.subst(bundle_path)):
|
||||||
@@ -1349,19 +1400,30 @@ generate_default_component()
|
|||||||
#
|
#
|
||||||
|
|
||||||
if not board.get("build.ldscript", ""):
|
if not board.get("build.ldscript", ""):
|
||||||
linker_script = env.Command(
|
initial_ld_script = board.get("build.esp-idf.ldscript", os.path.join(
|
||||||
os.path.join("$BUILD_DIR", "memory.ld"),
|
FRAMEWORK_DIR,
|
||||||
board.get(
|
"components",
|
||||||
"build.esp-idf.ldscript",
|
"esp_system",
|
||||||
|
"ld",
|
||||||
|
idf_variant,
|
||||||
|
"memory.ld.in",
|
||||||
|
))
|
||||||
|
|
||||||
|
if IDF5 and IDF_minor > 2:
|
||||||
|
initial_ld_script = preprocess_linker_file(
|
||||||
|
initial_ld_script,
|
||||||
os.path.join(
|
os.path.join(
|
||||||
FRAMEWORK_DIR,
|
BUILD_DIR,
|
||||||
"components",
|
"esp-idf",
|
||||||
"esp_system",
|
"esp_system",
|
||||||
"ld",
|
"ld",
|
||||||
idf_variant,
|
|
||||||
"memory.ld.in",
|
"memory.ld.in",
|
||||||
),
|
)
|
||||||
),
|
)
|
||||||
|
|
||||||
|
linker_script = env.Command(
|
||||||
|
os.path.join("$BUILD_DIR", "memory.ld"),
|
||||||
|
initial_ld_script,
|
||||||
env.VerboseAction(
|
env.VerboseAction(
|
||||||
'$CC -I"$BUILD_DIR/config" -I"%s" -C -P -x c -E $SOURCE -o $TARGET'
|
'$CC -I"$BUILD_DIR/config" -I"%s" -C -P -x c -E $SOURCE -o $TARGET'
|
||||||
% os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld"),
|
% os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld"),
|
||||||
@@ -1601,7 +1663,7 @@ env.Prepend(
|
|||||||
(
|
(
|
||||||
board.get(
|
board.get(
|
||||||
"upload.bootloader_offset",
|
"upload.bootloader_offset",
|
||||||
"0x0" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32s3", "esp32h2") else "0x1000",
|
"0x0" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32s3", "esp32h2") else ("0x2000" if mcu in ("esp32p4") else "0x1000"),
|
||||||
),
|
),
|
||||||
os.path.join("$BUILD_DIR", "bootloader.bin"),
|
os.path.join("$BUILD_DIR", "bootloader.bin"),
|
||||||
),
|
),
|
||||||
@@ -1712,7 +1774,7 @@ env["BUILDERS"]["ElfToBin"].action = action
|
|||||||
#
|
#
|
||||||
|
|
||||||
ulp_dir = os.path.join(PROJECT_DIR, "ulp")
|
ulp_dir = os.path.join(PROJECT_DIR, "ulp")
|
||||||
if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32h2"):
|
if os.path.isdir(ulp_dir) and os.listdir(ulp_dir) and mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"):
|
||||||
env.SConscript("ulp.py", exports="env sdk_config project_config idf_variant")
|
env.SConscript("ulp.py", exports="env sdk_config project_config idf_variant")
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user