Automatically detect BlackMagic probe GDB port

This commit is contained in:
Ivan Kravets
2017-11-07 00:10:48 +02:00
parent 4504a65b92
commit 5d2867d8a9
2 changed files with 9 additions and 5 deletions

View File

@ -116,20 +116,23 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
]
if any([isfile(p) for p in mbed_pages]):
return item['disk']
if (item['name']
and any([l in item['name'].lower() for l in msdlabels])):
if item['name'] \
and any([l in item['name'].lower() for l in msdlabels]):
return item['disk']
return None
def _look_for_serial_port():
port = None
board_hwids = []
upload_protocol = env.subst("$UPLOAD_PROTOCOL")
if "BOARD" in env and "build.hwids" in env.BoardConfig():
board_hwids = env.BoardConfig().get("build.hwids")
for item in util.get_serialports(filter_hwid=True):
if not _is_match_pattern(item['port']):
continue
port = item['port']
if upload_protocol.startswith("blackmagic") and "GDB" in port:
return port
for hwid in board_hwids:
hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "")
if hwid_str in item['hwid']:
@ -140,7 +143,8 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
print env.subst("Use manually specified: $UPLOAD_PORT")
return
if "mbed" in env.subst("$PIOFRAMEWORK"):
if "mbed" in env.subst("$PIOFRAMEWORK") \
and not env.subst("$UPLOAD_PROTOCOL"):
env.Replace(UPLOAD_PORT=_look_for_mbed_disk())
else:
if (system() == "Linux" and not any([

View File

@ -512,8 +512,8 @@ class PlatformBase( # pylint: disable=too-many-public-methods
config = PlatformBoardConfig(manifest_path)
if "platform" in config and config.get("platform") != self.name:
return
elif ("platforms" in config
and self.name not in config.get("platforms")):
elif "platforms" in config \
and self.name not in config.get("platforms"):
return
config.manifest['platform'] = self.name
self._BOARDS_CACHE[board_id] = config