Skip to content

Commit

Permalink
Merge branch 'feature/i53' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros committed Jul 30, 2024
2 parents 3ef6a7a + cb702f4 commit bbe4952
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 26 deletions.
103 changes: 85 additions & 18 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,16 +652,30 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
'--objdump "{objdump}"'
).format(**args)

initial_ld_script = os.path.join(
FRAMEWORK_DIR,
"components",
"esp_system",
"ld",
idf_variant,
"sections.ld.in",
)

if IDF5:
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(
os.path.join("$BUILD_DIR", "sections.ld"),
os.path.join(
FRAMEWORK_DIR,
"components",
"esp_system",
"ld",
idf_variant,
"sections.ld.in",
),
initial_ld_script,
env.VerboseAction(cmd, "Generating project linker script $TARGET"),
)

Expand Down Expand Up @@ -1111,6 +1125,46 @@ def get_app_partition_offset(pt_table, pt_offset):
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):
bundle_path = os.path.join("$BUILD_DIR", "x509_crt_bundle")
if os.path.isfile(env.subst(bundle_path)):
Expand Down Expand Up @@ -1356,19 +1410,30 @@ def get_python_exe():
#

if not board.get("build.ldscript", ""):
linker_script = env.Command(
os.path.join("$BUILD_DIR", "memory.ld"),
board.get(
"build.esp-idf.ldscript",
initial_ld_script = board.get("build.esp-idf.ldscript", os.path.join(
FRAMEWORK_DIR,
"components",
"esp_system",
"ld",
idf_variant,
"memory.ld.in",
))

if IDF5:
initial_ld_script = preprocess_linker_file(
initial_ld_script,
os.path.join(
FRAMEWORK_DIR,
"components",
BUILD_DIR,
"esp-idf",
"esp_system",
"ld",
idf_variant,
"memory.ld.in",
),
),
)
)

linker_script = env.Command(
os.path.join("$BUILD_DIR", "memory.ld"),
initial_ld_script,
env.VerboseAction(
'$CC -I"$BUILD_DIR/config" -I"%s" -C -P -x c -E $SOURCE -o $TARGET'
% os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld"),
Expand Down Expand Up @@ -1530,7 +1595,9 @@ def get_python_exe():

# Extra flags which need to be explicitly specified in LINKFLAGS section because SCons
# cannot merge them correctly
extra_flags = filter_args(link_args["LINKFLAGS"], ["-T", "-u"])
extra_flags = filter_args(
link_args["LINKFLAGS"], ["-T", "-u", "-Wl,--start-group", "-Wl,--end-group"]
)
link_args["LINKFLAGS"] = sorted(list(set(link_args["LINKFLAGS"]) - set(extra_flags)))

# remove the main linker script flags '-T memory.ld'
Expand Down
12 changes: 9 additions & 3 deletions builder/frameworks/ulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import sys

from platformio import fs
from platformio.util import get_systype
Expand Down Expand Up @@ -60,7 +61,7 @@ def prepare_ulp_env_vars(env):

def collect_ulp_sources():
return [
fs.to_unix_path(os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp", f))
os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp", f)
for f in os.listdir(os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp"))
if f.endswith((".c", ".S", ".s"))
]
Expand Down Expand Up @@ -98,7 +99,7 @@ def _generate_ulp_configuration_action(env, target, source):
"-riscv" if riscv_ulp_enabled else "",
),
),
"-DULP_S_SOURCES=%s" % ";".join([s.get_abspath() for s in source]),
"-DULP_S_SOURCES=%s" % ";".join([fs.to_unix_path(s.get_abspath()) for s in source]),
"-DULP_APP_NAME=ulp_main",
"-DCOMPONENT_DIR=" + os.path.join(ulp_env.subst("$PROJECT_DIR"), "ulp"),
"-DCOMPONENT_INCLUDES=%s" % ";".join(get_component_includes(target_config)),
Expand All @@ -113,7 +114,12 @@ def _generate_ulp_configuration_action(env, target, source):
os.path.join(FRAMEWORK_DIR, "components", "ulp", "cmake"),
)

exec_command(cmd)
print(555, cmd)

result = exec_command(cmd)
if result["returncode"] != 0:
sys.stderr.write(result["err"] + "\n")
env.Exit(1)

ulp_sources = collect_ulp_sources()
ulp_sources.sort()
Expand Down
8 changes: 4 additions & 4 deletions platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
"optional": true,
"owner": "espressif",
"version": "8.4.0+2021r2-patch5",
"optionalVersions": ["13.2.0+20230928"]
"optionalVersions": ["13.2.0+20240530"]
},
"toolchain-xtensa-esp-elf": {
"type": "toolchain",
"optional": true,
"owner": "platformio",
"version": "13.2.0+20230928"
"version": "13.2.0+20240530"
},
"toolchain-esp32ulp": {
"type": "toolchain",
"optional": true,
"owner": "platformio",
"version": "~1.23500.0"
"version": "~1.23800.0"
},
"tool-xtensa-esp-elf-gdb": {
"type": "debugger",
Expand All @@ -88,7 +88,7 @@
"type": "framework",
"optional": true,
"owner": "platformio",
"version": "~3.50202.0",
"version": "~3.50300.0",
"optionalVersions": ["~3.40407.0"]
},
"tool-esptoolpy": {
Expand Down
2 changes: 1 addition & 1 deletion platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def configure_default_packages(self, variables, targets):
self.packages["toolchain-riscv32-esp"]["owner"] = "platformio"
self.packages["toolchain-riscv32-esp"][
"version"
] = "13.2.0+20230928"
] = "13.2.0+20240530"

if "arduino" in frameworks:
# Disable standalone GDB packages for Arduino and Arduino/IDF projects
Expand Down

0 comments on commit bbe4952

Please sign in to comment.