Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/fbt_tools/fbt_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"),
]
Expand Down
3 changes: 1 addition & 2 deletions scripts/fbt_tools/fbt_extapps.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def _add_host_app_to_targets(host_app):
# 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,
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion scripts/flipper/utils/cdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
6 changes: 5 additions & 1 deletion scripts/serial_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argparse
import logging
import os
import subprocess
Expand All @@ -8,7 +9,10 @@

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(
Expand Down
4 changes: 2 additions & 2 deletions scripts/ufbt/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions scripts/ufbt/commandline.scons
Original file line number Diff line number Diff line change
Expand Up @@ -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")
5 changes: 5 additions & 0 deletions site_scons/commandline.scons
Original file line number Diff line number Diff line change
Expand Up @@ -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")