Skip to content

fix espota / small refactor / CI examples #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions builder/frameworks/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@
"""

from os.path import join

from SCons.Script import DefaultEnvironment, SConscript

env = DefaultEnvironment()
board = env.BoardConfig()
extra_flags = board.get("build.extra_flags", "")
extra_flags = [element.replace("-D", " ") for element in extra_flags]
extra_flags = ''.join(extra_flags)
build_flags = env.GetProjectOption("build_flags")
build_flags = [element.replace("-D", " ") for element in build_flags]
build_flags = ''.join(build_flags)

extra_flags = ''.join([element.replace("-D", " ") for element in env.BoardConfig().get("build.extra_flags", "")])
build_flags = ''.join([element.replace("-D", " ") for element in env.GetProjectOption("build_flags")])

SConscript("_embed_files.py", exports="env")

Expand All @@ -43,13 +38,13 @@
"framework-arduino-solo1"), "tools", "platformio-build.py"))
env["INTEGRATION_EXTRA_DATA"].update({"application_offset": env.subst("$ESP32_APP_OFFSET")})

elif "arduino" in env.subst("$PIOFRAMEWORK") and "FRAMEWORK_ARDUINO_ITEAD" in build_flags and "espidf" not in env.subst("$PIOFRAMEWORK"):
elif ("CORE32ITEAD" in extra_flags or "FRAMEWORK_ARDUINO_ITEAD" in build_flags) and ("arduino" in env.subst("$PIOFRAMEWORK") and "espidf" not in env.subst("$PIOFRAMEWORK")):
SConscript(
join(DefaultEnvironment().PioPlatform().get_package_dir(
"framework-arduino-ITEAD"), "tools", "platformio-build.py"))
env["INTEGRATION_EXTRA_DATA"].update({"application_offset": env.subst("$ESP32_APP_OFFSET")})

elif "arduino" in env.subst("$PIOFRAMEWORK") and "CORE32SOLO1" not in extra_flags and "FRAMEWORK_ARDUINO_ITEAD" not in build_flags and "espidf" not in env.subst("$PIOFRAMEWORK"):
elif "arduino" in env.subst("$PIOFRAMEWORK") and "CORE32SOLO1" not in extra_flags and "FRAMEWORK_ARDUINO_SOLO1" not in build_flags and "CORE32ITEAD" not in extra_flags and "FRAMEWORK_ARDUINO_ITEAD" not in build_flags and "espidf" not in env.subst("$PIOFRAMEWORK"):
SConscript(
join(DefaultEnvironment().PioPlatform().get_package_dir(
"framework-arduinoespressif32"), "tools", "platformio-build.py"))
Expand Down
20 changes: 15 additions & 5 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,24 @@

from platformio.util import get_serial_ports

env = DefaultEnvironment()
platform = env.PioPlatform()

#
# Helpers
#

extra_flags = ''.join([element.replace("-D", " ") for element in env.BoardConfig().get("build.extra_flags", "")])
build_flags = ''.join([element.replace("-D", " ") for element in env.GetProjectOption("build_flags")])

if "CORE32SOLO1" in extra_flags or "FRAMEWORK_ARDUINO_SOLO1" in build_flags:
FRAMEWORK_DIR = platform.get_package_dir("framework-arduino-solo1")
print ("Solo1 framework will be used")
elif "CORE32ITEAD" in extra_flags or "FRAMEWORK_ARDUINO_ITEAD" in build_flags:
FRAMEWORK_DIR = platform.get_package_dir("framework-arduino-ITEAD")
print ("ITEAD framework will be used")
else:
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")

def BeforeUpload(target, source, env):
upload_options = {}
Expand Down Expand Up @@ -167,8 +181,6 @@ def __fetch_fs_size(target, source, env):
return (target, source)


env = DefaultEnvironment()
platform = env.PioPlatform()
board = env.BoardConfig()
mcu = board.get("build.mcu", "esp32")
toolchain_arch = "xtensa-%s" % mcu
Expand Down Expand Up @@ -356,9 +368,7 @@ def __fetch_fs_size(target, source, env):
"See https://docs.platformio.org/page/platforms/"
"espressif32.html#over-the-air-ota-update\n")
env.Replace(
UPLOADER=join(
platform.get_package_dir("framework-arduinoespressif32") or "",
"tools", "espota.py"),
UPLOADER=join(FRAMEWORK_DIR,"tools", "espota.py"),
UPLOADERFLAGS=["--debug", "--progress", "-i", "$UPLOAD_PORT"],
UPLOADCMD='"$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS -f $SOURCE'
)
Expand Down
12 changes: 12 additions & 0 deletions examples/arduino-blink/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ framework = arduino
board = esp32doit-devkit-v1
monitor_speed = 115200

[env:esp32-solo1]
platform = espressif32
framework = arduino
board = esp32doit-devkit-v1
build_flags = -DFRAMEWORK_ARDUINO_SOLO1

[env:esp32-ITEAD]
platform = espressif32
framework = arduino
board = esp32doit-devkit-v1
build_flags = -DFRAMEWORK_ARDUINO_ITEAD

[env:lolin32]
platform = espressif32
framework = arduino
Expand Down