From 6d2b0a3b6c791082bd77a5c097c37c83ba09d329 Mon Sep 17 00:00:00 2001 From: Yoanndp <13591243+Yoanndp@users.noreply.github.com> Date: Sat, 24 Sep 2022 12:36:11 +0200 Subject: [PATCH 1/2] Update ReadMe.md (#1766) --- ReadMe.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index e848e18a4..c091d7e3f 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -24,7 +24,7 @@ Check out details on [how to build firmware](documentation/fbt.md), [write appli Flipper Zero's firmware consists of two components: -- Core2 firmware set - proprietary components by ST: FUS + radio stack. FUS is flashed at factory and you should never update it. +- Core2 firmware set - proprietary components by ST: FUS + radio stack. FUS is flashed at factory, and you should never update it. - Core1 Firmware - HAL + OS + Drivers + Applications. They both must be flashed in the order described. @@ -52,7 +52,7 @@ Prerequisites: - [arm-gcc-none-eabi](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) - openocd -One liner: `./fbt firmware_flash` +One-liner: `./fbt firmware_flash` ## With USB DFU @@ -128,7 +128,7 @@ Connect your device via ST-Link and run: - `debug` - Debug tool: GDB-plugins, SVD-file and etc - `documentation` - Documentation generation system configs and input files - `firmware` - Firmware source code -- `lib` - Our and 3rd party libraries, drivers and etc... +- `lib` - Our and 3rd party libraries, drivers, etc. - `scripts` - Supplementary scripts and python libraries home -Also pay attention to `ReadMe.md` files inside of those directories. +Also pay attention to `ReadMe.md` files inside those directories. From eadd7801afea681841ea1a2ba28e1e64d819977f Mon Sep 17 00:00:00 2001 From: ghettorce <799240+ghettorce@users.noreply.github.com> Date: Sat, 24 Sep 2022 14:30:19 +0300 Subject: [PATCH 2/2] fbt: exclude user site-packages directory from sys.path (#1778) * fbt: exclude user site-packages directory from sys.path * fbt: python path fixes for *nix * fbt: fixed cli target on Windows Co-authored-by: hedger --- scripts/flipper/utils/cdc.py | 2 +- scripts/serial_cli.py | 14 +++++++++++++- scripts/toolchain/fbtenv.cmd | 1 + scripts/toolchain/fbtenv.sh | 13 +++++++++++++ site_scons/environ.scons | 9 ++++++++- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/scripts/flipper/utils/cdc.py b/scripts/flipper/utils/cdc.py index 081705cc2..7047db2a6 100644 --- a/scripts/flipper/utils/cdc.py +++ b/scripts/flipper/utils/cdc.py @@ -14,4 +14,4 @@ def resolve_port(logger, portname: str = "auto"): logger.error("Failed to find connected Flipper") elif len(flippers) > 1: logger.error("More than one Flipper is attached") - logger.error("Failed to guess which port to use. Specify --port") + logger.error("Failed to guess which port to use") diff --git a/scripts/serial_cli.py b/scripts/serial_cli.py index e07e6bfb4..441bc7cc8 100644 --- a/scripts/serial_cli.py +++ b/scripts/serial_cli.py @@ -1,13 +1,25 @@ import logging import subprocess from flipper.utils.cdc import resolve_port +import os +import sys def main(): logger = logging.getLogger() if not (port := resolve_port(logger, "auto")): + logger.error("Is Flipper connected over USB and isn't in DFU mode?") return 1 - subprocess.call(["python3", "-m", "serial.tools.miniterm", "--raw", port, "230400"]) + subprocess.call( + [ + os.path.basename(sys.executable), + "-m", + "serial.tools.miniterm", + "--raw", + port, + "230400", + ] + ) if __name__ == "__main__": diff --git a/scripts/toolchain/fbtenv.cmd b/scripts/toolchain/fbtenv.cmd index 1403837d9..5eaf16f94 100644 --- a/scripts/toolchain/fbtenv.cmd +++ b/scripts/toolchain/fbtenv.cmd @@ -32,6 +32,7 @@ if not "%REAL_TOOLCHAIN_VERSION%" == "%FLIPPER_TOOLCHAIN_VERSION%" ( set "HOME=%USERPROFILE%" set "PYTHONHOME=%FBT_TOOLCHAIN_ROOT%\python" set "PYTHONPATH=" +set "PYTHONNOUSERSITE=1" set "PATH=%FBT_TOOLCHAIN_ROOT%\python;%FBT_TOOLCHAIN_ROOT%\bin;%FBT_TOOLCHAIN_ROOT%\protoc\bin;%FBT_TOOLCHAIN_ROOT%\openocd\bin;%PATH%" set "PROMPT=(fbt) %PROMPT%" diff --git a/scripts/toolchain/fbtenv.sh b/scripts/toolchain/fbtenv.sh index f68e4c0ba..7c501803f 100755 --- a/scripts/toolchain/fbtenv.sh +++ b/scripts/toolchain/fbtenv.sh @@ -40,6 +40,13 @@ fbtenv_restore_env() elif [ -n "${PROMPT:-""}" ]; then PROMPT="$(echo "$PROMPT" | sed 's/\[fbt\]//g')"; fi + + PYTHONNOUSERSITE="$SAVED_PYTHONNOUSERSITE"; + PYTHONPATH="$SAVED_PYTHONPATH"; + + unset SAVED_PYTHONNOUSERSITE; + unset SAVED_PYTHONPATH; + unset SCRIPT_PATH; unset FBT_TOOLCHAIN_VERSION; unset FBT_TOOLCHAIN_PATH; @@ -276,6 +283,12 @@ fbtenv_main() PATH="$TOOLCHAIN_ARCH_DIR/bin:$PATH"; PATH="$TOOLCHAIN_ARCH_DIR/protobuf/bin:$PATH"; PATH="$TOOLCHAIN_ARCH_DIR/openocd/bin:$PATH"; + + SAVED_PYTHONNOUSERSITE="${PYTHONNOUSERSITE:-""}"; + SAVED_PYTHONPATH="${PYTHONPATH:-""}"; + + PYTHONNOUSERSITE=1; + PYTHONPATH=; } fbtenv_main "${1:-""}"; diff --git a/site_scons/environ.scons b/site_scons/environ.scons index 99d4cc0b5..c61f29616 100644 --- a/site_scons/environ.scons +++ b/site_scons/environ.scons @@ -12,7 +12,14 @@ forward_os_env = { "PATH": os.environ["PATH"], } # Proxying CI environment to child processes & scripts -for env_value_name in ("WORKFLOW_BRANCH_OR_TAG", "DIST_SUFFIX", "HOME", "APPDATA"): +for env_value_name in ( + "WORKFLOW_BRANCH_OR_TAG", + "DIST_SUFFIX", + "HOME", + "APPDATA", + "PYTHONHOME", + "PYTHONNOUSERSITE", +): if environ_value := os.environ.get(env_value_name, None): forward_os_env[env_value_name] = environ_value