HOW-TO Compile Tvheadend & HDHomerun on Synology NAS

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
hoontune Offline
Junior Member
Posts: 7
Joined: Oct 2012
Reputation: 0
Post: #1
This is how I got Tvheadend & a HDHomerun working on a Synology NAS DS210j (ARM based)

First you need to install the correct bootstrap for your device, if you haven't already
Code:
cd /volume1/@tmp
wget http://wizjos.endofinternet.net/synology/archief/syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh
chmod +x syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh
sh syno-mvkw-bootstrap_1.2-7_arm-ds111.xsh
reboot

Now you need a few dependancies
Code:
ipkg update
ipkg upgrade

ipkg install optware-devel
ipkg install git
ipkg install openssl
ipkg install gcc
ipkg install openssl-dev

Now you can download the Tvheadend source
Code:
mkdir -p /opt/tvheadend
git clone https://github.com/tvheadend/tvheadend.git /opt/tvheadend
cd /opt/tvheadend


you then need to update a few libraries

Code:
cp /opt/arm-none-linux-gnueabi/lib/libpthread-2.5.so /opt/arm-none-linux-gnueabi/lib/libpthread-2.5.so.bk
cp /lib/libpthread.so.0 /opt/arm-none-linux-gnueabi/lib/libpthread-2.5.so

cp /opt/lib/libssl.so.0.9.8 /opt/arm-none-linux-gnueabi/lib
cp /opt/lib/libssl.so.0.9.8 /lib
cp /opt/lib/libcrypto.so.0.9.8 /lib

compile time
Code:
export CC=gcc

bash configure \
--host=armle-unknown-linux \
--target=armle-unknown-linux \
--build=i686-pc-linux \
--disable-avahi \
--release \
--openssl=/opt/lib \
--prefix=/opt/tvheadend

make

make install

setup a directory to hold config data
Code:
mkdir /opt/tvh_dvrconfig_xbmc
to give it a test run
Code:
/opt/tvheadend/bin/tvheadend start -C -u hts -g video -c /opt/tvh_dvrconfig_xbmc
Ctrl-C to stop it
find quote
hoontune Offline
Junior Member
Posts: 7
Joined: Oct 2012
Reputation: 0
Post: #2
The driver for the hdhomerun comes from http://sourceforge.net/projects/dvbhdhomerun/

I've compiled it, and have included the files here

Edit 2014-FEB-07: link to redmine forum no longer works, reposted links on page 8 here
HDHomerun modules


Code:
mkdir /opt/dvb_native

and copy the .ko files into /opt/dvb_native


next download the two start scripts and copy them into the /opt directory
Code:
cd /opt

the startup script start_homerun looks like this
Code:
# Load Core modules
#
insmod /opt/dvb_native/dvb-core.ko
insmod /opt/dvb_native/dvb_hdhomerun_core.ko
#
# Load BE & FE modules
#
insmod /opt/dvb_native/dvb_hdhomerun.ko
insmod /opt/dvb_native/dvb_hdhomerun_fe.ko
#
#lsmod to check if everything is running
#grep -i dvb /proc/devices
#
DYNAMIC_ID=$(grep hdhomerun_control /proc/misc | awk "{print \$1}")
if [ "$DYNAMIC_ID" != "" ]; then
  echo "making node hdhomerun_control" $DYNAMIC_ID
  mknod /dev/hdhomerun_control c 10 $DYNAMIC_ID
else
  echo "Unable to detect hdhomerun_control inside /proc/misc."
fi
# Set permissions
chmod 666 /dev/hdhomerun_control
chown root:root /dev/hdhomerun_control
#
# Clear userhdhomerun log
rm -f "/opt/dvbhdhomerun/dvbhdhomerun.log"
#
# Run userhdhomerun with LD_PRELOAD
/opt/dvbhdhomerun/userhdhomerun/build/userhdhomerun \
        -f -u root -g root -l "/opt/dvbhdhomerun/dvbhdhomerun.log"
#
sleep 1
#
# Retrieve the major device number for DVB
# (normally it should be 212)
DYNAMIC_ID=$(grep DVB /proc/devices | awk "{print \$1}")
if [ "$DYNAMIC_ID" != "" ]; then
        echo "Creating DVB device nodes to major device #$DYNAMIC_ID..."

        # Create device nodes for DVB
        mkdir -p /dev/dvb/adapter0
        DYNAMIC_ID2=$(cut -f2 -d':' /sys/class/dvb/dvb0.frontend0/dev)
        mknod /dev/dvb/adapter0/frontend0 c $DYNAMIC_ID $DYNAMIC_ID2
        DYNAMIC_ID2=$(cut -f2 -d':' /sys/class/dvb/dvb0.demux0/dev)
        mknod /dev/dvb/adapter0/demux0 c $DYNAMIC_ID $DYNAMIC_ID2
        DYNAMIC_ID2=$(cut -f2 -d':' /sys/class/dvb/dvb0.dvr0/dev)
        mknod /dev/dvb/adapter0/dvr0 c $DYNAMIC_ID $DYNAMIC_ID2

        mkdir -p /dev/dvb/adapter1
        DYNAMIC_ID2=$(cut -f2 -d':' /sys/class/dvb/dvb1.frontend0/dev)
        mknod /dev/dvb/adapter1/frontend0 c $DYNAMIC_ID $DYNAMIC_ID2
        DYNAMIC_ID2=$(cut -f2 -d':' /sys/class/dvb/dvb1.demux0/dev)
        mknod /dev/dvb/adapter1/demux0 c $DYNAMIC_ID $DYNAMIC_ID2
        DYNAMIC_ID2=$(cut -f2 -d':' /sys/class/dvb/dvb1.dvr0/dev)
        mknod /dev/dvb/adapter1/dvr0 c $DYNAMIC_ID $DYNAMIC_ID2

        # Set permissions
        chmod 755 /dev/dvb/adapter*
        chmod 666 /dev/dvb/adapter*/*
        chown root:users /dev/dvb/adapter*/*
else
        echo "ERROR: Unable to detect DVB inside /proc/devices; dvb-core.k$"
        exit 10
fi

you can start it with the script
Code:
/opt/start_homerun

last thing is just a startup script for Tvheadend

Code:
TVHROOT="/opt/tvheadend"
TVHNAME="tvheadend"
TVHBIN="${TVHROOT}/bin/${TVHNAME}"
TVHUSER="hts"

# comment below when your happy its working
$TVHBIN start -C -u hts -g video -c /opt/tvh_dvrconfig_xbmc
# use this to fork it into the background
#$TVHBIN start -C -f -u hts -g video -c /opt/tvh_dvrconfig_xbmc

When the system starts, the hdhomerun script needs to run first, then the Tvheadend
(This post was last modified: 2014-02-07 07:48 by hoontune.)
find quote
pvautrin Offline
Junior Member
Posts: 39
Joined: Jan 2011
Reputation: 0
Post: #3
If you want to install tvh 3.2 beta directly from the Syno GUI, Diaoul from http://www.synocommunity.com/ has packaged version 3.2~git20120927-1 a few days ago
find quote
321liftoff Offline
Member
Posts: 53
Joined: Oct 2010
Reputation: 0
Post: #4
Glad you got it all running on your Synology. I noticed a typo in your startup script for Tvheadend: the username for the non-forked cmd is "bts", but I think you mean "hts"?
find quote
schumi2004 Offline
Posting Freak
Posts: 1,227
Joined: Aug 2011
Reputation: 14
Post: #5
If you want the latest TVH then bootstrap and compile it on your Synology is the only way to go.
Since for latest TVH you need GCC 4.3 or higher and Synology's toolchain only supports GCC 4.2.1 for now.
Synology support tells me they will be updating GCC in toolchain but not before DSM 5
find quote
opdenkamp Offline
Team-XBMC PVR Developer
Posts: 2,219
Joined: Feb 2009
Reputation: 29
Location: Heerlen, The Netherlands
Post: #6
stickied

opdenkamp / dushmaniac

xbmc-pvr [Eden-PVR builds] [now included in mainline XBMC, so no more source link here :)]
personal website: [link]

Found a problem with PVR? Report it on Trac, under "PVR - core components". Please attach the full debug log.

If you like my work, please consider donating to me and/or Team XBMC.
find quote
seamus5 Offline
Junior Member
Posts: 6
Joined: Jan 2009
Reputation: 0
Post: #7
Anyone successfully done this on one of the x86 CPUs?
find quote
Z3rO Offline
Member
Posts: 83
Joined: Jan 2009
Reputation: 0
Location: Germany
Post: #8
(2013-01-20 01:12)seamus5 Wrote:  Anyone successfully done this on one of the x86 CPUs?

I tried to and failed miserably using a DS1511+. You need a newer gcc (4.3 upwards I think) to compile the newest tvheadend. Since ipkg only provides 4.2 I tried to compile gcc 4.7 on the DS which resulted in errors I couldn't resolve. Sad
find quote
javamarket Offline
Junior Member
Posts: 16
Joined: Jan 2013
Reputation: 0
Post: #9
Me too, as in ultimate failure sadly.
find quote
seamus5 Offline
Junior Member
Posts: 6
Joined: Jan 2009
Reputation: 0
Post: #10
(2013-02-06 03:33)javamarket Wrote:  Me too, as in ultimate failure sadly.

It's a real shame as TVheadend on a Synology NAS would make a great backend. It could almost be worth trading out my DS412+ for an ARM cpu version just for this.

I guess we can only hope that someone with a little more skill and determination than ourselves is willing to take up the challenge!
find quote
Prof Yaffle Offline
Donor
Posts: 1,092
Joined: Mar 2011
Reputation: 23
Location: UK - in the middlish (mostly).
Post: #11
Since I'm staring at my overflowing 211+ at the moment, wondering what to do next - and weighing up the power management and usability of a bigger Synology box versus a DIY Linux server - this thread caught my eye.

For those of you with x86 Synologies - is the tvheadend spk package in the synocommunity repository? I assume that your concern is a self-build to 3.3.x/git in preference to taking the "old" 3.2.18, or waiting for a pre-built 3.4 to arrive when it's release, yes?

And does anyone have a PPC Synology? Is the 3.2.18 package available (specifically for the QorIQ architecture in the PPC DSx13 series), or has anyone tried to roll their own with any more success than the Atom crew here have had?

Thanks...

EDIT

Or, another thought for anyone - have you tried installing Debian chroot, and running tvheadend (and anything else you need) in that? Yes, it'll have a performance hit on the box, so I don't know if it's viable, but that'd give you much more flexibility on gcc, library versions, etc.
(This post was last modified: 2013-02-06 20:21 by Prof Yaffle.)
find quote
javamarket Offline
Junior Member
Posts: 16
Joined: Jan 2013
Reputation: 0
Post: #12
My issue is the ability to add a HDHomerun Prime device to the mix. TVHeadend is available from SynoCommunity and seems to work with the SynoNAS. I have an x86 713+ and already realize I should have bought his big brother so I feel you pain @Prof Yaffle. The 5 week old 713+ goes on Ebay as soon as the 1512+ is set up. This speaks volumes to how much I actually love this unit.

So to clarify, I'm unable to build the dvbhdhomerun drivers on the x64 unit. I tried to "cheat" by installing DVBLogic server backend (which does a fine job of detecting the HDHR Prime). The issue there is their solution is not yet really ready for QAM which with Verizon & Cablecard is what I need.

I was hoping that removing the DVBLogic backend and reinstalling TVHE would allow detecting the HDHR Prime, unfortunately no such luck.
find quote
seamus5 Offline
Junior Member
Posts: 6
Joined: Jan 2009
Reputation: 0
Post: #13
(2013-02-06 19:47)Prof Yaffle Wrote:  Since I'm staring at my overflowing 211+ at the moment, wondering what to do next - and weighing up the power management and usability of a bigger Synology box versus a DIY Linux server - this thread caught my eye.

For those of you with x86 Synologies - is the tvheadend spk package in the synocommunity repository? I assume that your concern is a self-build to 3.3.x/git in preference to taking the "old" 3.2.18, or waiting for a pre-built 3.4 to arrive when it's release, yes?

And does anyone have a PPC Synology? Is the 3.2.18 package available (specifically for the QorIQ architecture in the PPC DSx13 series), or has anyone tried to roll their own with any more success than the Atom crew here have had?

Thanks...

EDIT

Or, another thought for anyone - have you tried installing Debian chroot, and running tvheadend (and anything else you need) in that? Yes, it'll have a performance hit on the box, so I don't know if it's viable, but that'd give you much more flexibility on gcc, library versions, etc.

TVheadend is available as a package from synocommunity. Current version is 3.2.18-4.
I have an DS412+ (Atom CPU) and I presume it is also available for ARM, but can't confirm.

Current concerns are the lack of a dvbhomerun driver to run hdhomerun TVheadend on the synology x86 NAS.
There seems to be a few success stories for ARM cpus, but nothing for x86 as yet.
find quote
Prof Yaffle Offline
Donor
Posts: 1,092
Joined: Mar 2011
Reputation: 23
Location: UK - in the middlish (mostly).
Post: #14
Hmmm, my previous reply seems to have disappeared somewhere... try again...!

Thanks, Seamus5 - so that's x86 and ARM confirmed (I can confirm that one), for pre-built tvheadend itself at least. Sadly, it looks like the PPC DSx13 range is a dead end for all of this, since ipkg support is seemingly poor plus there's a delay while the synocommunity packages are ported (lack of QorIQ architecture source code from Synology, plus toolchain and library support).

Shame, they'd be nice boxes, but it seems all they can do is what Synology intended, for the moment at least.

Cheers...
find quote
acmyo Offline
Junior Member
Posts: 5
Joined: Feb 2013
Reputation: 0
Location: Denver, CO
Post: #15
(2013-02-06 14:23)seamus5 Wrote:  
(2013-02-06 03:33)javamarket Wrote:  Me too, as in ultimate failure sadly.

It's a real shame as TVheadend on a Synology NAS would make a great backend. It could almost be worth trading out my DS412+ for an ARM cpu version just for this.

I guess we can only hope that someone with a little more skill and determination than ourselves is willing to take up the challenge!

Challenge accepted. Checkout the following tvheadend fork and give it a whirl:

Code:
git clone https://github.com/acmyo/tvheadend.git

If you have any build issues, please attach the output of this command into the thread through pastebin:

Code:
make -k

I am able to successfully build tvheadend with gcc 4.2.1 and gcc 4.1.2. However, I do not have a Synology NAS so there may be other issues I'm unaware of.

I have submitted a pull request to the developer, hopefully this gets merged in shortly.
find quote
Post Reply