Extend debugging options with flash images

This commit is contained in:
Ivan Kravets
2020-10-26 18:44:10 +02:00
parent f5ffb5896c
commit d10bbbe7dc
+28 -2
View File
@@ -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