Skip to content

Commit

Permalink
Hybrid compile: add sdkconfig settings to boards manifest (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Nov 9, 2024
1 parent 950a4cd commit feffc0e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
5 changes: 5 additions & 0 deletions boards/esp32-solo1.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"require_upload_port": true,
"speed": 460800
},
"espidf": {
"custom_sdkconfig": [
"CONFIG_FREERTOS_UNICORE=y"
]
},
"url": "https://en.wikipedia.org/wiki/ESP32",
"vendor": "Espressif"
}
31 changes: 21 additions & 10 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,36 @@ def _get_installed_standard_pip_packages():
#
# generate modified Arduino IDF sdkconfig, applying settings from "custom_sdkconfig"
#
if config.has_option("env:"+env["PIOENV"], "custom_sdkconfig"):
flag_custom_sdkonfig = True

if config.has_option("env:"+env["PIOENV"], "custom_component_add"):
flag_custom_component_add = True

if config.has_option("env:"+env["PIOENV"], "custom_component_remove"):
flag_custom_component_remove = True


if config.has_option("env:"+env["PIOENV"], "custom_sdkconfig"):
flag_custom_sdkonfig = True
if "espidf.custom_sdkconfig" in board:
flag_custom_sdkonfig = True

def HandleArduinoIDFsettings(env):
def get_MD5_hash(phrase):
import hashlib
return hashlib.md5((phrase).encode('utf-8')).hexdigest()[:16]

if flag_custom_sdkonfig == True:
custom_sdk_config_flags = ""
board_idf_config_flags = ""

if config.has_option("env:"+env["PIOENV"], "custom_sdkconfig"):
flag_custom_sdkonfig = True
custom_sdk_config_flags = (env.GetProjectOption("custom_sdkconfig").rstrip("\n")) + "\n"

if "espidf.custom_sdkconfig" in board:
board_idf_config_flags = ('\n'.join([element for element in board.get("espidf.custom_sdkconfig", "")])).rstrip("\n") + "\n"
flag_custom_sdkonfig = True

if flag_custom_sdkonfig == True: # TDOO duplicated
print("*** Add \"custom_sdkconfig\" settings to IDF sdkconfig.defaults ***")
idf_config_flags = env.GetProjectOption("custom_sdkconfig")
idf_config_flags = idf_config_flags + "\n"
idf_config_flags = custom_sdk_config_flags
idf_config_flags = idf_config_flags + board_idf_config_flags
if flash_frequency != "80m":
idf_config_flags = idf_config_flags + "# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set\n"
esptool_flashfreq_y = "CONFIG_ESPTOOLPY_FLASHFREQ_%s=y\n" % flash_frequency.upper()
Expand Down Expand Up @@ -223,7 +234,7 @@ def get_flag(line):
with open(sdkconfig_src) as src:
sdkconfig_dst = os.path.join(PROJECT_DIR, "sdkconfig.defaults")
dst = open(sdkconfig_dst,"w")
dst.write("# TASMOTA__"+ get_MD5_hash(env.GetProjectOption("custom_sdkconfig").strip() + mcu) +"\n")
dst.write("# TASMOTA__"+ get_MD5_hash(''.join(custom_sdk_config_flags).strip() + mcu) +"\n")
while line := src.readline():
flag = get_flag(line)
if flag is None:
Expand Down Expand Up @@ -319,7 +330,7 @@ def HandleCOMPONENTsettings(env):
if flag_custom_component_add == True or flag_custom_component_remove == True:
HandleCOMPONENTsettings(env)

if flag_custom_sdkonfig and "arduino" in env.subst("$PIOFRAMEWORK"):
if flag_custom_sdkonfig == True and "arduino" in env.subst("$PIOFRAMEWORK"):
HandleArduinoIDFsettings(env)
LIB_SOURCE = os.path.join(env.subst("$PROJECT_CORE_DIR"), "platforms", "espressif32", "builder", "build_lib")
if not bool(os.path.exists(os.path.join(PROJECT_DIR, ".dummy"))):
Expand Down
6 changes: 0 additions & 6 deletions examples/arduino-blink/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@ platform = espressif32
framework = arduino
board = esp32-solo1
build_flags = -DLED_BUILTIN=2
custom_sdkconfig = CONFIG_FREERTOS_UNICORE=y
'# CONFIG_BT_ENABLED is not set'
'# CONFIG_ULP_COPROC_ENABLED is not set'
'# CONFIG_LWIP_PPP_SUPPORT is not set'
'# CONFIG_ETH_ENABLED is not set'
custom_component_remove = espressif/esp_hosted
espressif/esp_wifi_remote
espressif/mdns
espressif/esp-dsp
espressif/esp_modem
espressif/esp32-camera

[env:esp32-s3-120]
Expand Down
5 changes: 3 additions & 2 deletions platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,21 @@ def configure_default_packages(self, variables, targets):

board_config = self.board_config(variables.get("board"))
mcu = variables.get("board_build.mcu", board_config.get("build.mcu", "esp32"))
board_sdkconfig = variables.get("board_espidf.custom_sdkconfig", board_config.get("espidf.custom_sdkconfig", ""))
core_variant_board = ''.join(variables.get("board_build.extra_flags", board_config.get("build.extra_flags", "")))
core_variant_board = core_variant_board.replace("-D", " ")
core_variant_build = (''.join(variables.get("build_flags", []))).replace("-D", " ")
frameworks = variables.get("pioframework", [])

if "arduino" in frameworks and variables.get("custom_sdkconfig") is None:
if "arduino" in frameworks and variables.get("custom_sdkconfig") is None and len(str(board_sdkconfig)) < 3:
if "CORE32SOLO1" in core_variant_board or "FRAMEWORK_ARDUINO_SOLO1" in core_variant_build:
self.packages["framework-arduino-solo1"]["optional"] = False
elif "CORE32ITEAD" in core_variant_board or "FRAMEWORK_ARDUINO_ITEAD" in core_variant_build:
self.packages["framework-arduino-ITEAD"]["optional"] = False
else:
self.packages["framework-arduinoespressif32"]["optional"] = False

if variables.get("custom_sdkconfig") is not None:
if variables.get("custom_sdkconfig") is not None or len(str(board_sdkconfig)) > 3:
frameworks.append("espidf")
self.packages["framework-espidf"]["optional"] = False
self.packages["framework-arduinoespressif32"]["optional"] = False
Expand Down

0 comments on commit feffc0e

Please sign in to comment.