Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Astrrra committed Jul 1, 2022
2 parents 0e225d4 + b3767d1 commit d2d494c
Show file tree
Hide file tree
Showing 25 changed files with 461 additions and 200 deletions.
8 changes: 7 additions & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ They both must be flashed in order described.

## With offline update package

With Flipper attached over USB:

`./fbt --with-updater flash_usb`

Just building the package:

`./fbt --with-updater updater_package`

Copy the resulting directory to Flipper's SD card and navigate to `update.fuf` file in Archive app.
To update, copy the resulting directory to Flipper's SD card and navigate to `update.fuf` file in Archive app.

## With STLink

Expand Down
89 changes: 37 additions & 52 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ fbt_variables = SConscript("site_scons/commandline.scons")
cmd_environment = Environment(tools=[], variables=fbt_variables)
Help(fbt_variables.GenerateHelpText(cmd_environment))


# Building basic environment - tools, utility methods, cross-compilation
# settings, gcc flags for Cortex-M4, basic builders and more
coreenv = SConscript(
Expand All @@ -43,7 +42,6 @@ firmware_out = distenv.AddFwProject(
fw_env_key="FW_ENV",
)


# If enabled, initialize updater-related targets
if GetOption("fullenv"):
updater_out = distenv.AddFwProject(
Expand Down Expand Up @@ -71,80 +69,67 @@ if GetOption("fullenv"):
"--splash",
distenv.subst("assets/slideshow/$UPDATE_SPLASH"),
]
selfupdate_dist = distenv.DistBuilder(
"selfupdate.pseudo",

selfupdate_dist = distenv.DistCommand(
"updater_package",
(distenv["DIST_DEPENDS"], firmware_out["FW_RESOURCES"]),
DIST_EXTRA=dist_arguments,
)
distenv.Pseudo("selfupdate.pseudo")
AlwaysBuild(selfupdate_dist)
Alias("updater_package", selfupdate_dist)

# Updater debug
debug_updater_elf = distenv.AddDebugTarget(updater_out, False)
Alias("updater_debug", debug_updater_elf)

distenv.AddDebugTarget("updater_debug", updater_out, False)

# Installation over USB & CLI
usb_update_package = distenv.UsbInstall(
"#build/usbinstall.flag",
(
distenv["DIST_DEPENDS"],
firmware_out["FW_RESOURCES"],
selfupdate_dist,
),
)
if distenv["FORCE"]:
distenv.AlwaysBuild(usb_update_package)
distenv.Depends(usb_update_package, selfupdate_dist)
distenv.Alias("flash_usb", usb_update_package)

# Target for copying & renaming binaries to dist folder
basic_dist = distenv.DistBuilder("dist.pseudo", distenv["DIST_DEPENDS"])
distenv.Pseudo("dist.pseudo")
AlwaysBuild(basic_dist)
Alias("fw_dist", basic_dist)
Default(basic_dist)
basic_dist = distenv.DistCommand("fw_dist", distenv["DIST_DEPENDS"])
distenv.Default(basic_dist)

# Target for bundling core2 package for qFlipper
copro_dist = distenv.CoproBuilder(
Dir("assets/core2_firmware"),
distenv.Dir("assets/core2_firmware"),
[],
)
AlwaysBuild(copro_dist)
Alias("copro_dist", copro_dist)

distenv.Alias("copro_dist", copro_dist)

# Debugging firmware

debug_fw_elf = distenv.AddDebugTarget(firmware_out)
Alias("debug", debug_fw_elf)


distenv.AddDebugTarget("debug", firmware_out)
# Debug alien elf
debug_other = distenv.GDBPy(
"debugother.pseudo",
None,
distenv.PhonyTarget(
"debug_other",
"$GDBPYCOM",
GDBPYOPTS=
# '-ex "source ${ROOT_DIR.abspath}/debug/FreeRTOS/FreeRTOS.py" '
'-ex "source debug/PyCortexMDebug/PyCortexMDebug.py" '
'-ex "source debug/PyCortexMDebug/PyCortexMDebug.py" ',
)
distenv.Pseudo("debugother.pseudo")
AlwaysBuild(debug_other)
Alias("debug_other", debug_other)


# Just start OpenOCD
openocd = distenv.OOCDCommand("openocd.pseudo", [])
distenv.Pseudo("openocd.pseudo")
AlwaysBuild(openocd)
Alias("openocd", openocd)

distenv.PhonyTarget(
"openocd",
"${OPENOCDCOM}",
)

# Linter
lint_check = distenv.Command(
"lint.check.pseudo",
[],
"${PYTHON3} scripts/lint.py check $LINT_SOURCES",
distenv.PhonyTarget(
"lint",
"${PYTHON3} scripts/lint.py check ${LINT_SOURCES}",
LINT_SOURCES=firmware_out["LINT_SOURCES"],
)
distenv.Pseudo("lint.check.pseudo")
AlwaysBuild(lint_check)
Alias("lint", lint_check)


lint_format = distenv.Command(
"lint.format.pseudo",
[],
"${PYTHON3} scripts/lint.py format $LINT_SOURCES",
distenv.PhonyTarget(
"format",
"${PYTHON3} scripts/lint.py format ${LINT_SOURCES}",
LINT_SOURCES=firmware_out["LINT_SOURCES"],
)
distenv.Pseudo("lint.format.pseudo")
AlwaysBuild(lint_format)
Alias("format", lint_format)
3 changes: 2 additions & 1 deletion applications/cli/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ void cli_reset(Cli* cli) {
}

static void cli_handle_backspace(Cli* cli) {
if(string_size(cli->line) > 0) {
if(cli->cursor_position > 0) {
furi_assert(string_size(cli->line) > 0);
// Other side
printf("\e[D\e[1P");
fflush(stdout);
Expand Down
1 change: 1 addition & 0 deletions applications/infrared/infrared_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static bool infrared_cli_parse_message(const char* str, InfraredSignal* signal)
return false;
}

message.protocol = infrared_get_protocol_by_name(protocol_name);
message.repeat = false;
infrared_signal_set_message(signal, &message);
return infrared_signal_is_valid(signal);
Expand Down
48 changes: 24 additions & 24 deletions assets/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,47 @@ icons_src = assetsenv.GlobRecursive("*.png", "icons")
icons_src += assetsenv.GlobRecursive("frame_rate", "icons")

icons = assetsenv.IconBuilder(Dir("compiled"), Dir("#/assets/icons"))
Depends(icons, icons_src)
Alias("icons", icons)
assetsenv.Depends(icons, icons_src)
assetsenv.Alias("icons", icons)


# Protobuf .proto -> .c + .h

proto_src = Glob("protobuf/*.proto", source=True)
proto_options = Glob("protobuf/*.options", source=True)
proto = assetsenv.ProtoBuilder(Dir("compiled"), proto_src)
Depends(proto, proto_options)
proto_src = assetsenv.Glob("protobuf/*.proto", source=True)
proto_options = assetsenv.Glob("protobuf/*.options", source=True)
proto = assetsenv.ProtoBuilder(assetsenv.Dir("compiled"), proto_src)
assetsenv.Depends(proto, proto_options)
# Precious(proto)
Alias("proto", proto)
assetsenv.Alias("proto", proto)


# Internal animations

dolphin_internal = assetsenv.DolphinSymBuilder(
Dir("compiled"),
Dir("#/assets/dolphin"),
assetsenv.Dir("compiled"),
assetsenv.Dir("#/assets/dolphin"),
DOLPHIN_RES_TYPE="internal",
)
Alias("dolphin_internal", dolphin_internal)
assetsenv.Alias("dolphin_internal", dolphin_internal)


# Blocking animations

dolphin_blocking = assetsenv.DolphinSymBuilder(
Dir("compiled"),
Dir("#/assets/dolphin"),
assetsenv.Dir("compiled"),
assetsenv.Dir("#/assets/dolphin"),
DOLPHIN_RES_TYPE="blocking",
)
Alias("dolphin_blocking", dolphin_blocking)
assetsenv.Alias("dolphin_blocking", dolphin_blocking)


# Protobuf version meta
proto_ver = assetsenv.ProtoVerBuilder(
"compiled/protobuf_version.h",
"#/assets/protobuf/Changelog",
)
Depends(proto_ver, proto)
Alias("proto_ver", proto_ver)
assetsenv.Depends(proto_ver, proto)
assetsenv.Alias("proto_ver", proto_ver)

# Gather everything into a static lib
assets_parts = (icons, proto, dolphin_blocking, dolphin_internal, proto_ver)
Expand All @@ -82,14 +82,14 @@ assetsenv.Install("${LIB_DIST_DIR}", assetslib)
if assetsenv["IS_BASE_FIRMWARE"]:
# External dolphin animations
dolphin_external = assetsenv.DolphinExtBuilder(
Dir("#/assets/resources/dolphin"),
Dir("#/assets/dolphin"),
assetsenv.Dir("#/assets/resources/dolphin"),
assetsenv.Dir("#/assets/dolphin"),
DOLPHIN_RES_TYPE="external",
)
NoClean(dolphin_external)
assetsenv.NoClean(dolphin_external)
if assetsenv["FORCE"]:
AlwaysBuild(dolphin_external)
Alias("dolphin_ext", dolphin_external)
assetsenv.AlwaysBuild(dolphin_external)
assetsenv.Alias("dolphin_ext", dolphin_external)

# Resources manifest

Expand All @@ -101,13 +101,13 @@ if assetsenv["IS_BASE_FIRMWARE"]:
"${RESMANIFESTCOMSTR}",
),
)
Precious(resources)
NoClean(resources)
assetsenv.Precious(resources)
assetsenv.NoClean(resources)
if assetsenv["FORCE"]:
AlwaysBuild(resources)
assetsenv.AlwaysBuild(resources)

# Exporting resources node to external environment
env["FW_RESOURCES"] = resources
Alias("resources", resources)
assetsenv.Alias("resources", resources)

Return("assetslib")
15 changes: 9 additions & 6 deletions documentation/fbt.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Flipper Build Tool

FBT is the entry point for most firmware-related commands and utilities.
FBT is the entry point for firmware-related commands and utilities.
It is invoked by `./fbt` in firmware project root directory. Internally, it is a wrapper around [scons](https://scons.org/) build system.

## Requirements

Please install Python packages required by assets build scripts: `pip3 install -r scripts/requirements.txt`
Make sure that `gcc-arm-none-eabi` toolchain & OpenOCD executables are in system's PATH.

## NB

Expand All @@ -17,20 +18,22 @@ To build with FBT, call it specifying configuration options & targets to build.

`./fbt --with-updater COMPACT=1 DEBUG=0 VERBOSE=1 updater_package copro_dist`

To run cleanup (think of `make clean`) for specified targets, all `-c` option.
To run cleanup (think of `make clean`) for specified targets, add `-c` option.

## FBT targets

FBT keeps track of internal dependencies, so you only need to build the highest-level target you need, and FBT will make sure everything it needs is up-to-date.
FBT keeps track of internal dependencies, so you only need to build the highest-level target you need, and FBT will make sure everything they depend on is up-to-date.

### High-level (what you most likely need)

- `fw_dist` - build & publish firmware to `dist` folder
- `fw_dist` - build & publish firmware to `dist` folder. This is a default target, when no other are specified
- `updater_package` - build self-update package. _Requires `--with-updater` option_
- `copro_dist` - bundle Core2 FUS+stack binaries for qFlipper
- `flash` - flash attached device with OpenOCD over ST-Link
- `flash_usb` - build, upload and install update package to device over USB. _Requires `--with-updater` option_
- `debug` - build and flash firmware, then attach with gdb with firmware's .elf loaded
- `debug_updater` - attach gdb with updater's .elf loaded. _Requires `--with-updater` option_
- `debug_other` - attach gdb without loading built elf. Allows to manually add external elf files with `add-symbol-file` in gdb.
- `debug_other` - attach gdb without loading any .elf. Allows to manually add external elf files with `add-symbol-file` in gdb.
- `openocd` - just start OpenOCD

### Firmware targets
Expand All @@ -39,7 +42,7 @@ FBT keeps track of internal dependencies, so you only need to build the highest-
- `firmware_snake_game`, etc - build single plug-in as .elf by its name
- Check out `--extra-ext-apps` for force adding extra apps to external build
- `firmware_snake_game_list`, etc - generate source + assembler listing for app's .elf
- `firmware_flash` - flash current version to attached device with OpenOCD
- `flash`, `firmware_flash` - flash current version to attached device with OpenOCD over ST-Link
- `firmware_cdb` - generate compilation database
- `firmware_all`, `updater_all` - build basic set of binaries
- `firmware_list`, `updater_list` - generate source + assembler listing
Expand Down
14 changes: 10 additions & 4 deletions fbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

set -e

SCRIPTDIR="$( dirname -- "$0"; )";
SCONS_EP=${SCRIPTDIR}/lib/scons/scripts/scons.py

if [[ -d .git ]]; then
echo "Updating git submodules"
git submodule update --init
echo Updating git submodules
git submodule update --init
else # Not in a git repo
echo Not in a git repo, please clone with git clone --recursive
# Return error code 1 to indicate failure
exit 1
fi

SCRIPTDIR="$( dirname -- "$0"; )";
SCONS_DEFAULT_FLAGS="-Q --warn=target-not-built"
python3 ${SCRIPTDIR}/lib/scons/scripts/scons.py ${SCONS_DEFAULT_FLAGS} "$@"
python3 ${SCONS_EP} ${SCONS_DEFAULT_FLAGS} "$@"
9 changes: 6 additions & 3 deletions fbt.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
@echo off

set SCONS_EP=%~dp0\lib\scons\scripts\scons.py

if exist ".git" (
echo Prepairing git submodules
git submodule update --init
echo Updating git submodules
git submodule update --init
)

set "SCONS_DEFAULT_FLAGS=-Q --warn=target-not-built"
python lib/scons/scripts/scons.py %SCONS_DEFAULT_FLAGS% %*
python %SCONS_EP% %SCONS_DEFAULT_FLAGS% %*
8 changes: 4 additions & 4 deletions fbt_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
SVD_FILE = "debug/STM32WB55_CM4.svd"

FIRMWARE_APPS = {
"default": (
"default": [
"crypto_start",
# Svc
"basic_services",
Expand All @@ -62,11 +62,11 @@
"basic_plugins",
# Debug
"debug_apps",
),
"unit_tests": (
],
"unit_tests": [
"basic_services",
"unit_tests",
),
],
}

FIRMWARE_APP_SET = "default"
Loading

0 comments on commit d2d494c

Please sign in to comment.