@@ -42,17 +42,37 @@ def BeforeUpload(target, source, env):
42
42
env .Replace (UPLOAD_PORT = env .WaitForNewSerialPort (before_ports ))
43
43
44
44
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
+
45
62
def _get_board_f_flash (env ):
46
63
frequency = env .subst ("$BOARD_F_FLASH" )
47
64
frequency = str (frequency ).replace ("L" , "" )
48
65
return str (int (int (frequency ) / 1000000 )) + "m"
49
66
50
67
51
68
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
+ ):
55
73
return "dout"
74
+
75
+ mode = env .subst ("$BOARD_FLASH_MODE" )
56
76
if mode in ("qio" , "qout" ):
57
77
return "dio"
58
78
return mode
@@ -181,6 +201,7 @@ def __fetch_fs_size(target, source, env):
181
201
__get_board_boot_mode = _get_board_boot_mode ,
182
202
__get_board_f_flash = _get_board_f_flash ,
183
203
__get_board_flash_mode = _get_board_flash_mode ,
204
+ __get_board_memory_type = _get_board_memory_type ,
184
205
185
206
AR = "%s-elf-ar" % toolchain_arch ,
186
207
AS = "%s-elf-as" % toolchain_arch ,
0 commit comments