The Tivo service is coming to an end in my part of the world, so I’m trying to create an equally wife/child-friendly option for recording free-to-air, over-the-air TV and playing it back.
I already have Raspberry Pi’s connected to the various TVs in the house, and I know that Kodi has good support for tvheadend, so I figured I’d give that a go.
I bought a Hauppauge dual tuner USB stick as I thought that it is a good brand, with good Linux support, and I was keen to run the whole thing on an old Raspberry Pi (model B+, 1st generation) if I could.
Good idea, but a bit tricky in the end, because while Raspbian (and LibreElec) detected the card just fine, they would only detect one tuner on the card.
The fine people over in the LibreElec forums helped me out with patching the kernel to allow for dual tuner support. To do this, I set up a virtual machine running Ubuntu 16.04 and got it ready to act as a cross-compiler for Raspberry Pi. The instructions to do so are here – just make sure that you remember what kind of Raspberry Pi you are building for!
The summary of steps I took:
- I got the toolchain and copied the right (64-bit) bin path into my
- I then downloaded the 4.9 kernel with
git clone --depth 1 -b rpi-4.9.y https://github.com/raspberrypi/linux
- I then got patch from a user called Puffin Chunks and followed their instructions
- I applied the patch as per instructions (i.e.
patch -p1 < ../hauppage_winTV_dualHD_DVB_PuffinChunks_4.9.y.diff)
- I then followed the rest of the Raspberry Pi instructions for cross-compiling, paying attention to when to use sudo and when not to!
- Because my VM (Hyper-V) won’t do USB pass-through, I put the SD card in a USB card reader and plugged it into another Linux machine on my network. I then mounted it using
On the machine with the USB card plugged in:
mount /dev/sdc1 /mnt/fat32/ -o umask=000
mount /dev/sdc2 /mnt/ext4-2
bindfs -u -g users /mnt/ext4-2/ /mnt/ext4
(That last bindfs was due to the fact that
ext4 partitions don’t mount with read/write permissions properly.)Then, on the cross-compiling machine:
sudo sshfs @:/mnt/ext4 mnt/ext4
sudo sshfs @:/mnt/fat32 mnt/fat32
This was all in the
linux/ folder that I was working within.)
- After doing this, the modules install line worked fine:
sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install
- Then, making sure that I had put
KERNEL=kernel, I copied the kernel across:
sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.imgI actually called the kernel a new name and then added
sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img
sudo cp arch/arm/boot/dts/*.dtb mnt/fat32/
sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/
sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/
sudo umount mnt/fat32
sudo umount mnt/ext4
- Put the card in, booted it up and we were away to the races! I was now able to boot the RPi, run
raspi-config to get things set up, then SSH on and load all the firmwares from the forum into the
- Installing tvheadend was pretty simple – instructions are here, but
apt-get worked for me after adding
deb http://apt.tvheadend.org/unstable/ jessie main to
Things have moved along quite a way since my first forays into getting AirPlay-compatible Raspberry Pi devices on my home network!
Thanks to Rui’s post here, it was pretty easy to get going on my old Raspberry Pi B+ with a USB Creative Live DAC. All I did was follow the instructions using W32 Disk Imager to put a Raspbian Lite image on a 4GB sound card. Then, I followed Rui’s instructions, which are truncated below:
# NOTE:run these as root (or prefixed with sudo)
# install required packages
apt-get install git automake alsa-utils autoconf libtool libdaemon-dev libasound2-dev libpopt-dev libconfig-dev avahi-daemon libavahi-client-dev libssl-dev make g++
# grab the source
git clone https://github.com/mikebrady/shairport-sync.git
# build it
autoreconf -i -f
./configure --with-alsa --with-avahi --with-ssl=openssl --with-metadata --with-systemd
# create a user account for it and add it to the audio group
groupadd -r shairport-sync
useradd -r -M -g shairport-sync -s /usr/bin/nologin -G audio shairport-sync
# install and enable service
systemctl enable shairport-sync
Then I edited
/usr/local/etc/shairport-sync.conf and added in the name of my AirPlay device that I wanted to appear on the network, and added in these two lines (which I got from using
aplay -l to figure out what my USB sound card was coming in as):
alsa = section)
output_device = "hw:1";
mixer_control_name = "USB Audio";
Done. I also tried adding in the
dwc_otg.speed=1 line to
/boot/cmdline.txt but found that there was no real need for it as I don’t have any crackling or popping like I used to (after making sure the mic input was muted using
alsamixer). Plus, when I do have that line in, USB keyboards and the like don’t work, so be careful with that one.
The fun I had with this one!
The goal: to get Airplay working on my Raspberry Pi.
The rationale: turns out that my HP Microserver (N40L) doesn’t support the hardware extensions needed to pass-through a USB sound-card to VMWare ESXi 5.5, in order for it, in turn, to pass that to the VMs. So, my goal of having a Windows VM running iTunes, Spotify etc. and playing that through a long (15m) 3.5mm cable in a #8 fencing wire approach to extending my media upstairs has come up short. Ha, ha.
So, my backup plan? I have a Raspberry Pi sitting right beside the Microserver (with a very long HDMI cable for extending same said video media upstairs). Maybe I could use that, I thought.
The plan: the Raspberry Pi is running RaspBMC (an awesome distro), and I thought it worthwhile to use a USB soundcard (specifically, a Creative Sound Blaster USB stick) to improve on the not-so-flash audio that comes out of the native 3.5mm jack.
Enter Shairport – a port of Airplay that can run on a Pi.
This site has most of the instructions needed to download and compile the Shairport source, including the additional instructions when using Raspbmc as a base.
From there, the gotchas I uncovered:
- The SoundBlaster seemed to have dramas with rubbish sound when the analog input (default) was selected, but no problems when what ALSA identifies as the S/PDIF input. So, to use that, I had to create a
/etc/asound.conf file that contains the line
pcm.!default front:U0x41e0x30d3 and nothing else. The U0x… is the identifier of the SoundBlaster that I got from using the
aplay -L command, along with the iec958 which is the identifier of the S/PDIF input.
- I found I didn’t need to have the
options snd-usb-audio nrpacks=1 line in the
/etc/modprobe.d/alsa-base.conf file, so that’s good.
- Still some noise coming through the soundcard, so I used
alsactl store 0 to mute and save the changes to the Mic input.
- The final key to getting rid of the noise as best I could was to add the line
dwc_otg.speed=1 to the
/boot/cmdline.txt file which, I think, slows down the USB ports to cut back noise.
What a drama! But now I have it (mostly) sorted and stable, and receiving pretty good sound from a VM with a hi-fi virtual audio cable and AirFoil.
Not too bad.
Turns out that Raspberry Pi is pretty sweet! Not only is the little-computer-that-could a great project with some really laudable intentions re: education, it’s also a great platform for XBMC!
Just wanted to record some of the tips and tricks and learnings as I go through the process of learning another platform:
- When setting up passwordless access via SSH (i.e. using keys), the
.ssh folder needs to be
chmod 700, the
authorized_keys2 files both need to be there with
chmod 600, and the key needs to be a DSA key indicated by
ssh-dss in the
- Yeah, I’m not proud of this workaround (okay, maybe a little), but when you have a large video library (600+ titles), the Pi struggles a bit with reading back from the cache. So, in the short-term, I’ve installed
incrontab and I’m watching the temp folder with the following line entered via
/home/pi/.xbmc/temp/ IN_CLOSE,IN_CLOSE_WRITE,IN_CLOSE_NOWRITE rm /home/pi/.xbmc/temp/vdb-17492a19.fi. In short, the moment that file is written, it’s deleted again. Saves about 10-15 seconds off the load time, but it’s still slow. 😦