Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions software/deploy-bootloader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh

# This script is provided to ensure builds of firmware included in the repository are byte for byte
# reproducible regardless of the host OS or the packages installed.
#
# Using this script is not a requirement to work on the firmware; installation instructions for
# the prerequisites for a selection of operating systems are included in the documentation.

BASE_IMAGE=debian:trixie-20250721-slim@sha256:cc92da07b99dd5c078cb5583fdb4ba639c7c9c14eb78508a2be285ca67cc738a

if [ -z "${DOCKER}" ]; then
exec docker run \
--volume $(dirname $(dirname $(readlink -f $0))):/glasgow \
--workdir /glasgow \
--env DOCKER=1 \
--env UID=$(id -u) \
--env GID=$(id -g) \
--rm ${BASE_IMAGE} \
software/deploy-bootloader.sh
fi

set -ex

# Install dependencies.
apt-get update -qq
apt-get install -qq --no-install-recommends git make sdcc python3 python3-usb1

# Any commands that create new files in the host mount must be invoked with the caller UID/GID, or
# else the created files will be owned by root. We can't use `docker run --user` because then
# apt-get would not be able to install packages.
#
# Create a user and a group with the UID/GID of the caller.
groupadd --gid ${GID} caller || true
useradd --uid ${UID} --gid ${GID} caller

# Do the work.
su caller - <<END

# Display dependency versions.
sdcc --version

# Clean all build products; they may have been built using a different compiler.
make -C firmware/library clean
make -C firmware/boot-cypress clean

# Build the artifact.
make -C firmware/library all MODELS=small
make -C firmware/boot-cypress all

# Deploy the artifact. For incomprehensible (literally; I could not figure out why) reasons,
# the Debian and NixOS builds of exact same commit of sdcc produce different .ihex files that
# nevertheless translate to the same binary contents.
PYTHONPATH=software python3 software/normalize.py \
firmware/boot-cypress/boot-cypress.ihex software/fx2/boot-cypress.ihex

END
Loading