#!/bin/bash # # Builds the Piano LED Visualizer firmware for the Raspberry Pi Zero family. # # Produces both kernel images, which coexist on one SD card: # # kernel.img RASPPI=1 Pi Zero / Zero W (ARM1176) # kernel7.img RASPPI=2 Pi Zero 2 / Zero 2 W (Cortex-A7) # # The Pi picks the right one at boot, so the same card runs on either model. # set -e cd "$(dirname "$0")" ROOT=$PWD PREFIX=${PREFIX:-arm-none-eabi-} if ! command -v "${PREFIX}gcc" >/dev/null 2>&1; then echo "error: ${PREFIX}gcc not found." >&2 echo " Debian/Ubuntu: sudo apt-get install gcc-arm-none-eabi" >&2 exit 1 fi if [ ! -f circle/Rules.mk ]; then echo "error: circle/ is empty. Run: git submodule update --init" >&2 exit 1 fi mkdir -p boot for SPEC in "1:kernel.img" "2:kernel7.img"; do RASPPI=${SPEC%%:*} IMAGE=${SPEC##*:} echo echo "=============== RASPPI=$RASPPI -> $IMAGE ===============" cd "$ROOT/circle" ./configure -r "$RASPPI" -p "$PREFIX" -f ./makeall clean >/dev/null ./makeall -j "$(nproc)" # The WS28XX driver is an addon and is not built by makeall. make -C addon/WS28XX clean >/dev/null 2>&1 || true make -C addon/WS28XX -j "$(nproc)" cd "$ROOT/firmware" make clean >/dev/null 2>&1 || true make -j "$(nproc)" cp "$ROOT/firmware/$IMAGE" "$ROOT/boot/$IMAGE" echo "wrote boot/$IMAGE" done cd "$ROOT/firmware" && make clean >/dev/null 2>&1 || true echo echo "Built:" ls -l "$ROOT/boot" echo echo "Copy boot/*.img plus the Raspberry Pi firmware files (bootcode.bin," echo "start.elf, fixup.dat) and cmdline.txt onto a FAT32 SD card." echo "See README.md for the full card layout."