diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index eb8e8c447..18e79cedd 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -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") @@ -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")) diff --git a/builder/main.py b/builder/main.py index 80ba655ac..66affa180 100644 --- a/builder/main.py +++ b/builder/main.py @@ -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 = {} @@ -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 @@ -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' ) diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini index b9bd7f537..78d55726c 100644 --- a/examples/arduino-blink/platformio.ini +++ b/examples/arduino-blink/platformio.ini @@ -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