12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
- from os .path import isdir
15
+ import copy
16
+ import os
16
17
18
+ from platformio import fs
17
19
from platformio .managers .platform import PlatformBase
18
20
from platformio .util import get_systype
19
21
@@ -32,7 +34,7 @@ def configure_default_packages(self, variables, targets):
32
34
self .packages ['tool-mkspiffs' ]['optional' ] = False
33
35
if variables .get ("upload_protocol" ):
34
36
self .packages ['tool-openocd-esp32' ]['optional' ] = False
35
- if isdir ("ulp" ):
37
+ if os . path . isdir ("ulp" ):
36
38
self .packages ['toolchain-esp32ulp' ]['optional' ] = False
37
39
if "espidf" in frameworks :
38
40
for p in self .packages :
@@ -152,3 +154,27 @@ def _add_dynamic_options(self, board):
152
154
153
155
board .manifest ['debug' ] = debug
154
156
return board
157
+
158
+ def configure_debug_options (self , initial_debug_options , ide_data ):
159
+ flash_images = ide_data .get ("extra" , {}).get ("flash_images" )
160
+ ignore_conds = [
161
+ initial_debug_options ["load_cmds" ] != ["load" ],
162
+ not flash_images ,
163
+ not all ([os .path .isfile (item ["path" ]) for item in flash_images ]),
164
+ ]
165
+ if any (ignore_conds ):
166
+ return initial_debug_options
167
+
168
+ debug_options = copy .deepcopy (initial_debug_options )
169
+ load_cmds = [
170
+ 'monitor program_esp32 "{{{path}}}" {offset} verify' .format (
171
+ path = fs .to_unix_path (item ["path" ]), offset = item ["offset" ]
172
+ )
173
+ for item in flash_images
174
+ ]
175
+ load_cmds .append (
176
+ 'monitor program_esp32 "{%s.bin}" 0x10000 verify'
177
+ % fs .to_unix_path (ide_data ["prog_path" ][:- 4 ])
178
+ )
179
+ debug_options ["load_cmds" ] = load_cmds
180
+ return debug_options
0 commit comments