forked from RogueMaster/flipperzero-firmware-wPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fbt: support for LOADER_AUTOSTART; post-build size stats (flipperdevi…
…ces#1594) * fbt: restored LOADER_AUTOSTART support * scripts: added fwsize.py wrapper for size command; fbt: changed size post-build stats to fwsize.py call * fbt: removed size wrapper * fbt: added stats for binary flash size in pages * fbt: hint on build options details * scripts: fixed fwsize.py for *nix
- Loading branch information
Showing
10 changed files
with
87 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from flipper.app import App | ||
import subprocess | ||
import os | ||
import math | ||
|
||
|
||
class Main(App): | ||
def init(self): | ||
self.subparsers = self.parser.add_subparsers(help="sub-command help") | ||
|
||
self.parser_elfsize = self.subparsers.add_parser("elf", help="Dump elf stats") | ||
self.parser_elfsize.add_argument("elfname", action="store") | ||
self.parser_elfsize.set_defaults(func=self.process_elf) | ||
|
||
self.parser_binsize = self.subparsers.add_parser("bin", help="Dump bin stats") | ||
self.parser_binsize.add_argument("binname", action="store") | ||
self.parser_binsize.set_defaults(func=self.process_bin) | ||
|
||
def process_elf(self): | ||
all_sizes = subprocess.check_output( | ||
["arm-none-eabi-size", "-A", self.args.elfname], shell=False | ||
) | ||
all_sizes = all_sizes.splitlines() | ||
|
||
sections_to_keep = (".text", ".rodata", ".data", ".bss", ".free_flash") | ||
for line in all_sizes: | ||
line = line.decode("utf-8") | ||
parts = line.split() | ||
if len(parts) != 3: | ||
continue | ||
section, size, _ = parts | ||
if section not in sections_to_keep: | ||
continue | ||
print(f"{section:<11} {size:>8} ({(int(size)/1024):6.2f} K)") | ||
|
||
return 0 | ||
|
||
def process_bin(self): | ||
PAGE_SIZE = 4096 | ||
binsize = os.path.getsize(self.args.binname) | ||
pages = math.ceil(binsize / PAGE_SIZE) | ||
last_page_state = (binsize % PAGE_SIZE) * 100 / PAGE_SIZE | ||
print( | ||
f"{os.path.basename(self.args.binname):<11}: {pages:>4} flash pages (last page {last_page_state:.02f}% full)" | ||
) | ||
return 0 | ||
|
||
|
||
if __name__ == "__main__": | ||
Main()() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.