2022-06-26 12:00:03 +00:00
|
|
|
Import("ENV", "fw_build_meta")
|
|
|
|
|
2022-10-06 13:55:57 +00:00
|
|
|
from SCons.Errors import UserError
|
2022-11-02 15:15:40 +00:00
|
|
|
from SCons.Node import FS
|
2022-09-14 16:11:38 +00:00
|
|
|
import itertools
|
2022-06-26 12:00:03 +00:00
|
|
|
|
2022-10-12 16:12:05 +00:00
|
|
|
from fbt_extra.util import (
|
2022-07-05 12:24:59 +00:00
|
|
|
should_gen_cdb_and_link_dir,
|
|
|
|
link_elf_dir_as_latest,
|
|
|
|
)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
# Building initial C environment for libs
|
|
|
|
env = ENV.Clone(
|
2022-08-02 13:46:43 +00:00
|
|
|
tools=[
|
|
|
|
("compilation_db", {"COMPILATIONDB_COMSTR": "\tCDB\t${TARGET}"}),
|
|
|
|
"fwbin",
|
|
|
|
"fbt_apps",
|
|
|
|
],
|
2022-07-05 12:24:59 +00:00
|
|
|
COMPILATIONDB_USE_ABSPATH=False,
|
2022-06-26 12:00:03 +00:00
|
|
|
BUILD_DIR=fw_build_meta["build_dir"],
|
|
|
|
IS_BASE_FIRMWARE=fw_build_meta["type"] == "firmware",
|
|
|
|
FW_FLAVOR=fw_build_meta["flavor"],
|
2022-11-05 11:47:59 +00:00
|
|
|
LIB_DIST_DIR=fw_build_meta["build_dir"].Dir("lib"),
|
2022-06-26 12:00:03 +00:00
|
|
|
LINT_SOURCES=[
|
|
|
|
"applications",
|
|
|
|
],
|
|
|
|
LIBPATH=[
|
|
|
|
"${LIB_DIST_DIR}",
|
|
|
|
],
|
|
|
|
CPPPATH=[
|
2022-07-20 10:56:33 +00:00
|
|
|
"#/furi",
|
2022-09-14 16:11:38 +00:00
|
|
|
*(f"#/{app_dir[0]}" for app_dir in ENV["APPDIRS"] if app_dir[1]),
|
2022-06-26 12:00:03 +00:00
|
|
|
"#/firmware/targets/f${TARGET_HW}/ble_glue",
|
|
|
|
"#/firmware/targets/f${TARGET_HW}/fatfs",
|
|
|
|
"#/firmware/targets/f${TARGET_HW}/furi_hal",
|
|
|
|
"#/firmware/targets/f${TARGET_HW}/Inc",
|
|
|
|
"#/firmware/targets/furi_hal_include",
|
|
|
|
],
|
|
|
|
# Specific flags for building libraries - always do optimized builds
|
|
|
|
FW_LIB_OPTS={
|
|
|
|
"Default": {
|
|
|
|
"CCFLAGS": [
|
|
|
|
"-Os",
|
|
|
|
],
|
|
|
|
"CPPDEFINES": [
|
|
|
|
"NDEBUG",
|
|
|
|
"FURI_NDEBUG",
|
|
|
|
],
|
|
|
|
# You can add other entries named after libraries
|
|
|
|
# If they are present, they have precedence over Default
|
2022-06-28 12:28:55 +00:00
|
|
|
},
|
|
|
|
# for furi_check to respect build type
|
2022-07-20 10:56:33 +00:00
|
|
|
"furi": {
|
2022-06-28 12:28:55 +00:00
|
|
|
"CCFLAGS": [
|
|
|
|
"-Os",
|
|
|
|
],
|
|
|
|
"CPPDEFINES": [
|
|
|
|
"NDEBUG",
|
|
|
|
"FURI_DEBUG" if ENV["DEBUG"] else "FURI_NDEBUG",
|
|
|
|
],
|
|
|
|
},
|
2022-09-14 16:11:38 +00:00
|
|
|
"flipper_application": {
|
|
|
|
"CCFLAGS": [
|
|
|
|
"-Og",
|
|
|
|
],
|
|
|
|
"CPPDEFINES": [
|
|
|
|
"NDEBUG",
|
|
|
|
"FURI_DEBUG" if ENV["DEBUG"] else "FURI_NDEBUG",
|
|
|
|
],
|
|
|
|
},
|
2022-06-26 12:00:03 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def ApplyLibFlags(env):
|
|
|
|
flags_to_apply = env["FW_LIB_OPTS"].get(
|
|
|
|
env.get("FW_LIB_NAME"),
|
|
|
|
env["FW_LIB_OPTS"]["Default"],
|
|
|
|
)
|
|
|
|
# print("Flags for ", env.get("FW_LIB_NAME", "Default"), flags_to_apply)
|
|
|
|
env.MergeFlags(flags_to_apply)
|
|
|
|
|
|
|
|
|
|
|
|
env.AddMethod(ApplyLibFlags)
|
|
|
|
|
|
|
|
Export("env")
|
|
|
|
|
2022-07-05 12:24:59 +00:00
|
|
|
if env["IS_BASE_FIRMWARE"]:
|
|
|
|
env.Append(
|
|
|
|
FIRMWARE_BUILD_CFG="firmware",
|
|
|
|
RAM_EXEC=False,
|
|
|
|
)
|
|
|
|
else:
|
2022-06-26 12:00:03 +00:00
|
|
|
env.Append(
|
|
|
|
FIRMWARE_BUILD_CFG="updater",
|
|
|
|
RAM_EXEC=True,
|
|
|
|
CPPDEFINES=[
|
|
|
|
"FURI_RAM_EXEC",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2022-08-07 15:09:00 +00:00
|
|
|
# Invoke child SConscripts to populate global `env` + build their own part of the code
|
2022-06-26 12:00:03 +00:00
|
|
|
lib_targets = env.BuildModules(
|
|
|
|
[
|
|
|
|
"lib",
|
|
|
|
"assets",
|
|
|
|
"firmware",
|
2022-07-20 10:56:33 +00:00
|
|
|
"furi",
|
2022-06-26 12:00:03 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Now, env is fully set up with everything to build apps
|
2022-11-02 15:15:40 +00:00
|
|
|
fwenv = env.Clone(FW_ARTIFACTS=[])
|
|
|
|
|
|
|
|
fw_artifacts = fwenv["FW_ARTIFACTS"]
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
# Set up additional app-specific build flags
|
|
|
|
SConscript("site_scons/firmwareopts.scons", exports={"ENV": fwenv})
|
|
|
|
|
|
|
|
# Set up app configuration
|
|
|
|
if env["IS_BASE_FIRMWARE"]:
|
|
|
|
fwenv.Append(APPS=fwenv["FIRMWARE_APPS"].get(fwenv.subst("$FIRMWARE_APP_SET")))
|
|
|
|
else:
|
|
|
|
fwenv.Append(APPS=["updater"])
|
|
|
|
|
|
|
|
if extra_int_apps := GetOption("extra_int_apps"):
|
2022-06-30 16:06:12 +00:00
|
|
|
fwenv.Append(APPS=extra_int_apps.split(","))
|
2022-06-26 12:00:03 +00:00
|
|
|
|
2022-10-12 16:12:05 +00:00
|
|
|
|
|
|
|
if fwenv["FAP_EXAMPLES"]:
|
|
|
|
fwenv.Append(APPDIRS=[("applications/examples", False)])
|
|
|
|
|
2022-11-02 15:15:40 +00:00
|
|
|
for app_dir, _ in env["APPDIRS"]:
|
|
|
|
app_dir_node = env.Dir("#").Dir(app_dir)
|
|
|
|
|
|
|
|
for entry in app_dir_node.glob("*"):
|
|
|
|
if isinstance(entry, FS.Dir) and not str(entry).startswith("."):
|
|
|
|
fwenv.LoadAppManifest(entry)
|
|
|
|
|
|
|
|
|
2022-06-26 12:00:03 +00:00
|
|
|
fwenv.PrepareApplicationsBuild()
|
|
|
|
|
2022-11-05 11:47:59 +00:00
|
|
|
# Build external apps + configure SDK
|
2022-10-25 22:15:02 +00:00
|
|
|
if env["IS_BASE_FIRMWARE"]:
|
2022-11-05 11:47:59 +00:00
|
|
|
fwenv.SetDefault(FBT_FAP_DEBUG_ELF_ROOT="${BUILD_DIR}/.extapps")
|
|
|
|
fwenv["FW_EXTAPPS"] = SConscript(
|
|
|
|
"site_scons/extapps.scons",
|
|
|
|
exports={"ENV": fwenv},
|
2022-10-25 22:15:02 +00:00
|
|
|
)
|
2022-11-05 11:47:59 +00:00
|
|
|
fw_artifacts.append(fwenv["FW_EXTAPPS"].sdk_tree)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Add preprocessor definitions for current set of apps
|
2022-09-14 16:11:38 +00:00
|
|
|
fwenv.Append(
|
2022-06-26 12:00:03 +00:00
|
|
|
CPPDEFINES=fwenv["APPBUILD"].get_apps_cdefs(),
|
|
|
|
)
|
|
|
|
|
|
|
|
# Build applications.c for selected services & apps
|
|
|
|
# Depends on virtual value-only node, so it only gets rebuilt when set of apps changes
|
|
|
|
apps_c = fwenv.ApplicationsC(
|
|
|
|
"applications/applications.c",
|
2022-08-12 22:17:11 +00:00
|
|
|
[Value(fwenv["APPS"]), Value(fwenv["LOADER_AUTOSTART"])],
|
2022-06-26 12:00:03 +00:00
|
|
|
)
|
2022-09-14 16:11:38 +00:00
|
|
|
|
2022-07-04 16:53:04 +00:00
|
|
|
# Adding dependency on manifest files so apps.c is rebuilt when any manifest is changed
|
2022-09-14 16:11:38 +00:00
|
|
|
for app_dir, _ in env["APPDIRS"]:
|
|
|
|
app_dir_node = env.Dir("#").Dir(app_dir)
|
2022-10-06 13:55:57 +00:00
|
|
|
fwenv.Depends(apps_c, app_dir_node.glob("*/application.fam"))
|
|
|
|
|
|
|
|
# Sanity check - certain external apps are using features that are not available in base firmware
|
|
|
|
if advanced_faps := list(
|
|
|
|
filter(
|
|
|
|
lambda app: app.fap_extbuild or app.fap_private_libs or app.fap_icon_assets,
|
|
|
|
fwenv["APPBUILD"].get_builtin_apps(),
|
|
|
|
)
|
|
|
|
):
|
|
|
|
raise UserError(
|
|
|
|
"An Application that is using fap-specific features cannot be built into base firmware."
|
|
|
|
f" Offending app(s): {', '.join(app.appid for app in advanced_faps)}"
|
|
|
|
)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
sources = [apps_c]
|
2022-07-05 12:24:59 +00:00
|
|
|
# Gather sources only from app folders in current configuration
|
2022-09-14 16:11:38 +00:00
|
|
|
sources.extend(
|
|
|
|
itertools.chain.from_iterable(
|
2022-10-06 13:55:57 +00:00
|
|
|
fwenv.GlobRecursive(source_type, appdir.relpath, exclude="lib")
|
2022-09-14 16:11:38 +00:00
|
|
|
for appdir, source_type in fwenv["APPBUILD"].get_builtin_app_folders()
|
|
|
|
)
|
|
|
|
)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
|
|
|
# Debug
|
|
|
|
# print(fwenv.Dump())
|
|
|
|
|
|
|
|
# Full firmware definition
|
|
|
|
fwelf = fwenv["FW_ELF"] = fwenv.Program(
|
|
|
|
"${FIRMWARE_BUILD_CFG}",
|
|
|
|
sources,
|
|
|
|
LIBS=[
|
2022-08-03 16:00:17 +00:00
|
|
|
"print",
|
2022-06-26 12:00:03 +00:00
|
|
|
"flipper${TARGET_HW}",
|
2022-07-20 10:56:33 +00:00
|
|
|
"furi",
|
2022-06-26 12:00:03 +00:00
|
|
|
"freertos",
|
|
|
|
"stm32cubewb",
|
|
|
|
"hwdrivers",
|
|
|
|
"fatfs",
|
|
|
|
"littlefs",
|
|
|
|
"subghz",
|
|
|
|
"flipperformat",
|
|
|
|
"toolbox",
|
2022-07-26 15:30:49 +00:00
|
|
|
"nfc",
|
2022-06-26 12:00:03 +00:00
|
|
|
"microtar",
|
|
|
|
"usb_stm32",
|
|
|
|
"st25rfal002",
|
|
|
|
"infrared",
|
|
|
|
"appframe",
|
|
|
|
"assets",
|
|
|
|
"misc",
|
2022-07-05 12:24:59 +00:00
|
|
|
"mbedtls",
|
[FL-2529][FL-1628] New LF-RFID subsystem (#1601)
* Makefile: unit tests pack
* RFID: pulse joiner and its unit test
* Move pulse protocol helpers to appropriate place
* Drop pulse_joiner tests
* Generic protocol, protocols dictionary, unit test
* Protocol dict unit test
* iButton: protocols dictionary
* Lib: varint
* Lib: profiler
* Unit test: varint
* rfid: worker mockup
* LFRFID: em4100 unit test
* Storage: file_exist function
* rfid: fsk osc
* rfid: generic fsk demodulator
* rfid: protocol em4100
* rfid: protocol h10301
* rfid: protocol io prox xsf
* Unit test: rfid protocols
* rfid: new hal
* rfid: raw worker
* Unit test: fix error output
* rfid: worker
* rfid: plain c cli
* fw: migrate to scons
* lfrfid: full io prox support
* unit test: io prox protocol
* SubGHZ: move bit defines to source
* FSK oscillator: level duration compability
* libs: bit manipulation library
* lfrfid: ioprox protocol, use bit library and new level duration method of FSK ocillator
* bit lib: unit tests
* Bit lib: parity tests, remove every nth bit, copy bits
* Lfrfid: awid protocol
* bit lib: uint16 and uint32 getters, unit tests
* lfrfid: FDX-B read, draft version
* Minunit: better memeq assert
* bit lib: reverse, print, print regions
* Protocol dict: get protocol features, get protocol validate count
* lfrfid worker: improved read
* lfrfid raw worker: psk support
* Cli: rfid plain C cli
* protocol AWID: render
* protocol em4100: render
* protocol h10301: render
* protocol indala26: support every indala 26 scramble
* Protocol IO Prox: render
* Protocol FDX-B: advanced read
* lfrfid: remove unused test function
* lfrfid: fix os primitives
* bit lib: crc16 and unit tests
* FDX-B: save data
* lfrfid worker: increase stream size. Alloc raw worker only when needed.
* lfrfid: indala26 emulation
* lfrfid: prepare to write
* lfrfid: fdx-b emulation
* lfrfid: awid, ioprox write
* lfrfid: write t55xx w\o validation
* lfrfid: better t55xx block0 handling
* lfrfid: use new t5577 functions in worker
* lfrfid: improve protocol description
* lfrfid: write and verify
* lfrfid: delete cpp cli
* lfrfid: improve worker usage
* lfrfid-app: step to new worker
* lfrfid: old indala (I40134) load fallback
* lfrfid: indala26, recover wrong synced data
* lfrfid: remove old worker
* lfrfid app: dummy read screen
* lfrfid app: less dummy read screen
* lfrfid: generic 96-bit HID protocol (covers up to HID 37-bit)
* rename
* lfrfid: improve indala26 read
* lfrfid: generic 192-bit HID protocol (covers all HID extended)
* lfrfid: TODO about HID render
* lfrfid: new protocol FDX-A
* lfrfid-app: correct worker stop on exit
* misc fixes
* lfrfid: FDX-A and HID distinguishability has been fixed.
* lfrfid: decode HID size header and render it (#1612)
* lfrfid: rename HID96 and HID192 to HIDProx and HIDExt
* lfrfid: extra actions scene
* lfrfid: decode generic HID Proximity size lazily (#1618)
* lib: stream of data buffers concept
* lfrfid: raw file helper
* lfrfid: changed raw worker api
* lfrfid: packed varint pair
* lfrfid: read stream speedup
* lfrfid app: show read mode
* Documentation
* lfrfid app: raw read gui
* lfrfid app: storage check for raw read
* memleak fix
* review fixes
* lfrfid app: read blink color
* lfrfid app: reset key name after read
* review fixes
* lfrfid app: fix copypasted text
* review fixes
* lfrfid: disable debug gpio
* lfrfid: card detection events
* lfrfid: change validation color from magenta to green
* Update core_defines.
* lfrfid: prefix fdx-b id by zeroes
* lfrfid: parse up to 43-bit HID Proximity keys (#1640)
* Fbt: downgrade toolchain and fix PS1
* lfrfid: fix unit tests
* lfrfid app: remove printf
* lfrfid: indala26, use bit 55 as data
* lfrfid: indala26, better brief format
* lfrfid: indala26, loading fallback
* lfrfid: read timing tuning
Co-authored-by: James Ide <ide@users.noreply.github.com>
Co-authored-by: あく <alleteam@gmail.com>
2022-08-23 15:57:39 +00:00
|
|
|
"lfrfid",
|
2022-09-14 16:11:38 +00:00
|
|
|
"flipper_application",
|
2022-06-26 12:00:03 +00:00
|
|
|
# 2nd round
|
|
|
|
"flipperformat",
|
|
|
|
"toolbox",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2022-07-05 12:24:59 +00:00
|
|
|
# Firmware depends on everything child builders returned
|
2022-06-26 12:00:03 +00:00
|
|
|
Depends(fwelf, lib_targets)
|
2022-07-05 12:24:59 +00:00
|
|
|
# Output extra details after building firmware
|
2022-06-26 12:00:03 +00:00
|
|
|
AddPostAction(fwelf, fwenv["APPBUILD_DUMP"])
|
2022-08-12 22:17:11 +00:00
|
|
|
AddPostAction(
|
|
|
|
fwelf,
|
2022-11-02 15:15:40 +00:00
|
|
|
Action(
|
|
|
|
'${PYTHON3} "${BIN_SIZE_SCRIPT}" elf ${TARGET}',
|
|
|
|
"Firmware size",
|
|
|
|
),
|
2022-08-12 22:17:11 +00:00
|
|
|
)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
2022-07-05 12:24:59 +00:00
|
|
|
# Produce extra firmware files
|
2022-06-26 12:00:03 +00:00
|
|
|
fwhex = fwenv["FW_HEX"] = fwenv.HEXBuilder("${FIRMWARE_BUILD_CFG}")
|
|
|
|
fwbin = fwenv["FW_BIN"] = fwenv.BINBuilder("${FIRMWARE_BUILD_CFG}")
|
2022-08-12 22:17:11 +00:00
|
|
|
AddPostAction(
|
|
|
|
fwbin,
|
2022-11-02 15:15:40 +00:00
|
|
|
Action('@${PYTHON3} "${BIN_SIZE_SCRIPT}" bin ${TARGET}'),
|
2022-08-12 22:17:11 +00:00
|
|
|
)
|
|
|
|
|
2022-06-26 12:00:03 +00:00
|
|
|
fwdfu = fwenv["FW_DFU"] = fwenv.DFUBuilder("${FIRMWARE_BUILD_CFG}")
|
|
|
|
Alias(fwenv["FIRMWARE_BUILD_CFG"] + "_dfu", fwdfu)
|
|
|
|
|
|
|
|
fwdump = fwenv.ObjDump("${FIRMWARE_BUILD_CFG}")
|
|
|
|
Alias(fwenv["FIRMWARE_BUILD_CFG"] + "_list", fwdump)
|
|
|
|
|
|
|
|
|
2022-11-02 15:15:40 +00:00
|
|
|
fw_artifacts.extend(
|
|
|
|
[
|
|
|
|
fwhex,
|
|
|
|
fwbin,
|
|
|
|
fwdfu,
|
|
|
|
fwenv["FW_VERSION_JSON"],
|
|
|
|
]
|
|
|
|
)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
2022-10-06 13:55:57 +00:00
|
|
|
|
|
|
|
fwcdb = fwenv.CompilationDatabase()
|
|
|
|
# without filtering, both updater & firmware commands would be generated in same file
|
2022-11-07 14:54:41 +00:00
|
|
|
fwenv.Replace(
|
|
|
|
COMPILATIONDB_PATH_FILTER=fwenv.subst("*${FW_FLAVOR}*"),
|
|
|
|
COMPILATIONDB_SRCPATH_FILTER="*.c*",
|
|
|
|
)
|
2022-10-06 13:55:57 +00:00
|
|
|
AlwaysBuild(fwcdb)
|
|
|
|
Precious(fwcdb)
|
|
|
|
NoClean(fwcdb)
|
|
|
|
Alias(fwenv["FIRMWARE_BUILD_CFG"] + "_cdb", fwcdb)
|
|
|
|
|
2022-07-05 12:24:59 +00:00
|
|
|
# If current configuration was explicitly requested, generate compilation database
|
|
|
|
# and link its directory as build/latest
|
|
|
|
if should_gen_cdb_and_link_dir(fwenv, BUILD_TARGETS):
|
|
|
|
fw_artifacts.append(fwcdb)
|
|
|
|
|
|
|
|
# Adding as a phony target, so folder link is updated even if elf didn't change
|
|
|
|
link_dir_command = fwenv.PhonyTarget(
|
|
|
|
fwenv.subst("${FIRMWARE_BUILD_CFG}_latest"),
|
|
|
|
Action(
|
|
|
|
lambda source, target, env: link_elf_dir_as_latest(env, source[0]),
|
|
|
|
None,
|
|
|
|
),
|
|
|
|
source=fwelf,
|
|
|
|
)
|
|
|
|
fw_artifacts.append(link_dir_command)
|
|
|
|
|
|
|
|
Alias(fwenv["FIRMWARE_BUILD_CFG"] + "_all", fw_artifacts)
|
2022-06-26 12:00:03 +00:00
|
|
|
|
2022-06-30 16:06:12 +00:00
|
|
|
|
2022-06-26 12:00:03 +00:00
|
|
|
Return("fwenv")
|