[FL-3346] fbt: added Flipper selection when multiple are connected over USB (#2723)

* fbt: added Flipper selection when multiple are connected over USB
* scripts: serial_cli: added --port (-p) option
This commit is contained in:
hedger 2023-06-08 08:47:27 +04:00 committed by GitHub
parent 09fae620d9
commit 436194e6c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 9 deletions

View File

@ -171,7 +171,7 @@ distenv.Depends(firmware_env["FW_RESOURCES"], external_apps_artifacts.resources_
fap_deploy = distenv.PhonyTarget(
"fap_deploy",
"${PYTHON3} ${ROOT_DIR}/scripts/storage.py send ${SOURCE} /ext/apps",
"${PYTHON3} ${FBT_SCRIPT_DIR}/storage.py -p ${FLIP_PORT} send ${SOURCE} /ext/apps",
source=Dir("#/assets/resources/apps"),
)
@ -323,7 +323,9 @@ distenv.PhonyTarget(
)
# Start Flipper CLI via PySerial's miniterm
distenv.PhonyTarget("cli", "${PYTHON3} ${FBT_SCRIPT_DIR}/serial_cli.py")
distenv.PhonyTarget(
"cli", "${PYTHON3} ${FBT_SCRIPT_DIR}/serial_cli.py -p ${FLIP_PORT}"
)
# Find blackmagic probe

View File

@ -132,7 +132,7 @@ def generate(env):
"UsbInstall": Builder(
action=[
Action(
'${PYTHON3} "${SELFUPDATE_SCRIPT}" ${UPDATE_BUNDLE_DIR}/update.fuf'
'${PYTHON3} "${SELFUPDATE_SCRIPT}" -p ${FLIP_PORT} ${UPDATE_BUNDLE_DIR}/update.fuf'
),
Touch("${TARGET}"),
]

View File

@ -431,7 +431,7 @@ def AddAppLaunchTarget(env, appname, launch_target_name):
# print(deploy_sources, flipp_dist_paths)
env.PhonyTarget(
launch_target_name,
'${PYTHON3} "${APP_RUN_SCRIPT}" ${EXTRA_ARGS} -s ${SOURCES} -t ${FLIPPER_FILE_TARGETS}',
'${PYTHON3} "${APP_RUN_SCRIPT}" -p ${FLIP_PORT} ${EXTRA_ARGS} -s ${SOURCES} -t ${FLIPPER_FILE_TARGETS}',
source=deploy_sources,
FLIPPER_FILE_TARGETS=flipp_dist_paths,
EXTRA_ARGS=run_script_extra_ars,
@ -443,7 +443,6 @@ def generate(env, **kw):
env.SetDefault(
EXT_APPS_WORK_DIR="${FBT_FAP_DEBUG_ELF_ROOT}",
APP_RUN_SCRIPT="${FBT_SCRIPT_DIR}/runfap.py",
STORAGE_SCRIPT="${FBT_SCRIPT_DIR}/storage.py",
)
if not env["VERBOSE"]:
env.SetDefault(

View File

@ -6,7 +6,7 @@ def resolve_port(logger, portname: str = "auto"):
if portname != "auto":
return portname
# Try guessing
flippers = list(list_ports.grep("flip"))
flippers = list(list_ports.grep("flip_"))
if len(flippers) == 1:
flipper = flippers[0]
logger.info(f"Using {flipper.serial_number} on {flipper.device}")

View File

@ -1,3 +1,4 @@
import argparse
import logging
import os
import subprocess
@ -8,7 +9,10 @@ from flipper.utils.cdc import resolve_port
def main():
logger = logging.getLogger()
if not (port := resolve_port(logger, "auto")):
parser = argparse.ArgumentParser()
parser.add_argument("-p", "--port", help="CDC Port", default="auto")
args = parser.parse_args()
if not (port := resolve_port(logger, args.port)):
logger.error("Is Flipper connected via USB and not in DFU mode?")
return 1
subprocess.call(

View File

@ -342,7 +342,7 @@ else:
appenv.PhonyTarget(
"cli",
'${PYTHON3} "${FBT_SCRIPT_DIR}/serial_cli.py"',
'${PYTHON3} "${FBT_SCRIPT_DIR}/serial_cli.py" -p ${FLIP_PORT}',
)
# Linter
@ -469,7 +469,7 @@ if dolphin_src_dir.exists():
)
dist_env.PhonyTarget(
"dolphin_ext",
'${PYTHON3} ${FBT_SCRIPT_DIR}/storage.py send "${SOURCE}" /ext/dolphin',
'${PYTHON3} ${FBT_SCRIPT_DIR}/storage.py -p ${FLIP_PORT} send "${SOURCE}" /ext/dolphin',
source=ufbt_build_dir.Dir("dolphin"),
)
else:

View File

@ -71,6 +71,11 @@ vars.AddVariables(
validator=PathVariable.PathIsDir,
default="",
),
(
"FLIP_PORT",
"CDC Port of Flipper to use, if multiple are connected",
"auto",
),
)
Return("vars")

View File

@ -243,6 +243,11 @@ vars.AddVariables(
" app can check what version it is being built for.",
"Official",
),
(
"FLIP_PORT",
"Full port name of Flipper to use, if multiple Flippers are connected",
"auto",
),
)
Return("vars")