Skip to content

Commit bb9b135

Browse files
committed
Properly handle "memory_type" option
1 parent f4119a6 commit bb9b135

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

builder/main.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,37 @@ def BeforeUpload(target, source, env):
4242
env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports))
4343

4444

45+
def _get_board_memory_type(env):
46+
board_config = env.BoardConfig()
47+
default_type = "%s_%s" % (
48+
board_config.get("build.flash_mode", "dio"),
49+
board_config.get("build.psram_type", "qspi"),
50+
)
51+
52+
return board_config.get(
53+
"build.memory_type",
54+
board_config.get(
55+
"build.%s.memory_type"
56+
% env.subst("$PIOFRAMEWORK").strip().replace(" ", "_"),
57+
default_type,
58+
),
59+
)
60+
61+
4562
def _get_board_f_flash(env):
4663
frequency = env.subst("$BOARD_F_FLASH")
4764
frequency = str(frequency).replace("L", "")
4865
return str(int(int(frequency) / 1000000)) + "m"
4966

5067

5168
def _get_board_flash_mode(env):
52-
memory_type = env.BoardConfig().get("build.arduino.memory_type", "qio_qspi")
53-
mode = env.subst("$BOARD_FLASH_MODE")
54-
if memory_type in ("opi_opi", "opi_qspi"):
69+
if ["arduino"] == env.get("PIOFRAMEWORK") and _get_board_memory_type(env) in (
70+
"opi_opi",
71+
"opi_qspi",
72+
):
5573
return "dout"
74+
75+
mode = env.subst("$BOARD_FLASH_MODE")
5676
if mode in ("qio", "qout"):
5777
return "dio"
5878
return mode
@@ -181,6 +201,7 @@ def __fetch_fs_size(target, source, env):
181201
__get_board_boot_mode=_get_board_boot_mode,
182202
__get_board_f_flash=_get_board_f_flash,
183203
__get_board_flash_mode=_get_board_flash_mode,
204+
__get_board_memory_type=_get_board_memory_type,
184205

185206
AR="%s-elf-ar" % toolchain_arch,
186207
AS="%s-elf-as" % toolchain_arch,

0 commit comments

Comments
 (0)