Skip to content

Commit 3ef2838

Browse files
authored
FBT: Optimize icons blob -4KB DFU, scrub unused icons (#291)
* Unused icons to check later * Exclude disabled icons from firmware * Format * Also report free flash in gh comment * Fix free flash calc * Fix? * Fix?? * Split to next line * Remove dead icons * Some spring cleaning of icons cooker * Improve unused icons script * Disable icons that cant be used in asset packs * These will need a workaround for external * Revert "These will need a workaround for external" This reverts commit fb23d97. * Here's the workaround: split assets lib now there is "assets" and "fwassets" firmware links with fwassets and includes all icons however not all of them are exposed to api if an app needs a firmware icon not in api, it can use fap_libs=["assets"] this will link against this dummy assets lib it only contains the icons that arent exposed to api this way, an app using assets lib will still benefit from asset packs but at same time, we can remove pointless icons from dfu blob * Update changelog
1 parent 78f517b commit 3ef2838

24 files changed

+183
-77
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,22 @@ jobs:
128128
dfu_size_new=$(du --apparent-size -B 1 artifacts/flipper-z-${TARGET}-full-*.dfu | cut -f1)
129129
dfu_size_dev=$(du --apparent-size -B 1 dev.dfu | cut -f1)
130130
dfu_size_diff=$((dfu_size_new - dfu_size_dev))
131-
DFU_SIZE=$(echo ${dfu_size_new}B | sed -r 's/^([0-9]+)([0-9]{2})([0-9])B/\1.\2K/')
132-
DFU_DIFF=$(echo ${dfu_size_diff}B | sed -r 's/^(-?[0-9]+)([0-9]{2})([0-9])B/\1.\2K/' | sed -r 's/^([^-])/+\1/')
131+
DFU_SIZE=$(echo $dfu_size_new | numfmt --to=iec --format=%.2f)
132+
DFU_DIFF=$(echo $dfu_size_diff | numfmt --to=iec --format=%.2f | sed -r 's/^([^-])/+\1/')
133133
echo "DFU_SIZE=$DFU_SIZE" >> $GITHUB_ENV
134134
echo "DFU_DIFF=$DFU_DIFF" >> $GITHUB_ENV
135135
136+
tar xzf build/core2_firmware.tgz
137+
radio_addr=$(jq -r '.copro.radio.files[0].address' core2_firmware/Manifest.json)
138+
flash_base=0x8000000
139+
min_gap=$((2 * 4 * 1024))
140+
flash_free_total=$((radio_addr - flash_base - dfu_size_new))
141+
flash_free_usable=$((flash_free_total - min_gap))
142+
FLASH_FREE=$(echo $flash_free_total | numfmt --to=iec --format=%.2f)
143+
FLASH_USABLE=$(echo $flash_free_usable | numfmt --to=iec --format=%.2f)
144+
echo "FLASH_FREE=$FLASH_FREE" >> $GITHUB_ENV
145+
echo "FLASH_USABLE=$FLASH_USABLE" >> $GITHUB_ENV
146+
136147
- name: "Upload artifacts to update server"
137148
env:
138149
INDEXER_URL: ${{ secrets.INDEXER_URL }}
@@ -170,6 +181,7 @@ jobs:
170181
- [☁️ Flipper Lab/App](https://lab.flipper.net/?url=${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=mntm-${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}})
171182
- [📦 qFlipper Package](${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz)
172183
- DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev)
184+
- Free Flash: `${{ env.FLASH_FREE }}` (`${{ env.FLASH_USABLE }}` usable)
173185
edit-mode: replace
174186

175187
- name: Send devbuild webhook

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@
133133
- UL: W5500 Ethernet: Various fixes and improvements (by @xMasterX)
134134
- OFW: SPI Mem Manager: Fixed UI rendering bug related to line breaks (by @portasynthinca3)
135135
- OFW: USB/BT Remote: Mouse clicker option to click as fast as possible (by @sumukhj1219)
136-
- CLI:
137-
- Print plugin name on load fail (by @Willy-JL)
138-
- Move more commands as plugins on SD, refactor plugin wrapper (#276 by @Willy-JL)
139136
- NFC:
140137
- NDEF Parser:
141138
- Mifare Classic support (#265 by @luu176), protocol-agnostic rewrite and more improvements (#265 by @Willy-JL)
@@ -166,6 +163,10 @@
166163
- OFW: Add TCL 75S451 to TV universal remote (by @christhetech131)
167164
- OFW: Universal remote additions (by @jaylikesbunda)
168165
- OFW: Heavily Expand Universal Remotes (by @jaylikesbunda)
166+
- CLI:
167+
- Print plugin name on load fail (by @Willy-JL)
168+
- Move more commands as plugins on SD, refactor plugin wrapper (#276 by @Willy-JL)
169+
- FBT: Optimize icons blob, scrub unused icons (#291 by @Willy-JL)
169170
- OFW: BadKB: Improve ChromeOS and GNOME demo scripts (by @kowalski7cc)
170171
- OFW: GUI: Change dialog_ex text ownership model (by @skotopes)
171172
- OFW: CCID: App changes and improvements (by @kidbomb)

applications/main/nfc/application.fam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ App(
1313
"!plugins",
1414
"!nfc_cli.c",
1515
],
16-
fap_libs=["mbedtls"],
16+
fap_libs=["assets", "mbedtls"],
1717
fap_icon="icon.png",
1818
fap_category="NFC",
1919
)

applications/settings/about/application.fam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ App(
1212
stack_size=1 * 1024,
1313
order=1000,
1414
fap_category="assets",
15+
fap_libs=["assets"],
1516
)

applications/settings/power_settings_app/application.fam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ App(
1212
stack_size=1 * 1024,
1313
order=40,
1414
fap_category="assets",
15+
fap_libs=["assets"],
1516
)

applications/settings/storage_settings/application.fam

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ App(
88
stack_size=2 * 1024,
99
order=30,
1010
fap_category="assets",
11+
fap_libs=["assets"],
1112
)

applications/system/js_app/application.fam

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ App(
55
cdefines=["JS_RUNNER_FAP"],
66
fap_icon="icon.png",
77
fap_category="assets",
8+
fap_libs=["assets"],
89
entry_point="js_app",
910
stack_size=2 * 1024,
1011
resources="examples",
@@ -35,6 +36,7 @@ App(
3536
"modules/js_flipper.c",
3637
"modules/js_tests.c",
3738
],
39+
fap_libs=["assets"],
3840
)
3941

4042
App(

assets/SConscript

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,26 @@ icons_path = (
1414
if assetsenv["IS_BASE_FIRMWARE"]
1515
else assetsenv["ASSETS_WORK_DIR"]
1616
)
17-
icons = assetsenv.CompileIcons(icons_path, assetsenv["ASSETS_SRC_DIR"].Dir("icons"))
17+
icons = assetsenv.CompileIcons(
18+
icons_path,
19+
assetsenv["ASSETS_SRC_DIR"].Dir("icons"),
20+
fw_bundle=True,
21+
)
1822
assetsenv.Alias("icons", icons)
1923

24+
# Extra icons lib so apps don't override asset packs to use fw icons not exposed to api
25+
# Not used anywhere in code, apps still reference assets_icons.h, but if one of the
26+
# icons they need is not exposed in api, they can link with fap_libs=["assets"] which
27+
# will use this lib purely for linking as a drop-in for missing symbols.
28+
# Should mean that apps made for OFW with fap_libs=["assets"], when compiled with
29+
# this FBT, will still use asset packs at runtime and only link non-exposed icons.
30+
if assetsenv["IS_BASE_FIRMWARE"]:
31+
dropin_icons = assetsenv.CompileIcons(
32+
assetsenv["ASSETS_WORK_DIR"],
33+
assetsenv["ASSETS_SRC_DIR"].Dir("icons"),
34+
icon_bundle_name="_assets_icons_dropin",
35+
)
36+
2037

2138
# Protobuf .proto -> .c + .h
2239
proto_src = assetsenv.Glob("protobuf/*.proto", source=True)
@@ -59,9 +76,14 @@ assetsenv.Alias("proto_ver", proto_ver)
5976
assets_parts = (icons, proto, dolphin_blocking, dolphin_internal, proto_ver)
6077
env.Replace(FW_ASSETS_HEADERS=assets_parts)
6178

62-
assetslib = assetsenv.Library("${FW_LIB_NAME}", assets_parts)
79+
assetslib = assetsenv.Library("fw${FW_LIB_NAME}", assets_parts)
6380
assetsenv.Install("${LIB_DIST_DIR}", assetslib)
6481

82+
if assetsenv["IS_BASE_FIRMWARE"]:
83+
dropin_parts = (dropin_icons, proto, dolphin_blocking, dolphin_internal, proto_ver)
84+
dropin_assetslib = assetsenv.Library("${FW_LIB_NAME}", dropin_parts)
85+
assetsenv.Install("${LIB_DIST_DIR}", dropin_assetslib)
86+
6587

6688
# Resources for SD card
6789
if assetsenv["IS_BASE_FIRMWARE"]:
-137 Bytes
Binary file not shown.
-128 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)