Skip to content

Commit d10bbbe

Browse files
committed
Extend debugging options with flash images
1 parent f5ffb58 commit d10bbbe

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

platform.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from os.path import isdir
15+
import copy
16+
import os
1617

18+
from platformio import fs
1719
from platformio.managers.platform import PlatformBase
1820
from platformio.util import get_systype
1921

@@ -32,7 +34,7 @@ def configure_default_packages(self, variables, targets):
3234
self.packages['tool-mkspiffs']['optional'] = False
3335
if variables.get("upload_protocol"):
3436
self.packages['tool-openocd-esp32']['optional'] = False
35-
if isdir("ulp"):
37+
if os.path.isdir("ulp"):
3638
self.packages['toolchain-esp32ulp']['optional'] = False
3739
if "espidf" in frameworks:
3840
for p in self.packages:
@@ -153,3 +155,27 @@ def _add_dynamic_options(self, board):
153155

154156
board.manifest['debug'] = debug
155157
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

Comments
 (0)