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()
|
idf_variant = mcu.lower()
|
||||||
|
|
||||||
FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
|
FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
|
||||||
|
TOOLCHAIN_DIR = platform.get_package_dir(
|
||||||
# Legacy toolchains for mixed IDF/Arduino projects
|
"toolchain-%s" % ("riscv32-esp" if mcu == "esp32c3" else ("xtensa-%s" % mcu))
|
||||||
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")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
assert os.path.isdir(FRAMEWORK_DIR)
|
assert os.path.isdir(FRAMEWORK_DIR)
|
||||||
@@ -233,7 +223,7 @@ def populate_idf_env_vars(idf_env):
|
|||||||
os.path.dirname(env.subst("$PYTHONEXE")),
|
os.path.dirname(env.subst("$PYTHONEXE")),
|
||||||
]
|
]
|
||||||
|
|
||||||
if mcu != "esp32c3":
|
if mcu not in ("esp32c3", "esp32s3"):
|
||||||
additional_packages.append(
|
additional_packages.append(
|
||||||
os.path.join(platform.get_package_dir("toolchain-%sulp" % mcu), "bin"),
|
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)
|
file(GLOB component_sources *.c* *.S)
|
||||||
idf_component_register(SRCS ${component_sources})
|
idf_component_register(SRCS ${component_sources})
|
||||||
"""
|
"""
|
||||||
dummy_component_path = os.path.join(BUILD_DIR, "__pio_env")
|
dummy_component_path = os.path.join(FRAMEWORK_DIR, "components", "__pio_env")
|
||||||
if not os.path.isdir(dummy_component_path):
|
if os.path.isdir(dummy_component_path):
|
||||||
os.makedirs(dummy_component_path)
|
return
|
||||||
|
|
||||||
|
os.makedirs(dummy_component_path)
|
||||||
|
|
||||||
for ext in (".cpp", ".c", ".S"):
|
for ext in (".cpp", ".c", ".S"):
|
||||||
dummy_file = os.path.join(dummy_component_path, "__dummy" + ext)
|
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:
|
with open(component_cmake, "w") as fp:
|
||||||
fp.write(prj_cmake_tpl)
|
fp.write(prj_cmake_tpl)
|
||||||
|
|
||||||
return dummy_component_path
|
|
||||||
|
|
||||||
|
|
||||||
def find_default_component(target_configs):
|
def find_default_component(target_configs):
|
||||||
for config in target_configs:
|
for config in target_configs:
|
||||||
@@ -1098,28 +1088,38 @@ def install_python_deps():
|
|||||||
|
|
||||||
install_python_deps()
|
install_python_deps()
|
||||||
|
|
||||||
|
|
||||||
# ESP-IDF package doesn't contain .git folder, instead package version is specified
|
# 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
|
# in a special file "version.h" in the root folder of the package
|
||||||
|
|
||||||
create_version_file()
|
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
|
# Generate final linker script
|
||||||
#
|
#
|
||||||
|
|
||||||
if not board.get("build.ldscript", ""):
|
if not board.get("build.ldscript", ""):
|
||||||
linker_common = os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld")
|
|
||||||
linker_script = env.Command(
|
linker_script = env.Command(
|
||||||
os.path.join("$BUILD_DIR", "memory.ld"),
|
os.path.join("$BUILD_DIR", "memory.ld"),
|
||||||
board.get(
|
board.get(
|
||||||
"build.esp-idf.ldscript",
|
"build.esp-idf.ldscript",
|
||||||
os.path.join(
|
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(
|
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",
|
"Generating LD script $TARGET",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -1127,37 +1127,6 @@ if not board.get("build.ldscript", ""):
|
|||||||
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", linker_script)
|
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", linker_script)
|
||||||
env.Replace(LDSCRIPT_PATH="memory.ld")
|
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
|
# 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
|
# 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'
|
# default 'src' folder we need to add this as an extra component. If there is no 'main'
|
||||||
# folder CMake won't generate dependencies properly
|
# folder CMake won't generate dependencies properly
|
||||||
extra_components = [generate_default_component()]
|
extra_components = []
|
||||||
if PROJECT_SRC_DIR != os.path.join(PROJECT_DIR, "main"):
|
if PROJECT_SRC_DIR != os.path.join(PROJECT_DIR, "main"):
|
||||||
extra_components.append(PROJECT_SRC_DIR)
|
extra_components.append(PROJECT_SRC_DIR)
|
||||||
if "arduino" in env.subst("$PIOFRAMEWORK"):
|
if "arduino" in env.subst("$PIOFRAMEWORK"):
|
||||||
@@ -1309,7 +1278,7 @@ libs = find_lib_deps(
|
|||||||
extra_flags = filter_args(link_args["LINKFLAGS"], ["-T", "-u"])
|
extra_flags = filter_args(link_args["LINKFLAGS"], ["-T", "-u"])
|
||||||
link_args["LINKFLAGS"] = sorted(list(set(link_args["LINKFLAGS"]) - set(extra_flags)))
|
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:
|
try:
|
||||||
ld_index = extra_flags.index("memory.ld")
|
ld_index = extra_flags.index("memory.ld")
|
||||||
extra_flags.pop(ld_index)
|
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)
|
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)
|
project_flags.update(link_args)
|
||||||
env.MergeFlags(project_flags)
|
env.MergeFlags(project_flags)
|
||||||
env.Prepend(
|
env.Prepend(
|
||||||
@@ -1369,7 +1375,8 @@ env.Prepend(
|
|||||||
FLASH_EXTRA_IMAGES=[
|
FLASH_EXTRA_IMAGES=[
|
||||||
(
|
(
|
||||||
board.get(
|
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"),
|
os.path.join("$BUILD_DIR", "bootloader.bin"),
|
||||||
),
|
),
|
||||||
|
|||||||
+2
-14
@@ -108,12 +108,7 @@ class Espressif32Platform(PlatformBase):
|
|||||||
# RISC-V based toolchain for ESP32C3, ESP32S2, ESP32S3 ULP
|
# RISC-V based toolchain for ESP32C3, ESP32S2, ESP32S3 ULP
|
||||||
self.packages["toolchain-riscv32-esp"]["optional"] = False
|
self.packages["toolchain-riscv32-esp"]["optional"] = False
|
||||||
|
|
||||||
is_legacy_project = (
|
if build_core == "mbcwb":
|
||||||
build_core == "mbcwb"
|
|
||||||
or set(("arduino", "espidf")) == set(frameworks)
|
|
||||||
)
|
|
||||||
|
|
||||||
if is_legacy_project:
|
|
||||||
# Remove the main toolchains from PATH
|
# Remove the main toolchains from PATH
|
||||||
for toolchain in (
|
for toolchain in (
|
||||||
"toolchain-xtensa-esp32",
|
"toolchain-xtensa-esp32",
|
||||||
@@ -127,16 +122,9 @@ class Espressif32Platform(PlatformBase):
|
|||||||
self.packages["toolchain-xtensa32"] = {
|
self.packages["toolchain-xtensa32"] = {
|
||||||
"type": "toolchain",
|
"type": "toolchain",
|
||||||
"owner": "platformio",
|
"owner": "platformio",
|
||||||
"version": "~2.80400.0"
|
"version": "~2.50200.0"
|
||||||
if "arduino" in frameworks and build_core != "mbcwb"
|
|
||||||
else "~2.50200.0",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Legacy setting for mixed IDF+Arduino projects
|
|
||||||
if set(("arduino", "espidf")) == set(frameworks):
|
|
||||||
# Arduino component is not compatible with ESP-IDF >=4.1
|
|
||||||
self.packages["framework-espidf"]["version"] = "~3.40001.0"
|
|
||||||
|
|
||||||
if build_core == "mbcwb":
|
if build_core == "mbcwb":
|
||||||
self.packages["framework-arduinoespressif32"]["optional"] = True
|
self.packages["framework-arduinoespressif32"]["optional"] = True
|
||||||
self.packages["framework-arduino-mbcwb"]["optional"] = False
|
self.packages["framework-arduino-mbcwb"]["optional"] = False
|
||||||
|
|||||||
Reference in New Issue
Block a user