Skip to content

Instantly share code, notes, and snippets.

@floehopper
Last active March 26, 2024 14:10
  • Star 69 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save floehopper/99a0c8931f9d779b0998 to your computer and use it in GitHub Desktop.
Install rtl-sdr on Raspian on Raspberry Pi
jamesmead@floehopper.local:~$ sudo dd bs=1m if=/Users/jamesmead/Downloads/2015-02-16-raspbian-wheezy.img of=/dev/disk2
pi@raspberrypi ~ $ sudo raspi-config
# Choose option 1 to "Expand Filesystem" - Ensures that all of the SD card storage is available to the OS
# Choose Finish & reboot

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get upgrade
pi@raspberrypi ~ $ cat <<EOF >no-rtl.conf
blacklist dvb_usb_rtl28xxu
blacklist rtl2832
blacklist rtl2830
EOF
pi@raspberrypi ~ $ sudo mv no-rtl.conf /etc/modprobe.d/

pi@raspberrypi ~ $ sudo apt-get install git-core
pi@raspberrypi ~ $ sudo apt-get install git
pi@raspberrypi ~ $ sudo apt-get install cmake
pi@raspberrypi ~ $ sudo apt-get install libusb-1.0-0-dev
pi@raspberrypi ~ $ sudo apt-get install build-essential

pi@raspberrypi ~ $ git clone https://gitea.osmocom.org/sdr/rtl-sdr.git
pi@raspberrypi ~ $ cd rtl-sdr/
pi@raspberrypi ~/rtl-sdr $ mkdir build
pi@raspberrypi ~/rtl-sdr $ cd build
pi@raspberrypi ~/rtl-sdr/build $ cmake ../ -DINSTALL_UDEV_RULES=ON
pi@raspberrypi ~/rtl-sdr/build $ make
pi@raspberrypi ~/rtl-sdr/build $ sudo make install
pi@raspberrypi ~/rtl-sdr/build $ sudo ldconfig
pi@raspberrypi ~/rtl-sdr/build $ cd ~
pi@raspberrypi ~ $ sudo cp ./rtl-sdr/rtl-sdr.rules /etc/udev/rules.d/
pi@raspberrypi ~ $ sudo reboot

pi@raspberrypi ~ $ rtl_test
Found 1 device(s):
  0:  Generic, RTL2832U, SN: 77771111153705700

Using device 0: Generic RTL2832U
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...

pi@raspberrypi ~ $ sudo apt-get install libasound-dev
pi@raspberrypi ~ $ sudo apt-get install libpulse-dev

pi@raspberrypi ~ $ wget  http://www.aishub.net/downloads/aisdecoder-1.0.0.tar.gz
pi@raspberrypi ~ $ tar zxvf aisdecoder-1.0.0.tar.gz
pi@raspberrypi ~ $ cd aisdecoder-1.0.0/
pi@raspberrypi ~/aisdecoder-1.0.0 $ mkdir build
pi@raspberrypi ~/aisdecoder-1.0.0 $ cd build/
pi@raspberrypi ~/aisdecoder-1.0.0/build $ cmake ../ -DCMAKE_BUILD_TYPE=Release
pi@raspberrypi ~/aisdecoder-1.0.0/build $ make
pi@raspberrypi ~/aisdecoder-1.0.0/build $ sudo cp aisdecoder /usr/local/bin
pi@raspberrypi ~/aisdecoder-1.0.0/build $ cd ~
pi@raspberrypi ~ $

@chrisjosack
Copy link

I used this method on my RPi4 but after I installed Spyserver . I thought Spyserver already had the rtl communications built in. I now get this error:
Kernel driver is active, or device is claimed by second instance of librtlsdr.
In the first case, please either detach or blacklist the kernel module
(dvb_usb_rtl28xxu), or enable automatic detaching at compile time.

usb_claim_interface error -6
Failed to open rtlsdr device #0.

I used the blacklist as detailed in your method but I still get the error.
Any help would be appreciated.
Thanks in advance,
Chris

@Festerstoybox
Copy link

I used this method on my RPi4 but after I installed Spyserver . I thought Spyserver already had the rtl communications built in. I now get this error: Kernel driver is active, or device is claimed by second instance of librtlsdr. In the first case, please either detach or blacklist the kernel module (dvb_usb_rtl28xxu), or enable automatic detaching at compile time.

usb_claim_interface error -6 Failed to open rtlsdr device #0.

I used the blacklist as detailed in your method but I still get the error. Any help would be appreciated. Thanks in advance, Chris

i'm also having this issues, i've tried everything i can find but still no luck. strange thing was it was running couple month ago (last time i used it).

@0xE-acc
Copy link

0xE-acc commented May 30, 2022

Had to recompile with:

cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON

before it worked.

Just sharing as it might help someone else as well.

Thanks for this posting!

This is still relevant in 2022

@Jakuko99
Copy link

Jakuko99 commented Jun 13, 2022

Had to recompile with:

cmake ../ -DINSTALL_UDEV_RULES=ON -DDETACH_KERNEL_DRIVER=ON

before it worked.
Just sharing as it might help someone else as well.
Thanks for this posting!

This is still relevant in 2022

Compiled it same way, but got message No supported devices found. I already tried compiling and installing driver for rtl sdr many different ways, but with no luck. I have no idea at this point what I am doing wrong. Could it be caused by Raspberry OS 64-bit system?

EDIT: It works now, problem was in crappy USB extension cable.

@robrackn
Copy link

robrackn commented Mar 25, 2024

2024 here. You might have to use this link below instead of the git link posted in the instructions:
git clone https://github.com/osmocom/rtl-sdr.git

@floehopper
Copy link
Author

2024 here. You might have to use this link below instead of the git link posted in the instructions: git clone https://github.com/osmocom/rtl-sdr.git

Thanks. It looks as if the canonical repo has moved to Gitea: https://gitea.osmocom.org/sdr/rtl-sdr.git but there is an official mirror on Github: https://github.com/osmocom/rtl-sdr.git. I'll update the instructions accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment