Convert install_wm8960.sh to Python#398
Conversation
Faithful 1:1 port of install_wm8960.sh to install_wm8960.py using adafruit_shell, matching the existing converted-script conventions in this repo. Behavior is unchanged: clones the Waveshare WM8960-Audio-HAT repo, installs kernel headers + dkms deps, DKMS-builds the soundcard module for every installed kernel >= 6.5 (preserving the 0.0.0 marker trick that protects sources across kernel updates), installs the dtbo, sets the kernel modules and snd_bcm2835 blacklist, enables the i2s / i2c_arm dtparams and overlays in config.txt, installs the config files and systemd service, and cleans up the clone. Hardware-tested on a Pi 5 (Debian Trixie) with a WM8960 codec: full install verified (DKMS built+installed for both kernels, all config/ module/service pieces placed), then reverted to a captured baseline.
There was a problem hiding this comment.
Pull request overview
Adds a new Python-based installer for the Waveshare WM8960 Audio HAT, continuing the repository’s migration from shell installers to adafruit_shell-driven Python scripts.
Changes:
- Added
install_wm8960.py, a Python port of the existing WM8960 installer flow (clone Waveshare repo, install deps, DKMS build/install, config + service setup). - Implemented DKMS rebuild/install across all installed kernels with version gating (>= 6.5) and a DKMS “marker” directory to preserve sources across kernel updates.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| shell.pattern_replace(config, "^#dtparam=i2s=on", "dtparam=i2s=on") | ||
| shell.pattern_replace(config, "^#dtparam=i2c_arm=on", "dtparam=i2c_arm=on") | ||
| append_if_missing(config, "dtoverlay=i2s-mmap") | ||
| append_if_missing(config, "dtparam=i2s=on") | ||
| append_if_missing(config, "dtoverlay=wm8960-soundcard") |
There was a problem hiding this comment.
Good catch. Switched to shell.reconfig(config, "^#?dtparam=i2c_arm=on", "dtparam=i2c_arm=on") (same for i2s), which uncomments the line if present and appends it if absent — so I2C/I2S are guaranteed enabled. Verified against four config.txt states (commented, absent, already-on, commented mid-file). Fixed in 05fd9f2.
| shell.remove(CLONE_DIR) | ||
|
|
||
| print("------------------------------------------------------") | ||
| print("Please reboot your raspberry pi to apply all settings") |
There was a problem hiding this comment.
Fixed — capitalized to "Raspberry Pi" in 05fd9f2.
|
append_if_missing would be a great function to add to adafruit_python_shell |
…ry Pi Use shell.reconfig (uncomment-or-append) for dtparam=i2s=on and dtparam=i2c_arm=on so I2C/I2S are guaranteed enabled even when the line isn't already present (commented) in config.txt. Drops the now redundant dtparam=i2s=on append. Also fixes the reboot message capitalization.
|
Agreed — For now I've kept the local helper so this PR doesn't depend on an unreleased shell version. |
|
Opened adafruit/Adafruit_Python_Shell#39 to add |
Drop the local append_if_missing helper now that it's available in the shared library (adafruit/Adafruit_Python_Shell#39).
|
adafruit-python-shell 1.14.0 is out, so I've dropped the local helper and switched to |
Converts
install_wm8960.shtoinstall_wm8960.py, continuing the shell-to-Python migration for this repo.This is a faithful 1:1 port using
adafruit_shell(no behavior changes, install-only like the original). It:WM8960-Audio-HATrepo and installs kernel headers + dkms deps0.0.0marker directory that protects the sources from removal across kernel updates.dtbo, sets the kernel modules andsnd_bcm2835blacklisti2s/i2c_armdtparams and thei2s-mmap+wm8960-soundcardoverlays inconfig.txt.conf/.statefiles to/etc/wm8960-soundcard, installs the binary and systemd service, and enables itHardware tested
Verified on a Pi 5 (Debian Trixie) with a WM8960 codec. Full install ran cleanly — DKMS module built and installed for both installed kernels (
6.12.75+rpt-rpi-2712and-v8), and every config / module / blacklist / overlay / service piece was placed correctly. The test system was then reverted to a captured baseline (config.txt md5 confirmed identical afterward).