e4ac072ea9
* IDF 5.3 support * IDF 5.3 * IDF 5.3 toolchains remove dynamic toolchains support, currently only older incompatible are possible to fetch. * Fix owner of * ULP compability for IDF 5.3 * remove debug print * Fix bootloader offset code retrieve * Update esp32-c6-devkitc-1.json * use espressif Arduino branch `release/v3.1.x` * Update README.md * Update README.md * Fix compile issue with managed components * use latest Arduino 3.1.0 libs * fetch Arduino libs dl URL from manifest json * fetch Arduino libs dl URL from manifest json * Update README.md * Fix IDF 5.3 ULP compile * Use espressif Arduino branch release/v3.1.x * Update platform.py * better handling of complex Macros from cmake model * IDF 5.3.1 release * fix handling of cc fragments * unchanged IDF 5.3.1 * ULP has now a cmake build script * add arduino/idf examples * fix used platform * prepare LP ULP support * enable bootloader components build * ULP LP support * add missing P4 * add P4 * change some if checks * Update README.md * remove wrong left over code * add ULP LP example / update Matter example * fix path * add zigbee examples * disable zigbee examples needs merge of the open zigbee Arduino PR * esptool.py v4.8.0 * add cmake_utilities for C2 * add auto select "espidf" when pio var "custom_sdkconfig" is set * IDF v5.3.1.240924 * Update main.py * matter example currently broken * Update platformio.ini * Update platformio.ini * Update platformio.ini * Update platformio.ini * Update examples.yml * IDF v5.3.1.241016 * Update Zigbee_On_Off_Light.ino * Update Zigbee_On_Off_Switch.ino * Update examples.yml * Update platformio.ini * Update platformio.ini * Update examples.yml * esptool.py v4.8.1.1 s2 s3 usb jtag reset fix * Update platform.py * Update gdb 14.2.0+20240403 * fix owner for gdb * Update IDF v5.3.1.241024 * Update adafruit_matrixportal_esp32s3.json * Use compatible h2zero NimBLE git commit * Update Zigbee_On_Off_Light.ino * Update Zigbee_On_Off_Switch.ino * fix custom partiton table offset calculation * Update README.md * Create esp32-p4.json * add P4 to blink example * Update Zigbee_On_Off_Switch.ino * Update Zigbee_On_Off_Light.ino * Update sdkconfig.defaults * add P4 to LP example * Create esp32-p4-evboard.json * IDF 5.3.2 release * prep for "pioarduino-build.py" script * add missing import os * fix not defined var * Update Zigbee_On_Off_Switch.ino * esptool.py v4.8.5 * Update Zigbee_On_Off_Light.ino * add Hybrid Compile (#73) * Update README.md * set Arduino compile option `UPDATE_NOCRYPT` in example Tasmota * Update C2 Hybrid compile skeleton * Update IDF v5.3.2.241210 * Revert to IDF 5.3.2 * Update pioarduino IDF 5.2 * Update release_zips.yml
182 lines
5.8 KiB
Python
182 lines
5.8 KiB
Python
# Copyright 2014-present PlatformIO <contact@platformio.org>
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import shutil
|
|
from os import SEEK_CUR, SEEK_END
|
|
from os.path import basename, isfile, join
|
|
|
|
from SCons.Script import Builder
|
|
|
|
Import("env")
|
|
|
|
board = env.BoardConfig()
|
|
|
|
#
|
|
# Embedded files helpers
|
|
#
|
|
|
|
|
|
def extract_files(cppdefines, files_type):
|
|
result = []
|
|
files = env.GetProjectOption("board_build.%s" % files_type, "").splitlines()
|
|
if files:
|
|
result.extend([join("$PROJECT_DIR", f.strip()) for f in files if f])
|
|
else:
|
|
files_define = "COMPONENT_" + files_type.upper()
|
|
for define in cppdefines:
|
|
if files_define not in define:
|
|
continue
|
|
|
|
value = define[1]
|
|
if not isinstance(define, tuple):
|
|
print("Warning! %s macro cannot be empty!" % files_define)
|
|
return []
|
|
|
|
if not isinstance(value, str):
|
|
print(
|
|
"Warning! %s macro must contain "
|
|
"a list of files separated by ':'" % files_define
|
|
)
|
|
return []
|
|
|
|
for f in value.split(":"):
|
|
if not f:
|
|
continue
|
|
result.append(join("$PROJECT_DIR", f))
|
|
|
|
for f in result:
|
|
if not isfile(env.subst(f)):
|
|
print('Warning! Could not find file "%s"' % basename(f))
|
|
|
|
return result
|
|
|
|
|
|
def remove_config_define(cppdefines, files_type):
|
|
for define in cppdefines:
|
|
if files_type in define:
|
|
env.ProcessUnFlags("-D%s" % "=".join(str(d) for d in define))
|
|
return
|
|
|
|
|
|
def prepare_file(source, target, env):
|
|
filepath = source[0].get_abspath()
|
|
shutil.copy(filepath, filepath + ".piobkp")
|
|
|
|
with open(filepath, "rb+") as fp:
|
|
fp.seek(-1, SEEK_END)
|
|
if fp.read(1) != "\0":
|
|
fp.seek(0, SEEK_CUR)
|
|
fp.write(b"\0")
|
|
|
|
|
|
def revert_original_file(source, target, env):
|
|
filepath = source[0].get_abspath()
|
|
if isfile(filepath + ".piobkp"):
|
|
shutil.move(filepath + ".piobkp", filepath)
|
|
|
|
|
|
def embed_files(files, files_type):
|
|
for f in files:
|
|
filename = basename(f) + ".txt.o"
|
|
file_target = env.TxtToBin(join("$BUILD_DIR", filename), f)
|
|
env.Depends("$PIOMAINPROG", file_target)
|
|
if files_type == "embed_txtfiles":
|
|
env.AddPreAction(file_target, prepare_file)
|
|
env.AddPostAction(file_target, revert_original_file)
|
|
env.AppendUnique(PIOBUILDFILES=[env.File(join("$BUILD_DIR", filename))])
|
|
|
|
|
|
def transform_to_asm(target, source, env):
|
|
files = [join("$BUILD_DIR", s.name + ".S") for s in source]
|
|
return files, source
|
|
|
|
|
|
mcu = board.get("build.mcu", "esp32")
|
|
env.Append(
|
|
BUILDERS=dict(
|
|
TxtToBin=Builder(
|
|
action=env.VerboseAction(
|
|
" ".join(
|
|
[
|
|
"riscv32-esp-elf-objcopy"
|
|
if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2","esp32p4")
|
|
else "xtensa-%s-elf-objcopy" % mcu,
|
|
"--input-target",
|
|
"binary",
|
|
"--output-target",
|
|
"elf32-littleriscv" if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2","esp32p4") else "elf32-xtensa-le",
|
|
"--binary-architecture",
|
|
"riscv" if mcu in ("esp32c2","esp32c3","esp32c6","esp32h2","esp32p4") else "xtensa",
|
|
"--rename-section",
|
|
".data=.rodata.embedded",
|
|
"$SOURCE",
|
|
"$TARGET",
|
|
]
|
|
),
|
|
"Converting $TARGET",
|
|
),
|
|
suffix=".txt.o",
|
|
),
|
|
FileToAsm=Builder(
|
|
action=env.VerboseAction(
|
|
" ".join(
|
|
[
|
|
join(
|
|
env.PioPlatform().get_package_dir("tool-cmake") or "",
|
|
"bin",
|
|
"cmake",
|
|
),
|
|
"-DDATA_FILE=$SOURCE",
|
|
"-DSOURCE_FILE=$TARGET",
|
|
"-DFILE_TYPE=$FILE_TYPE",
|
|
"-P",
|
|
join(
|
|
env.PioPlatform().get_package_dir("framework-espidf") or "",
|
|
"tools",
|
|
"cmake",
|
|
"scripts",
|
|
"data_file_embed_asm.cmake",
|
|
),
|
|
]
|
|
),
|
|
"Generating assembly for $TARGET",
|
|
),
|
|
emitter=transform_to_asm,
|
|
single_source=True,
|
|
),
|
|
)
|
|
)
|
|
|
|
|
|
flags = env.get("CPPDEFINES")
|
|
for files_type in ("embed_txtfiles", "embed_files"):
|
|
if (
|
|
"COMPONENT_" + files_type.upper() not in env.Flatten(flags)
|
|
and "build." + files_type not in board
|
|
):
|
|
continue
|
|
|
|
files = extract_files(flags, files_type)
|
|
if "espidf" in env.subst("$PIOFRAMEWORK"):
|
|
env.Requires(
|
|
join("$BUILD_DIR", "${PROGNAME}.elf"),
|
|
env.FileToAsm(
|
|
files,
|
|
FILE_TYPE="TEXT" if files_type == "embed_txtfiles" else "BINARY",
|
|
),
|
|
)
|
|
else:
|
|
embed_files(files, files_type)
|
|
remove_config_define(flags, files_type)
|