Skip to content

Commit d4bfc01

Browse files
authored
Support esp-idf 4.4 (platformio#716)
Resolves platformio#711
1 parent 314a54f commit d4bfc01

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

builder/frameworks/espidf.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def _add_archive(archive_path, link_args):
345345
if fragment.startswith("-l"):
346346
link_args["LIBS"].extend(args)
347347
elif fragment.startswith("-L"):
348-
lib_path = fragment.replace("-L", "").strip()
348+
lib_path = fragment.replace("-L", "").strip(" '\"")
349349
_add_to_libpath(lib_path, link_args)
350350
elif fragment.startswith("-") and not fragment.startswith("-l"):
351351
# CMake mistakenly marks LINKFLAGS as libraries
@@ -482,22 +482,15 @@ def extract_linker_script_fragments(framework_components_dir, sdk_config):
482482
if mcu == "esp32c3":
483483
result.append(os.path.join(framework_components_dir, "riscv", "linker.lf"))
484484

485-
result.extend(
486-
[
487-
os.path.join(
488-
framework_components_dir,
489-
idf_variant,
490-
"ld",
491-
"%s_fragments.lf" % idf_variant,
492-
),
493-
os.path.join(
494-
framework_components_dir,
495-
idf_variant,
496-
"linker.lf",
497-
),
498-
os.path.join(framework_components_dir, "newlib", "newlib.lf"),
499-
]
500-
)
485+
# Add extra linker fragments
486+
for fragment in (
487+
os.path.join("esp_system", "app.lf"),
488+
os.path.join("esp_common", "common.lf"),
489+
os.path.join("esp_common", "soc.lf"),
490+
os.path.join("newlib", "system_libs.lf"),
491+
os.path.join("newlib", "newlib.lf"),
492+
):
493+
result.append(os.path.join(framework_components_dir, fragment))
501494

502495
if sdk_config.get("SPIRAM_CACHE_WORKAROUND", False):
503496
result.append(
@@ -580,13 +573,14 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
580573
).format(**args)
581574

582575
return env.Command(
583-
os.path.join("$BUILD_DIR", "%s.project.ld" % idf_variant),
576+
os.path.join("$BUILD_DIR", "sections.ld"),
584577
os.path.join(
585578
FRAMEWORK_DIR,
586579
"components",
587-
idf_variant,
580+
"esp_system",
588581
"ld",
589-
"%s.project.ld.in" % idf_variant,
582+
idf_variant,
583+
"sections.ld.in",
590584
),
591585
env.VerboseAction(cmd, "Generating project linker script $TARGET"),
592586
)
@@ -1115,22 +1109,23 @@ def _get_installed_pip_packages():
11151109
#
11161110

11171111
if not board.get("build.ldscript", ""):
1112+
linker_common = os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld")
11181113
linker_script = env.Command(
1119-
os.path.join("$BUILD_DIR", "%s_out.ld" % idf_variant),
1114+
os.path.join("$BUILD_DIR", "memory.ld"),
11201115
board.get(
11211116
"build.esp-idf.ldscript",
11221117
os.path.join(
1123-
FRAMEWORK_DIR, "components", idf_variant, "ld", "%s.ld" % idf_variant
1118+
FRAMEWORK_DIR, "components", "esp_system", "ld", idf_variant, "memory.ld.in"
11241119
),
11251120
),
11261121
env.VerboseAction(
1127-
'$CC -I"$BUILD_DIR/config" -C -P -x c -E $SOURCE -o $TARGET',
1122+
f'$CC -I"$BUILD_DIR/config" -I"{linker_common}" -C -P -x c -E $SOURCE -o $TARGET',
11281123
"Generating LD script $TARGET",
11291124
),
11301125
)
11311126

11321127
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", linker_script)
1133-
env.Replace(LDSCRIPT_PATH="%s_out.ld" % idf_variant)
1128+
env.Replace(LDSCRIPT_PATH="memory.ld")
11341129

11351130
#
11361131
# Generate partition table
@@ -1316,7 +1311,7 @@ def _get_installed_pip_packages():
13161311

13171312
# remove the main linker script flags '-T esp32_out.ld'
13181313
try:
1319-
ld_index = extra_flags.index("%s_out.ld" % idf_variant)
1314+
ld_index = extra_flags.index("memory.ld")
13201315
extra_flags.pop(ld_index)
13211316
extra_flags.pop(ld_index - 1)
13221317
except:

0 commit comments

Comments
 (0)