Skip to content

Commit b07c738

Browse files
authored
Fix Arduino as an component of IDF compile for the C2
1 parent d47f924 commit b07c738

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-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"))):
@@ -2092,7 +2096,7 @@ def _skip_prj_source_files(node):
20922096
# Compile Arduino IDF sources
20932097
#
20942098

2095-
if "arduino" in env.get("PIOFRAMEWORK") and "espidf" not in env.get("PIOFRAMEWORK"):
2099+
if ("arduino" in env.subst("$PIOFRAMEWORK")) and ("espidf" not in env.subst("$PIOFRAMEWORK")):
20962100
def idf_lib_copy(source, target, env):
20972101
env_build = join(env["PROJECT_BUILD_DIR"],env["PIOENV"])
20982102
sdkconfig_h_path = join(env_build,"config","sdkconfig.h")
@@ -2150,7 +2154,7 @@ def idf_lib_copy(source, target, env):
21502154
print("*** Original Arduino \"idf_component.yml\" couldnt be restored ***")
21512155
env.AddPostAction("checkprogsize", idf_lib_copy)
21522156

2153-
if "espidf" in env.get("PIOFRAMEWORK") and (flag_custom_component_add == True or flag_custom_component_remove == True):
2157+
if "espidf" in env.subst("$PIOFRAMEWORK") and (flag_custom_component_add == True or flag_custom_component_remove == True):
21542158
def idf_custom_component(source, target, env):
21552159
try:
21562160
shutil.copy(join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml.orig"),join(ARDUINO_FRAMEWORK_DIR,"idf_component.yml"))

examples/espidf-arduino-littlefs/platformio.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
[env]
1212
platform = espressif32
1313
framework = arduino, espidf
14+
board_build.filesystem = littlefs
15+
board_build.partitions = partitions_custom.csv
1416
monitor_speed = 115200
17+
18+
[env:esp32dev]
19+
board = esp32dev
1520
board_build.embed_txtfiles =
1621
managed_components/espressif__esp_insights/server_certs/https_server.crt
1722
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
1823
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
1924
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
20-
21-
[env:esp32dev]
22-
board = esp32dev
23-
board_build.filesystem = littlefs
24-
board_build.partitions = partitions_custom.csv

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

0 commit comments

Comments
 (0)