Skip to content

Commit dedfed0

Browse files
committed
Extend debugging options with flash images
1 parent 3688b7b commit dedfed0

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:
@@ -152,3 +154,27 @@ def _add_dynamic_options(self, board):
152154

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

Comments
 (0)