Skip to content

Commit b375928

Browse files
authored
HybridCompile: Implement flash mode handling in espidf.py
Add flash mode configuration to sdkconfig and disable other modes.
1 parent d3b0275 commit b375928

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

builder/frameworks/espidf.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
flash_speed = board.get("build.f_flash", "40000000L")
8181
flash_frequency = str(flash_speed.replace("000000L", ""))
8282
flash_mode = board.get("build.flash_mode", "dio")
83+
boot_mode = board.get("build.boot", None)
8384
idf_variant = mcu.lower()
8485
flag_custom_sdkonfig = False
8586
flag_custom_component_add = False
@@ -337,9 +338,16 @@ def generate_board_specific_config():
337338
else:
338339
flash_memory_type = memory_type
339340

340-
# Check for additional flash configuration indicators
341-
boot_mode = board.get("build", {}).get("boot", None)
342-
flash_mode = board.get("build", {}).get("flash_mode", None)
341+
# Add flash mode to sdkconfig
342+
if flash_mode:
343+
flash_mode_lower = flash_mode.lower()
344+
board_config_flags.append(f"CONFIG_ESPTOOLPY_FLASHMODE_{flash_mode.upper()}=y")
345+
346+
# Disable other flash mode options
347+
flash_modes = ["qio", "qout", "dio", "dout"]
348+
for mode in flash_modes:
349+
if mode != flash_mode_lower:
350+
board_config_flags.append(f"# CONFIG_ESPTOOLPY_FLASHMODE_{mode.upper()} is not set")
343351

344352
# Override flash_memory_type if boot mode indicates OPI
345353
if boot_mode == "opi" or flash_mode in ["dout", "opi"]:

0 commit comments

Comments
 (0)