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 :
@@ -153,3 +155,27 @@ def _add_dynamic_options(self, board):
153
155
154
156
board .manifest ['debug' ] = debug
155
157
return board
158
+
159
+ def configure_debug_options (self , initial_debug_options , ide_data ):
160
+ flash_images = ide_data .get ("extra" , {}).get ("flash_images" )
161
+ ignore_conds = [
162
+ initial_debug_options ["load_cmds" ] != ["load" ],
163
+ not flash_images ,
164
+ not all ([os .path .isfile (item ["path" ]) for item in flash_images ]),
165
+ ]
166
+ if any (ignore_conds ):
167
+ return initial_debug_options
168
+
169
+ debug_options = copy .deepcopy (initial_debug_options )
170
+ load_cmds = [
171
+ 'monitor program_esp32 "{{{path}}}" {offset} verify' .format (
172
+ path = fs .to_unix_path (item ["path" ]), offset = item ["offset" ]
173
+ )
174
+ for item in flash_images
175
+ ]
176
+ load_cmds .append (
177
+ 'monitor program_esp32 "{%s.bin}" 0x10000 verify'
178
+ % fs .to_unix_path (ide_data ["prog_path" ][:- 4 ])
179
+ )
180
+ debug_options ["load_cmds" ] = load_cmds
181
+ return debug_options
0 commit comments