Realtek RTL2838 DVB-T tuner on Raspberry Pi with TvHeadEnd success

I decided to give my DVB-T usb dongle (Realtek RTL2838) another go with the Raspberry Pi and TvHeadEnd. As I thought the newer version of Raspbian if available might address the condition I had previously where I had no dvb device after plugging it in. Older post found here.

It would appear it was a good to check this out again.

I downloaded the latest Raspbian available from the Raspberry Pi site. The version available at the time of this post is the one below;

2013-12-20-wheezy-raspbian.zip

I installed to an SD card and booted my Raspberry Pi.

I plugged in my Realtek RTL2838 tuner and it detected fine and when I checked for the dvb device structure, it was populated all correctly, which never happened previously at all.

[26848.628778] usb 1-1.3: new high-speed USB device number 6 using dwc_otg
[26848.741110] usb 1-1.3: New USB device found, idVendor=0bda, idProduct=2838
[26848.741147] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[26848.741166] usb 1-1.3: Product: RTL2838UHIDIR
[26848.741183] usb 1-1.3: Manufacturer: Realtek
[26848.741199] usb 1-1.3: SerialNumber: 00000001
[26848.851456] usb 1-1.3: dvb_usb_v2: found a 'Realtek RTL2832U reference design' in warm state
[26848.857238] usbcore: registered new interface driver dvb_usb_rtl28xxu
[26848.921368] usb 1-1.3: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer
[26848.921447] DVB: registering new adapter (Realtek RTL2832U reference design)
[26848.965698] usb 1-1.3: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...
[26849.001551] r820t 0-001a: creating new instance
[26849.014447] r820t 0-001a: Rafael Micro r820t successfully identified
[26849.021655] Registered IR keymap rc-empty
[26849.022183] input: Realtek RTL2832U reference design as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/rc/rc0/input0
[26849.022231] rc0: Realtek RTL2832U reference design as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/rc/rc0
[26849.022262] usb 1-1.3: dvb_usb_v2: schedule remote query interval to 400 msecs
[26849.035148] usb 1-1.3: dvb_usb_v2: 'Realtek RTL2832U reference design' successfully initialized and connected

And device files

root@raspberrypi:~# ls -la /dev/dvb
total 0
drwxr-xr-x  3 root root   60 Jan  1 14:51 .
drwxr-xr-x 13 root root 3080 Jan  1 14:51 ..
drwxr-xr-x  2 root root  120 Jan  1 14:51 adapter0
root@raspberrypi:~# ls -la /dev/dvb/adapter0/
total 0
drwxr-xr-x 2 root root     120 Jan  1 14:51 .
drwxr-xr-x 3 root root      60 Jan  1 14:51 ..
crw-rw---T 1 root video 212, 4 Jan  1 14:51 demux0
crw-rw---T 1 root video 212, 5 Jan  1 14:51 dvr0
crw-rw---T 1 root video 212, 3 Jan  1 14:51 frontend0
crw-rw---T 1 root video 212, 7 Jan  1 14:51 net0

Next I configured other tools before compiling and installing the TvHeadEnd per the steps below;

sudo apt-get install unzip libcurl4-openssl-dev pkg-config git build-essential dvb-apps

cd ~
git clone https://github.com/tvheadend/tvheadend
cd tvheadend
./configure
make
sudo make install

At which point I executed the binary via “tvheadend -C” and I could now access the web interface for the TvHeadEnd software via http://raspberrypi_ip:9981/ where I could now see my dvb tuner was detected.

At this point you now have to configure the network and channels according to your region. Can be a bit tricky, but I followed the info available at the post here (step 14). This helped me make sense of the sequence of actions.

Below is a screen grab showing VideoLan Client from my Windows 7 desktop and a web browser in the background attached to the TvHeadEnd which is running on the Raspberry Pi with the RTL2838 tuner.

tvheadend_rtl2838_rpi_vlc

 

EDIT: And to get my TvHeadEnd to auto start with boot I performed the following additional steps.

Created /etc/init.d/tvheadend file with the contents below;

#!/bin/bash
### BEGIN INIT INFO
# Provides: tvheadend
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Should-Start: $syslog
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1
# Short-Description: start/stop tvheadend Server
### END INIT INFO

TVHNAME="tvheadend"
TVHBIN="/usr/local/bin/tvheadend"
TVHUSER="tvheadend"
TVHGROUP="tvheadend"
PIDFILE=/var/run/$TVHNAME.pid

start() {
if [ -e $PIDFILE ]; then
PID=$(ps ax | grep -v grep | grep -w $(cat $PIDFILE) | awk '{print $1}')
if [ -n "$PID" ]; then
echo "$TVHNAME already running (pid $PID)."
exit 1
fi
fi
echo -n "Starting tvheadend: "
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user ${TVHUSER} --exec ${TVHBIN} -- 
-u ${TVHUSER} -g ${TVHGROUP} -f -C
echo "Done."
}

stop() {
if [ -e $PIDFILE ]; then
PID=$(ps ax | grep -v grep | grep -w $(cat $PIDFILE) | awk '{print $1}')
if [ -n "$PID" ]; then
echo -n "Stopping $TVHNAME: "
start-stop-daemon --stop --quiet --pidfile $PIDFILE --name ${TVHNAME}
echo "Done."
else
echo "$TVHNAME is not running."
fi
else
echo "$TVHNAME is not running."
fi
}

status() {
if [ -e $PIDFILE ]; then
PID=$(ps ax | grep -v grep | grep -w $(cat $PIDFILE) | awk '{print $1}')
if [ -n "$PID" ]; then
echo "$TVHNAME is running (pid $PID)."
else
echo "$TVHNAME is not running."
[ -e $PIDFILE ] && exit 1 || exit 3
fi
fi
}

case "$1" in
start) start ;;
stop) stop ;;
restart) stop && sleep 2 && start ;;
*) echo "Usage: $0 [start|stop|restart|status]" && exit 1 ;;
esac

exit 0

Now set the script as executable using below;

sudo chmod 755 /etc/init.d/tvheadend

Create a tvheadend group

sudo groupadd tvheadend

Create a tvheadend user that is part of the video group and tvheadend group.

sudo useradd -g tvheadend -G video -m tvheadend

And now set the initscript tvheadend to startup and shutdown as system does

sudo update-rc.d tvheadend defaults

Comments

4 responses to “Realtek RTL2838 DVB-T tuner on Raspberry Pi with TvHeadEnd success”

  1. Paille Avatar
    Paille

    Hey !

    I just saw your post (thank you google time-based search!) as I was trying again but without success… I compared your log with mine and it simply appeared that the usb hub was forcing usb1.0. I have it now connected directly and recognized. I’ll go on with install and your procedure to see if it works.

    Thanks already !

    P.

    1. michaelf Avatar
      michaelf

      Excellent. I thought I’d try again and had success, so it appears they fixed the kernel issues with the newer release. Which is good.

  2. […] tvheadend setup on it and plug in the USB tuner I was using with my Raspberry Pi. Remember the post here, about […]

  3. Falk Avatar
    Falk

    I’ve got a similar setup, using a Terratec DVB-T-Stick and a Sundtek Media Pro III for DVB-C. With both USB-Sticks, you can stream on two devices at the same time. It’s really nice what you can do with a Raspberry Pi: https://www.kadder.de/2013/12/raspberry-pi-fernsehen-mit-tvheadend/

Leave a Reply

Your email address will not be published. Required fields are marked *