From 5a7a6ce52260ffce67d9b74f0be2cf920a53829a Mon Sep 17 00:00:00 2001 From: Smittix Date: Wed, 18 Feb 2026 16:22:45 +0000 Subject: [PATCH] fix: Remove apt rtl-sdr conflict and always unload DVB modules on Pi Two bugs caused RTL-SDR dongles to be deaf after setup on Raspberry Pi: 1. The apt `rtl-sdr` package was left installed alongside the Blog drivers, creating a binary/library ambiguity. Anything linking or calling the apt binaries in /usr/bin used the non-V4-aware library from /usr/lib instead of the Blog drivers in /usr/local. Fix: remove the apt package immediately after a successful Blog driver build. 2. `blacklist_kernel_drivers_debian` returned early with "already present" without ever running `modprobe -r`, so dvb_usb_rtl28xxu could remain loaded and hold the device in DVB mode (rtl_test sees the USB device but the tuner is unconfigured). Fix: always run the module unload loop regardless of whether the blacklist file is new. Also add `update-initramfs -u` so the blacklist survives reboots. Co-Authored-By: Claude Sonnet 4.6 --- setup.sh | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index 1af64cd..a3ab0f6 100755 --- a/setup.sh +++ b/setup.sh @@ -1315,6 +1315,16 @@ install_rtlsdr_blog_drivers_debian() { $SUDO udevadm trigger || true fi + # Remove the apt rtl-sdr package to prevent binary/library conflicts. + # The apt package installs to /usr/bin and /usr/lib; keeping it alongside + # the Blog drivers (in /usr/local) causes ambiguity and can silently + # result in the wrong (non-V4-aware) library being loaded. + if dpkg -l rtl-sdr 2>/dev/null | grep -q "^ii"; then + info "Removing apt rtl-sdr package to prevent library conflicts with Blog drivers..." + $SUDO apt-get remove -y rtl-sdr >/dev/null 2>&1 || true + fi + $SUDO ldconfig + ok "RTL-SDR Blog drivers installed successfully." info "These drivers provide improved support for RTL-SDR Blog V4 and other devices." warn "Unplug and replug your RTL-SDR devices for the new drivers to take effect." @@ -1348,24 +1358,35 @@ blacklist_kernel_drivers_debian() { if [[ -f "$blacklist_file" ]]; then ok "RTL-SDR kernel driver blacklist already present" - return 0 - fi - - info "Blacklisting conflicting DVB kernel drivers..." - $SUDO tee "$blacklist_file" >/dev/null <<'EOF' + else + info "Blacklisting conflicting DVB kernel drivers..." + $SUDO tee "$blacklist_file" >/dev/null <<'EOF' # Blacklist DVB-T drivers to allow rtl-sdr to access RTL2832U devices blacklist dvb_usb_rtl28xxu blacklist rtl2832 blacklist rtl2830 blacklist r820t EOF + fi - # Unload modules if currently loaded + # Always unload modules if currently loaded — this must happen even on + # re-runs where the blacklist file already exists, since the modules may + # still be live from the current boot (e.g. blacklist wasn't in initramfs). + local unloaded=false for mod in dvb_usb_rtl28xxu rtl2832 rtl2830 r820t; do if lsmod | grep -q "^$mod"; then $SUDO modprobe -r "$mod" 2>/dev/null || true + unloaded=true fi done + $unloaded && info "Unloaded conflicting DVB kernel modules from current session." + + # Bake the blacklist into the initramfs so it survives reboots on + # Raspberry Pi OS / Debian (without this the modules can reload on boot). + if cmd_exists update-initramfs; then + info "Updating initramfs to persist driver blacklist across reboots..." + $SUDO update-initramfs -u >/dev/null 2>&1 || true + fi ok "Kernel drivers blacklisted. Unplug/replug your RTL-SDR if connected." echo