Skip to content

Commit fd4a7fc

Browse files
committed
add tool to parse out firmware sizes for comparison
1 parent 52e75c6 commit fd4a7fc

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

tools/fwsizes.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
# Run this from within an unzipped directory of build logs from github
3+
# to get a CSV file full of firmware sizes. Super useful to compare sizes
4+
# from various builds.
5+
# Taken from https://github.com/adafruit/circuitpython/pull/4564#issuecomment-816655101
6+
import os, re
7+
8+
for fn in os.listdir():
9+
if os.path.isfile(fn) and ("build-arm " in fn or "build-riscv " in fn):
10+
board = re.split("[()]", fn)[1]
11+
if board in (
12+
"spresense",
13+
"teensy40",
14+
"teensy41",
15+
"feather_m7_1011",
16+
"feather_mimxrt1011",
17+
"feather_mimxrt1062",
18+
"imxrt1010_evk",
19+
"imxrt1020_evk",
20+
"imxrt1060_evk",
21+
"metro_m7_1011",
22+
):
23+
continue
24+
with open(fn, "r") as f:
25+
head = "Build " + board + " for "
26+
lines = iter(f)
27+
for line in lines:
28+
if head in line:
29+
tr = line.split(head)[1].split()[0]
30+
assert "make: Entering directory" in next(lines)
31+
assert "Use make V=1, make V=2" in next(lines)
32+
while re.search(
33+
r"\{\}|QSTR updated|FREEZE|\{'sku':|hex\tfilename|boot2.elf|Including User C Module from|Font missing|section `.bss' type changed to PROGBITS",
34+
next(lines),
35+
):
36+
pass
37+
free = next(lines).split("bytes used, ")[1].split()[0]
38+
print(board + "," + tr + "," + free)

0 commit comments

Comments
 (0)