Skip to content

Commit 7915d3b

Browse files
authored
Fix compile Arduino as an component of IDF for C2
1 parent f491b75 commit 7915d3b

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

builder/frameworks/arduino.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,20 @@ def shorthen_includes(env, node):
230230
+ shortened_includes,
231231
)
232232

233+
# Check if framework = arduino, espidf is set -> compile Arduino as an component of IDF
234+
# using platformio.ini entry since we modify the framework env var for Hybrid Compile!
235+
def get_frameworks_in_current_env():
236+
current_env_section = "env:" + env["PIOENV"]
237+
if "framework" in config.options(current_env_section):
238+
frameworks = config.get(current_env_section, "framework", "")
239+
return frameworks
240+
return []
241+
242+
current_env_frameworks = get_frameworks_in_current_env()
243+
if "arduino" in current_env_frameworks and "espidf" in current_env_frameworks:
244+
# Arduino as component is set, switch off Hybrid compile
245+
flag_custom_sdkconfig = False
246+
233247
def call_compile_libs():
234248
if mcu == "esp32c2":
235249
ARDUINO_FRMWRK_C2_LIB_DIR = join(platform.get_package_dir("framework-arduinoespressif32-libs"),mcu)

builder/frameworks/espidf.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,14 @@ def _get_installed_standard_pip_packages():
155155
):
156156
print("Warning! Debugging an IDF project requires PlatformIO Core >= 6.1.11!")
157157

158-
# Arduino framework as a component is not compatible with ESP-IDF >5.3
159158
if "arduino" in env.subst("$PIOFRAMEWORK"):
160159
ARDUINO_FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
161160
ARDUINO_FRMWRK_LIB_DIR = platform.get_package_dir("framework-arduinoespressif32-libs")
161+
if mcu == "esp32c2":
162+
ARDUINO_FRMWRK_C2_LIB_DIR = join(platform.get_package_dir("framework-arduinoespressif32-libs"),mcu)
163+
if not os.path.exists(ARDUINO_FRMWRK_C2_LIB_DIR):
164+
ARDUINO_C2_DIR = join(platform.get_package_dir("framework-arduino-c2-skeleton-lib"),mcu)
165+
shutil.copytree(ARDUINO_C2_DIR, ARDUINO_FRMWRK_C2_LIB_DIR, dirs_exist_ok=True)
162166
# Possible package names in 'package@version' format is not compatible with CMake
163167
if "@" in os.path.basename(ARDUINO_FRAMEWORK_DIR):
164168
new_path = os.path.join(
@@ -296,7 +300,7 @@ def HandleCOMPONENTsettings(env):
296300
if flag_custom_component_add == True or flag_custom_component_remove == True: # todo remove duplicated
297301
import yaml
298302
from yaml import SafeLoader
299-
print("*** \"custom_component\" is used to select managed idf components ***")
303+
print("*** \"custom_component\" is used to (de)select managed idf components ***")
300304
if flag_custom_component_remove == True:
301305
idf_custom_component_remove = env.GetProjectOption("custom_component_remove").splitlines()
302306
else:
@@ -365,7 +369,7 @@ def HandleCOMPONENTsettings(env):
365369
if flag_custom_component_add == True or flag_custom_component_remove == True:
366370
HandleCOMPONENTsettings(env)
367371

368-
if flag_custom_sdkonfig == True and "arduino" in env.subst("$PIOFRAMEWORK"):
372+
if flag_custom_sdkonfig == True and "arduino" in env.subst("$PIOFRAMEWORK") and "espidf" not in env.subst("$PIOFRAMEWORK"):
369373
HandleArduinoIDFsettings(env)
370374
LIB_SOURCE = os.path.join(ProjectConfig.get_instance().get("platformio", "platforms_dir"), "espressif32", "builder", "build_lib")
371375
if not bool(os.path.exists(os.path.join(PROJECT_DIR, ".dummy"))):
@@ -2056,7 +2060,7 @@ def _skip_prj_source_files(node):
20562060
# Compile Arduino IDF sources
20572061
#
20582062

2059-
if "arduino" in env.get("PIOFRAMEWORK") and "espidf" not in env.get("PIOFRAMEWORK"):
2063+
if ("arduino" in env.subst("$PIOFRAMEWORK")) and ("espidf" not in env.subst("$PIOFRAMEWORK")):
20602064
def idf_lib_copy(source, target, env):
20612065
env_build = join(env["PROJECT_BUILD_DIR"],env["PIOENV"])
20622066
sdkconfig_h_path = join(env_build,"config","sdkconfig.h")
@@ -2114,7 +2118,7 @@ def idf_lib_copy(source, target, env):
21142118
print("*** Original Arduino \"idf_component.yml\" couldnt be restored ***")
21152119
env.AddPostAction("checkprogsize", idf_lib_copy)
21162120

2117-
if "espidf" in env.get("PIOFRAMEWORK") and (flag_custom_component_add == True or flag_custom_component_remove == True):
2121+
if "espidf" in env.subst("$PIOFRAMEWORK") and (flag_custom_component_add == True or flag_custom_component_remove == True):
21182122
def idf_custom_component(source, target, env):
21192123
try:
21202124
shutil.copy(join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml.orig"),join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml"))

examples/tasmota_platformio_override.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ custom_sdkconfig = https://raw.githubusercontent.com/pioarduino/sdkconfig
3737
'# CONFIG_ETH_PHY_INTERFACE_RMII is not set'
3838
'# CONFIG_ETH_RMII_CLK_INPUT is not set'
3939
'# CONFIG_ETH_RMII_CLK_IN_GPIO is not set'
40-
custom_component_remove = espressif/esp_hosted
41-
espressif/esp_wifi_remote
40+
custom_component_remove =
4241
espressif/esp-dsp
4342
espressif/network_provisioning
4443
espressif/esp-zboss-lib

platform.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"license": "Apache-2.0",
77
"keywords": [
88
"dev-platform",
9-
"Wi-Fi",
9+
"WiFi",
1010
"Bluetooth",
1111
"Xtensa",
1212
"RISC-V"
1313
],
1414
"engines": {
15-
"platformio": ">=6.1.16"
15+
"platformio": ">=6.1.18"
1616
},
1717
"repository": {
1818
"type": "git",

platform.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ def configure_default_packages(self, variables, targets):
6868
core_variant_build = (''.join(variables.get("build_flags", []))).replace("-D", " ")
6969
frameworks = variables.get("pioframework", [])
7070

71-
if variables.get("custom_sdkconfig") is not None:
72-
frameworks.append("espidf")
73-
7471
# Enable debug tool gdb only when build debug is enabled
7572
if (variables.get("build_type") or "debug" in "".join(targets)) and tl_flag:
7673
self.packages["riscv32-esp-elf-gdb"]["optional"] = False if mcu in ["esp32c2", "esp32c3", "esp32c5", "esp32c6", "esp32h2", "esp32p4"] else True

0 commit comments

Comments
 (0)