@@ -161,7 +161,43 @@ def _add_dynamic_options(self, board):
161
161
board .manifest ["debug" ] = debug
162
162
return board
163
163
164
+ def configure_debug_session (self , debug_config ):
165
+ build_extra_data = debug_config .build_data .get ("extra" , {})
166
+ flash_images = build_extra_data .get ("flash_images" , [])
167
+
168
+ if "openocd" in (debug_config .server or {}).get ("executable" , "" ):
169
+ debug_config .server ["arguments" ].extend (
170
+ ["-c" , "adapter_khz %s" % (debug_config .speed or "5000" )]
171
+ )
172
+
173
+ ignore_conds = [
174
+ debug_config .load_cmds != ["load" ],
175
+ not flash_images ,
176
+ not all ([os .path .isfile (item ["path" ]) for item in flash_images ]),
177
+ ]
178
+
179
+ if any (ignore_conds ):
180
+ return
181
+
182
+ load_cmds = [
183
+ 'monitor program_esp "{{{path}}}" {offset} verify' .format (
184
+ path = fs .to_unix_path (item ["path" ]), offset = item ["offset" ]
185
+ )
186
+ for item in flash_images
187
+ ]
188
+ load_cmds .append (
189
+ 'monitor program_esp "{%s.bin}" %s verify'
190
+ % (
191
+ fs .to_unix_path (debug_config .build_data ["prog_path" ][:- 4 ]),
192
+ build_extra_data .get ("application_offset" , "0x10000" ),
193
+ )
194
+ )
195
+ debug_config .load_cmds = load_cmds
196
+
164
197
def configure_debug_options (self , initial_debug_options , ide_data ):
198
+ """
199
+ Deprecated. Remove method when PlatformIO Core 5.2 is released
200
+ """
165
201
ide_extra_data = ide_data .get ("extra" , {})
166
202
flash_images = ide_extra_data .get ("flash_images" , [])
167
203
debug_options = copy .deepcopy (initial_debug_options )
0 commit comments