From d10bbbe7dcaab73aa7d7089d16f6d1dd58dc12db Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 26 Oct 2020 18:44:10 +0200 Subject: [PATCH] Extend debugging options with flash images --- platform.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/platform.py b/platform.py index 13af013..eb5e8fe 100644 --- a/platform.py +++ b/platform.py @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os.path import isdir +import copy +import os +from platformio import fs from platformio.managers.platform import PlatformBase from platformio.util import get_systype @@ -32,7 +34,7 @@ class Espressif32Platform(PlatformBase): self.packages['tool-mkspiffs']['optional'] = False if variables.get("upload_protocol"): self.packages['tool-openocd-esp32']['optional'] = False - if isdir("ulp"): + if os.path.isdir("ulp"): self.packages['toolchain-esp32ulp']['optional'] = False if "espidf" in frameworks: for p in self.packages: @@ -153,3 +155,27 @@ class Espressif32Platform(PlatformBase): board.manifest['debug'] = debug return board + + def configure_debug_options(self, initial_debug_options, ide_data): + flash_images = ide_data.get("extra", {}).get("flash_images") + ignore_conds = [ + initial_debug_options["load_cmds"] != ["load"], + not flash_images, + not all([os.path.isfile(item["path"]) for item in flash_images]), + ] + if any(ignore_conds): + return initial_debug_options + + debug_options = copy.deepcopy(initial_debug_options) + load_cmds = [ + 'monitor program_esp32 "{{{path}}}" {offset} verify'.format( + path=fs.to_unix_path(item["path"]), offset=item["offset"] + ) + for item in flash_images + ] + load_cmds.append( + 'monitor program_esp32 "{%s.bin}" 0x10000 verify' + % fs.to_unix_path(ide_data["prog_path"][:-4]) + ) + debug_options["load_cmds"] = load_cmds + return debug_options