#!/bin/bash # RABBID Chromebook Audio Setup Script for Linux Mint 21.1 # Why Linux mint 21.1? It's the only distro with reports of getting sound to work with these. # It might work with other ubuntu (and probably debian) distros and kernels but who knows. # This script configures audio (speakers and microphone) for Asus Chromebook C423N (RABBID) # with Apollo Lake chipset, DA7219 codec, and MAX98357A amplifier. # Using the ALSA + pulseaudio software stack with intel-sof audio drivers. # ** THIS SCRIPT CREATES AND INSTALLS A SERVICE SCRIPT TO RESTART PULSEAUDIO 12s AFTER DESKTOP LOGIN FOR REASONS OF TIMING BEING HARD ** # ** ~/.config/systemd/user/rabbid-audio-user.service - calls rabbid-audio-fix.sh restarts pulseaudio # ** You might not like the unintended consequences of that. # ** I personally have no problems beyond the *ding* of new audio devices being found each boot. # ** The other file it creates are: # ** /usr/local/bin/rabbid-audio-fix.sh - bring up the kernel modules in the right order with pauses, unmutes # ** /etc/systemd/system/rabbid-audio-fix.service - actually calls rabbid-audio-fix.sh # ** /etc/pulse/default.pa.d/rabbid-audio.pa - sets the RABBID specific audio hardware id paths as pulse input/output devices # ** /lib/firmware/intel/sof-tplg/ - INSTALLS, contents replaced, contains: sof-apl-da7219.tplg topology # ** /lib/firmware/intel/sof/* - INSTALLS, contents replaced, contains: sof firmware # ** /etc/modprobe.d/inteldsp.conf - points kernel snd module at ./intel/sof/ firmware forcing SOF driver for Apollo Lake audio set -e # Exit on error echo "==========================================" echo "RABBID Chromebook Audio Setup" echo "For: Asus Chromebook C423N (codename: RABBID)" echo "OS: Linux Mint 21.1" echo "==========================================" echo "" # Check if running on correct OS if ! grep -q "Linux Mint 21" /etc/os-release 2>/dev/null; then echo "WARNING: This script is designed for Linux Mint 21.1" echo "You appear to be running a different distribution." read -p "Continue anyway? (y/n) " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1 fi fi # Check if running as root if [ "$EUID" -eq 0 ]; then echo "ERROR: Do not run this script as root/sudo" echo "The script will ask for sudo password when needed" exit 1 fi echo "Step 1: Installing required packages..." sudo apt update sudo apt install -y alsa-topology-conf alsa-ucm-conf linux-firmware echo "" echo "Step 2: Downloading SOF firmware..." cd /tmp if [ -d "sof-bin-2024.09.2" ]; then rm -rf sof-bin-2024.09.2 fi wget -q --show-progress https://github.com/thesofproject/sof-bin/releases/download/v2024.09.2/sof-bin-2024.09.2.tar.gz tar -xzf sof-bin-2024.09.2.tar.gz cd sof-bin-2024.09.2 echo "" echo "Step 3: Installing SOF firmware files..." # Remove any conflicting symlinks/directories sudo rm -rf /lib/firmware/intel/sof-tplg 2>/dev/null || true sudo rm -rf /lib/firmware/intel/sof 2>/dev/null || true # Copy topology files sudo cp -r sof-tplg /lib/firmware/intel/ # Copy SOF firmware files sudo cp -r sof /lib/firmware/intel/ # Set proper permissions sudo chmod -R 644 /lib/firmware/intel/sof* sudo find /lib/firmware/intel/sof* -type d -exec chmod 755 {} \; # Verify critical file exists if [ ! -f "/lib/firmware/intel/sof-tplg/sof-apl-da7219.tplg" ]; then echo "ERROR: Critical topology file not found!" exit 1 fi echo "✓ SOF firmware installed successfully" echo "" echo "Step 4: Configuring audio driver..." # Create modprobe configuration sudo bash -c 'cat > /etc/modprobe.d/inteldsp.conf << EOF # Force SOF driver for Apollo Lake audio options snd_intel_dspcfg dsp_driver=3 options snd-sof-pci fw_path=intel/sof/ EOF' echo "✓ Driver configuration created" echo "" echo "Step 5: Creating PulseAudio configuration..." sudo mkdir -p /etc/pulse/default.pa.d sudo bash -c 'cat > /etc/pulse/default.pa.d/rabbid-audio.pa << EOF # RABBID Chromebook audio configuration # Activate stereo output profile set-card-profile alsa_card.pci-0000_00_0e.0-platform-bxt_da7219_mx98357a output:stereo-fallback # Load internal DMIC (digital microphone) load-module module-alsa-source device=hw:0,99 # Load headset microphone load-module module-alsa-source device=hw:0,1 # Set internal DMIC as default microphone set-default-source alsa_input.hw_0_99 EOF' echo "✓ PulseAudio configuration created" echo "" echo "Step 6: Updating initramfs..." sudo update-initramfs -u echo "" echo "Step 7: Creating boot-time audio fix service..." # Create the fix script sudo bash -c 'cat > /usr/local/bin/rabbid-audio-fix.sh << '\''EOF'\'' #!/bin/bash # Wait for system to fully boot sleep 5 # Reload the SOF audio module to work around boot-time race condition modprobe -r snd_soc_sst_bxt_da7219_max98357a modprobe -r snd_sof_pci_intel_apl sleep 1 modprobe snd_sof_pci_intel_apl # Wait for module to initialize sleep 3 # Unmute microphone controls amixer -c 0 cset numid=2 on 2>/dev/null # Main mic amixer -c 0 cset numid=8 on 2>/dev/null # Capture digital amixer -c 0 cset numid=69 on 2>/dev/null # Headset mic amixer -c 0 cset numid=7 127 2>/dev/null # Capture volume # Save ALSA state alsactl store exit 0 EOF' # Make script executable sudo chmod +x /usr/local/bin/rabbid-audio-fix.sh # Create systemd service sudo bash -c 'cat > /etc/systemd/system/rabbid-audio-fix.service << '\''EOF'\'' [Unit] Description=RABBID Chromebook Audio Fix After=sound.target systemd-user-sessions.service Wants=sound.target [Service] Type=oneshot ExecStart=/usr/local/bin/rabbid-audio-fix.sh RemainAfterExit=yes [Install] WantedBy=multi-user.target EOF' # Enable the service sudo systemctl daemon-reload sudo systemctl enable rabbid-audio-fix.service echo "✓ Boot-time audio fix service created and enabled" echo "" echo "Step 8: Creating user-level PulseAudio restart service..." # Create user service directory mkdir -p ~/.config/systemd/user/ # Create user service cat > ~/.config/systemd/user/rabbid-audio-user.service << 'EOF' [Unit] Description=RABBID Audio User Fix After=rabbid-audio-fix.service Requires=sound.target [Service] Type=oneshot ExecStartPre=/bin/sleep 2 ExecStart=/bin/bash -c 'systemctl --user restart pulseaudio.service' RemainAfterExit=yes [Install] WantedBy=default.target EOF # Enable user service systemctl --user daemon-reload systemctl --user enable rabbid-audio-user.service echo "✓ User-level audio restart service created and enabled" echo "" echo "Step 9: Installing pasystray (optional audio tray icon)..." sudo apt install -y pasystray echo "" echo "==========================================" echo "Setup Complete!" echo "==========================================" echo "" echo "IMPORTANT: You must REBOOT for changes to take effect." echo "" echo "After reboot:" echo " - Audio will automatically reload ~10 seconds after boot" echo " - Speakers should work automatically" echo " - Internal microphone (DMIC) should work" echo " - Headset microphone should work when plugged in" echo "" echo "To test after reboot:" echo " Speaker test: paplay /usr/share/sounds/alsa/Front_Center.wav" echo " Mic test: parec -d alsa_input.hw_0_99 --format=s32le | paplay --format=s32le" echo "" echo "Optional: Add pasystray to startup applications for a system tray volume icon" echo "" echo "To check service status:" echo " System service: sudo systemctl status rabbid-audio-fix.service" echo " User service: systemctl --user status rabbid-audio-user.service" echo "" read -p "Reboot now? (y/n) " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then sudo reboot fi