Banana Pi / Arch Linux / TV

Introduction

The last days I was busy trying to transform my Banana Pi into a small DVR solution to watch and record live TV via a DVB-T USB device. Unfortunately I had to realize, that this goal is much harder to achieve, than I thought in the beginning…

Hardware

I bought a simple DVB-T stick based on the RTL2832U chipset a few month ago, which finally should get a productive purpose. Optimistic as I am, I just thought, a simple plugin of the device into the USB interface should be enough to get recognized by the system. What a huge mistake! I had to find out the hard way, that this device is not supported by the kernel version 3.4.90 which is shipped with the Banana Pi Arch Linux package. It is supported from kernel versions 3.6 and above.I tried hard, to find a working driver for that device on the web, but it seemed to be hopeless.In the end I decided to build the driver module for myself by patching the kernel configuration from the sources and cross compile the whole stuff for myself. A nice guide on how to build the kernel for the Banana Pi is found in the official documentation. As kernel version 3.6 introduced support for the mentioned device, I grabbed the RTL2832 sources from the appropriate Git branch, modified the necessary Makefiles and Kconfigs and after countless attempts on getting the whole stuff up and running, I finally built everything successfully. Thank god, there is Open Source!

A nice side effect of the complete rebuilding of the kernel is the fact, that I could build in some tweaks, that were missing in the official package. For example CONFIG_FHANDLE is not set in the official kernel of ArchLinux_For_BananaPi_v2.0 which results in weird problems with the auto mounting of hard disk drives.

However, when I successfully get the kernel and modules set up, dmesg finally shows the necessary information after plugging in the DVB-T device.

sudo modprobe dvb_usb_rtl2832
dmesg

[   53.317970] usbcore: registered new interface driver dvb_usb_rtl28xxu
[   72.647442] usb 1-1.4: new high-speed USB device number 4 using sw-ehci
[   72.932602] usb 1-1.4: New USB device found, idVendor=1f4d, idProduct=b803
[   73.090371] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   73.217953] usb 1-1.4: Product: RTL2838UHIDIR
[   73.308671] usb 1-1.4: Manufacturer: Realtek
[   73.399379] usb 1-1.4: SerialNumber: 00000041
[   73.546770] dvb-usb: found a 'G-Tek Electronics Group Lifeview LV5TDLX DVB-T' in warm state.
[   73.763096] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[   73.950612] DVB: registering new adapter (G-Tek Electronics Group Lifeview LV5TDLX DVB-T)
[   74.124405] rtl28xxu: rtl2832u_frontend_attach: FC0012 tuner found
[   74.286475] DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...
[   74.353244] fc0012: Fitipower FC0012 successfully attached.
[   74.455845] Registered IR keymap rc-empty
[   74.618852] input: IR-receiver inside an USB DVB receiver as /devices/platform/sw-ehci.1/usb1/1-1/1-1.4/rc/rc0/input3
[   74.851585] rc0: IR-receiver inside an USB DVB receiver as /devices/platform/sw-ehci.1/usb1/1-1/1-1.4/rc/rc0
[   75.029730] dvb-usb: schedule remote query interval to 400 msecs.
[   75.217541] dvb-usb: G-Tek Electronics Group Lifeview LV5TDLX DVB-T successfully initialized and connected.

 Finally this looks good, let’s go on with the much easier software part.
By the way: If you also own a RTL2832U based device and want to build the module for yourself, I created a patch which you simply apply from root directory of the checked out Banana Pi kernel 3.4.90 sources:

patch -p1 < rtl2832u.patch

Software

 I'm going to use Tvheadend as the TV back end which serves the DVB-T stream to XBMC and the rest of my network (make sure to add "armv7h" to the arch array in the PKGBUILD):

yaourt -S tvheadend

We start configuring Tvheadend by enabling the Tvheadend daemon:

sudo systemctl enable tvheadend
sudo systemctl start tvheadend

Now we use the web front end for configuration, the URL is http://BPI_IP:9981/extjs.html. We "add a DVB network by location" and enable the DVB-T device in "Configuration > DVB Input > General". The channel scan for tvheadend is starting then. After this process we have a list of recognized channels in the tab "Services".To get access from the network, we have to setup a user under "Configuration > Access control".Of course we want to get live TV running in XBMC. Therefore we need the PVR HTS add-on which acts as the client to tvheadend. I had to compile it for my own, as there are no official precompiled packages for the ARMv7 architecture.

git clone -b pvr.wmc_frodo https://github.com/krustyreturns/xbmc-pvr-addons
cd xbmc-pvr-addons
./bootstrap
./configure --enable-addons-with-dependencies
make zip

When the previous compilation is done, we retrieve the file pvr.hts-linux-arm.zip located under "addons" which we easily can install in XBMC under "System > Add-ons > Install from zip file". Afterwards we have to configure the previous created user in tvheadend as login data for the PVR client. "System > Live TV > General > Enabled". We are forwarded to "Add-ons > PVR Client", open "Tvheadend HTSP Client" enter the user data and hit "enable".

That's it, go back to the main menu and you have a new section "Live TV". If your live TV image seems to have a wrong aspect ratio, change it via the "Z" key ("Y" on German keyboards).

Enjoy TV on your XBMC setup!

9 comments:

  1. Hi Ryad,

    thank you very much for uploading, I’ll try to mend it into my installation as soon as I can and I’ll report about the result.

    Christian.

  2. Hello Ryad,

    since I’m quite a newbee to compiling a kernel, especially to such a one like the BPro kernel, I think I got stuck while patching and compiling code for my rtl2830/fc0013 DVB-T device working with my BPro. Currently I’m running Arch Linux with kernel 3.4.103 because it’s the latest one avaiable for the board, but since you have managed it to get the rtl2830 module for the 3.4.90 kernel working I’m interested in downgrading for this capability. Would you be so kind and make a downloadable packet of your kernel+modules so I could use it for my installation? Thanks.

    Cheers, Christian.

    1. Hello Christian,

      I could pack it later this day but I have to warn you: My kernel is customized for the Banana Pi. It won’t work on your Banana Pro entirely. You will loose at least Wifi capabilities of the BPro, if it boots at all. Are you still interested?

      By the way: I’m planning in upgrading this guide (and the patch) for the newer kernel version, but I’m really busy at the moment.

      Kind regards,
      Ryad

      1. Hello Ryad,

        thanks for your kind answer. If it’s not too much effort for you I’m still really keen on getting your kernel build.
        Sure – it would be better having the ability to build a working module for the current kernel, but I’m not able to, so it would mean for me to wait for a longer time until you or someone else offers a downloadable working solution. Since I bought my BPro for working as an Media Center especially for Live TV it’s harsh for me to wait. So if getting the binaries from you is the easiest way for me, I’d like to use them.
        Loosing Wifi functionality isn’t that bad for me since there is an working Ethernet port.
        BTW: I haven’t reconned with any obstacles using my USB TV device because my stick, I owned it already when buying the BPro, always worked with linux distributions. But while tracking down the problem with the USB device I had to realized my plans won’t work. So that’s my chance :-).
        Thanks a lot for your efforts and making it public. I’m looking forward to your binaries and, when you find time to make it, a new patch.
        Cheers Christian.

        1. Hello Christian,

          Here you are: download from Dropbox
          MD5: effb5997ede40a1187deb61dca638f07

          You will find the kernel (uImage) which you have to copy to the first partition of your SD card and the modules which you have to copy to /usr/lib/modules within the second partition (the rootfs). Please make a backup of your SD card before you overwrite anything, just in case.

          Then reset your Banana Pro. I expect, you’ll see a kernel panic while booting. But maybe you’re lucky 🙂
          Good luck!

          Ryad

  3. Hi Ryad,
    Like you I bought an RTL2832U usb stick and I want to made my banana PI a Tvheadend Server.
    Unfortunately I can not patch the kernel of a banana pi.
    So I Ask you for help.
    Can you send me a img of your archlinux for banana pi with TVheadend and the RTL2832U driver for please ?
    PS : sorry for my poor english

Leave a Reply

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