#!/bin/bash # BrainCraft HAT audio (HANDOFF package 1): our WM8960 overlay (pi/overlays/hermes-wm8960.dts: the # stock wm8960-soundcard plus the clock on the codec node, which Ubuntu's driver needs), with the # Pi's own headphone audio off (it shares PWM hardware with the servos). Run as root. Re-runnable. # Needs a reboot afterwards. set -euo pipefail cd "$(dirname "$0")" command -v dtc >/dev/null || apt-get -y install device-tree-compiler dtc -@ -I dts -O dtb -o /boot/firmware/overlays/hermes-wm8960.dtbo overlays/hermes-wm8960.dts cfg=/boot/firmware/config.txt [ -e "$cfg.bak-audio" ] || cp "$cfg" "$cfg.bak-audio" sed -i 's/^dtparam=audio=on$/dtparam=audio=off/' "$cfg" sed -i '/^dtoverlay=wm8960-soundcard$/d' "$cfg" if ! grep -qx 'dtoverlay=hermes-wm8960' "$cfg"; then # dtparam lines must come before the first dtoverlay, so put this right after vc4-kms-v3d sed -i '0,/^dtoverlay=vc4-kms-v3d$/s//dtoverlay=vc4-kms-v3d\ndtoverlay=hermes-wm8960/' "$cfg" fi grep -nE '^dtparam=audio|^dtoverlay=(hermes-)?wm8960' "$cfg" echo "done; reboot to apply"