Skip to content

Commit 4fe3536

Browse files
committed
software: normalize firmware while deploying.
1 parent 3e9c6b8 commit 4fe3536

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

firmware/normalize.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import sys
2+
from fx2.format import input_data, output_data
3+
4+
5+
def normalize(input):
6+
output = []
7+
for (addr, chunk) in sorted(input):
8+
if output and output[-1][0] + len(output[-1][1]) == addr:
9+
output[-1] = (output[-1][0], output[-1][1] + chunk)
10+
else:
11+
output.append((addr, chunk))
12+
return output
13+
14+
15+
with open(sys.argv[1], "rb") as f:
16+
data = input_data(f)
17+
data = normalize(data)
18+
with open(sys.argv[2], "wb") as f:
19+
output_data(f, data)

software/deploy-firmware.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set -ex
2323

2424
# Install dependencies.
2525
apt-get update -qq
26-
apt-get install -qq --no-install-recommends git make sdcc
26+
apt-get install -qq --no-install-recommends git make sdcc python3 python3-usb1
2727

2828
# Any commands that create new files in the host mount must be invoked with the caller UID/GID, or
2929
# else the created files will be owned by root. We can't use `docker run --user` because then
@@ -47,7 +47,10 @@ make -C firmware clean
4747
make -C vendor/libfx2/firmware/library all MODELS=medium
4848
make -C firmware all
4949
50-
# Deploy the artifact.
51-
cp firmware/glasgow.ihex software/glasgow/hardware/firmware.ihex
50+
# Deploy the artifact. For incomprehensible (literally; I could not figure out why) reasons,
51+
# the Debian and NixOS builds of exact same commit of sdcc produce different .ihex files that
52+
# nevertheless translate to the same binary contents.
53+
PYTHONPATH=vendor/libfx2/software python3 firmware/normalize.py \
54+
firmware/glasgow.ihex software/glasgow/hardware/firmware.ihex
5255
5356
END

0 commit comments

Comments
 (0)