Update IDF build script according to v4.4.1
This commit is contained in:
@@ -50,19 +50,9 @@ mcu = board.get("build.mcu", "esp32")
|
||||
idf_variant = mcu.lower()
|
||||
|
||||
FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
|
||||
|
||||
# Legacy toolchains for mixed IDF/Arduino projects
|
||||
if "arduino" in env.subst("$PIOFRAMEWORK"):
|
||||
TOOLCHAIN_DIR = platform.get_package_dir("toolchain-xtensa32")
|
||||
else:
|
||||
TOOLCHAIN_DIR = platform.get_package_dir(
|
||||
"toolchain-%s"
|
||||
% (
|
||||
"riscv32-esp"
|
||||
if mcu == "esp32c3"
|
||||
else ("xtensa-esp32s2" if mcu == "esp32s2" else "xtensa-esp32")
|
||||
)
|
||||
)
|
||||
TOOLCHAIN_DIR = platform.get_package_dir(
|
||||
"toolchain-%s" % ("riscv32-esp" if mcu == "esp32c3" else ("xtensa-%s" % mcu))
|
||||
)
|
||||
|
||||
|
||||
assert os.path.isdir(FRAMEWORK_DIR)
|
||||
@@ -233,7 +223,7 @@ def populate_idf_env_vars(idf_env):
|
||||
os.path.dirname(env.subst("$PYTHONEXE")),
|
||||
]
|
||||
|
||||
if mcu != "esp32c3":
|
||||
if mcu not in ("esp32c3", "esp32s3"):
|
||||
additional_packages.append(
|
||||
os.path.join(platform.get_package_dir("toolchain-%sulp" % mcu), "bin"),
|
||||
)
|
||||
@@ -857,9 +847,11 @@ def generate_default_component():
|
||||
file(GLOB component_sources *.c* *.S)
|
||||
idf_component_register(SRCS ${component_sources})
|
||||
"""
|
||||
dummy_component_path = os.path.join(BUILD_DIR, "__pio_env")
|
||||
if not os.path.isdir(dummy_component_path):
|
||||
os.makedirs(dummy_component_path)
|
||||
dummy_component_path = os.path.join(FRAMEWORK_DIR, "components", "__pio_env")
|
||||
if os.path.isdir(dummy_component_path):
|
||||
return
|
||||
|
||||
os.makedirs(dummy_component_path)
|
||||
|
||||
for ext in (".cpp", ".c", ".S"):
|
||||
dummy_file = os.path.join(dummy_component_path, "__dummy" + ext)
|
||||
@@ -871,8 +863,6 @@ idf_component_register(SRCS ${component_sources})
|
||||
with open(component_cmake, "w") as fp:
|
||||
fp.write(prj_cmake_tpl)
|
||||
|
||||
return dummy_component_path
|
||||
|
||||
|
||||
def find_default_component(target_configs):
|
||||
for config in target_configs:
|
||||
@@ -1098,28 +1088,38 @@ def install_python_deps():
|
||||
|
||||
install_python_deps()
|
||||
|
||||
|
||||
# ESP-IDF package doesn't contain .git folder, instead package version is specified
|
||||
# in a special file "version.h" in the root folder of the package
|
||||
|
||||
create_version_file()
|
||||
|
||||
# Generate a default component with dummy C/C++/ASM source files in the framework
|
||||
# folder. This component is used to force the IDF build system generate build
|
||||
# information for generic C/C++/ASM sources regardless of whether such files are used in project
|
||||
|
||||
generate_default_component()
|
||||
|
||||
#
|
||||
# Generate final linker script
|
||||
#
|
||||
|
||||
if not board.get("build.ldscript", ""):
|
||||
linker_common = os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld")
|
||||
linker_script = env.Command(
|
||||
os.path.join("$BUILD_DIR", "memory.ld"),
|
||||
board.get(
|
||||
"build.esp-idf.ldscript",
|
||||
os.path.join(
|
||||
FRAMEWORK_DIR, "components", "esp_system", "ld", idf_variant, "memory.ld.in"
|
||||
FRAMEWORK_DIR,
|
||||
"components",
|
||||
"esp_system",
|
||||
"ld",
|
||||
idf_variant,
|
||||
"memory.ld.in",
|
||||
),
|
||||
),
|
||||
env.VerboseAction(
|
||||
f'$CC -I"$BUILD_DIR/config" -I"{linker_common}" -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"),
|
||||
"Generating LD script $TARGET",
|
||||
),
|
||||
)
|
||||
@@ -1127,37 +1127,6 @@ if not board.get("build.ldscript", ""):
|
||||
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", linker_script)
|
||||
env.Replace(LDSCRIPT_PATH="memory.ld")
|
||||
|
||||
#
|
||||
# Generate partition table
|
||||
#
|
||||
|
||||
fwpartitions_dir = os.path.join(FRAMEWORK_DIR, "components", "partition_table")
|
||||
partitions_csv = board.get("build.partitions", "partitions_singleapp.csv")
|
||||
|
||||
env.Replace(
|
||||
PARTITIONS_TABLE_CSV=os.path.abspath(
|
||||
os.path.join(fwpartitions_dir, partitions_csv)
|
||||
if os.path.isfile(os.path.join(fwpartitions_dir, partitions_csv))
|
||||
else partitions_csv
|
||||
)
|
||||
)
|
||||
|
||||
partition_table = env.Command(
|
||||
os.path.join("$BUILD_DIR", "partitions.bin"),
|
||||
"$PARTITIONS_TABLE_CSV",
|
||||
env.VerboseAction(
|
||||
'"$PYTHONEXE" "%s" -q --flash-size "%s" $SOURCE $TARGET'
|
||||
% (
|
||||
os.path.join(
|
||||
FRAMEWORK_DIR, "components", "partition_table", "gen_esp32part.py"
|
||||
),
|
||||
board.get("upload.flash_size", "4MB"),
|
||||
),
|
||||
"Generating partitions $TARGET",
|
||||
),
|
||||
)
|
||||
|
||||
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table)
|
||||
|
||||
#
|
||||
# Current build script limitations
|
||||
@@ -1195,7 +1164,7 @@ if os.path.isfile(os.path.join(PROJECT_SRC_DIR, "sdkconfig.h")):
|
||||
# By default 'main' folder is used to store source files. In case when a user has
|
||||
# default 'src' folder we need to add this as an extra component. If there is no 'main'
|
||||
# folder CMake won't generate dependencies properly
|
||||
extra_components = [generate_default_component()]
|
||||
extra_components = []
|
||||
if PROJECT_SRC_DIR != os.path.join(PROJECT_DIR, "main"):
|
||||
extra_components.append(PROJECT_SRC_DIR)
|
||||
if "arduino" in env.subst("$PIOFRAMEWORK"):
|
||||
@@ -1309,7 +1278,7 @@ libs = find_lib_deps(
|
||||
extra_flags = filter_args(link_args["LINKFLAGS"], ["-T", "-u"])
|
||||
link_args["LINKFLAGS"] = sorted(list(set(link_args["LINKFLAGS"]) - set(extra_flags)))
|
||||
|
||||
# remove the main linker script flags '-T esp32_out.ld'
|
||||
# remove the main linker script flags '-T memory.ld'
|
||||
try:
|
||||
ld_index = extra_flags.index("memory.ld")
|
||||
extra_flags.pop(ld_index)
|
||||
@@ -1358,7 +1327,44 @@ if "__test" not in COMMAND_LINE_TARGETS or env.GetProjectOption(
|
||||
)
|
||||
)
|
||||
|
||||
#
|
||||
# Generate partition table
|
||||
#
|
||||
|
||||
fwpartitions_dir = os.path.join(FRAMEWORK_DIR, "components", "partition_table")
|
||||
partitions_csv = board.get("build.partitions", "partitions_singleapp.csv")
|
||||
partition_table_offset = sdk_config.get("PARTITION_TABLE_OFFSET", 0x8000)
|
||||
|
||||
env.Replace(
|
||||
PARTITIONS_TABLE_CSV=os.path.abspath(
|
||||
os.path.join(fwpartitions_dir, partitions_csv)
|
||||
if os.path.isfile(os.path.join(fwpartitions_dir, partitions_csv))
|
||||
else partitions_csv
|
||||
)
|
||||
)
|
||||
|
||||
partition_table = env.Command(
|
||||
os.path.join("$BUILD_DIR", "partitions.bin"),
|
||||
"$PARTITIONS_TABLE_CSV",
|
||||
env.VerboseAction(
|
||||
'"$PYTHONEXE" "%s" -q --offset "%s" --flash-size "%s" $SOURCE $TARGET'
|
||||
% (
|
||||
os.path.join(
|
||||
FRAMEWORK_DIR, "components", "partition_table", "gen_esp32part.py"
|
||||
),
|
||||
partition_table_offset,
|
||||
board.get("upload.flash_size", "4MB"),
|
||||
),
|
||||
"Generating partitions $TARGET",
|
||||
),
|
||||
)
|
||||
|
||||
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", partition_table)
|
||||
|
||||
#
|
||||
# Main environment configuration
|
||||
#
|
||||
|
||||
project_flags.update(link_args)
|
||||
env.MergeFlags(project_flags)
|
||||
env.Prepend(
|
||||
@@ -1369,7 +1375,8 @@ env.Prepend(
|
||||
FLASH_EXTRA_IMAGES=[
|
||||
(
|
||||
board.get(
|
||||
"upload.bootloader_offset", "0x0" if mcu == "esp32c3" else "0x1000"
|
||||
"upload.bootloader_offset",
|
||||
"0x0" if mcu in ("esp32c3", "esp32s3") else "0x1000",
|
||||
),
|
||||
os.path.join("$BUILD_DIR", "bootloader.bin"),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user