Skip to main content
  1. All Posts/

synology

Tools Shell

synology – th0ma7

Synology personnal hack, info, tools & source code
Donnations welcomed at: 0x522d164549E68681dfaC850A2cabdb95686C1fEC

Hauppauge WinTV DualHD HWC 955D

The following allows building kernel modules for the Hauppauge WinTV DualHD HWC 955D media adapter allowing to use TVheadEnd (TVH) natively within the NAS.

In theory this procedure is also valid to build most supported DVB adaptors available from the Media Tree within the Linux Media Subsystem.

Tested on the following hardware:

  • model: DS918+
  • OS: DSM 6.2.2 build #24922
  • kernel: 4.4.59+
  • arch: x86_64
  • core name: Apollo Lake

Finding your running kernel:

$ uname -mvr
4.4.59+ #24922 SMP PREEMPT Thu Mar 28 11:07:03 CST 2019 x86_64

Finding your CPU type:

$ cat /proc/cpuinfo | grep model.name | head -1
model name	: Intel(R) Celeron(R) CPU J3455 @ 1.50GHz

Current status

I had backported patches to the Synology DSM 6.x 4.4.59+ kernel but there where a few pending issues. Since then b-rad-NDi ended-up providing a backporting tool that allows rebuilding the media tree over the Synology DSM kernel. This solution as been playing really nicely on my NAS over the last months. Big thanks to b-rad-NDi!!!
For more details on b-rad-NDi project refer to:

  • https://github.com/b-rad-NDi/Embedded-MediaDrivers

Working:

  • em28xx: both tuners detected & firmware loading OK
  • lgdt3306a: fully functional

End result:

  • tvheadend: fully detects both tuners

Instead of building your own I’ve made available a pre-built module package for Hauppauge 955D USB DVB dongle to work on Synology NAS 6.2.2 kernel 4.4.59+ with Apollolake CPU (e.g. DS918+):

  • https://github.com/th0ma7/synology/raw/master/hauppauge/hauppauge955D-SYNOApollolake-DSM622_24922-Kernel_4.4.59-20190520.tar.bz2

Preparation

Using a Ubuntu 18.04 OS to build the updated modules install a few essential packages:

$ sudo apt update
$ sudo apt install build-essential ncurses-dev bc libssl-dev libc6-i386 curl libproc-processtable-perl

Clone b-rad-NDi git repository:

$ git clone https://github.com/b-rad-NDi/Embedded-MediaDrivers.git
$ cd Embedded-MediaDrivers
~/Embedded-MediaDrivers$

Create a SYNO-Apollolake download directory:

$ mkdir dl/SYNO-Apollolake

Download the toolchain

$ wget --content-disposition https://sourceforge.net/projects/dsgpl/files/DSM%206.2%20Tool%20Chains/Intel%20x86%20Linux%204.4.59%20%28Apollolake%29/apollolake-gcc493_glibc220_linaro_x86_64-GPL.txz/download -P dl/SYNO-Apollolake/

Download the Synology DSM kernel sources:

$ wget --content-disposition https://sourceforge.net/projects/dsgpl/files/Synology%20NAS%20GPL%20Source/22259branch/apollolake-source/linux-4.4.x.txz/download -P dl/SYNO-Apollolake/

Initialize the repository:

$ ./md_builder.sh -i -d SYNO-Apollolake

Build a default Synology DSM kernel build (takes a while):

$ export MAKEOPTS="-j`nproc`"
$ ./md_builder.sh -B media -d SYNO-Apollolake

Configure the media tree, get the latest media tree patches that applies over the default Synology DSM kernel and build the media drivers:

$ ./md_builder.sh -g -d SYNO-Apollolake
$ cd build/SYNOAPOLLOLAKE/media_build
build/SYNOAPOLLOLAKE/media_build$ ./build

Installation

Using SSH login as admin on the synology NAS:

$ ssh admin@<my.syno.nas.ip>

Create a new local module directory (name will match kernel version):

$ sudo mkdir -p /usr/local/lib/modules/$(uname -r)
$ cd /usr/local/lib/modules/$(uname -r)

Download the updated media drivers modules over to the NAS (the following downloads not only the mandatory modules for Hauppauge WinTV but rather all the media tree modules):

$ cd /usr/local/lib/modules/$(uname -r)
$ sudo scp "username@<my.ubuntu.linux.ip>:~/Embedded-MediaDrivers/build/SYNOAPOLLOLAKE/media_build/v4l/*.ko" .

Copy the start/stop/load/reset script to the NAS (and make it executable):

$ cd /usr/local/lib/modules/$(uname -r)
$ wget https://raw.githubusercontent.com/th0ma7/synology/master/hauppauge.sh
$ chmod 755 hauppauge.sh

Create a symbolic link to /opt/bin/hauppauge.sh for ease of use:

$ sudo ln -s -T -f /usr/local/lib/modules/$(uname -r)/hauppauge.sh /opt/bin/hauppauge.sh

Create a local rc file locate at /usr/local/etc/rc.d/media.sh that will be executed at boot time:

$ cat << EOF | sudo tee /usr/local/etc/rc.d/media.sh
#!/bin/sh
/usr/local/lib/modules/$(uname -r)/hauppauge.sh load
EOF
$ sudo chmod 755 /usr/local/etc/rc.d/media.sh

Execute manually the rc script to confirm there is no error:

$ sudo /usr/local/etc/rc.d/media.sh

Validate the status:

$ sudo /opt/bin/hauppauge.sh status
Status pkgctl-tvheadend...            N/A
kernel module status... 
	em28xx_dvb                    OK
	em28xx                        OK
	lgdt3306a                     OK
	si2157                        OK
	tveeprom                      OK
	v4l2_common                   OK
	dvb_usb                       OK
	rc_core                       OK
	dvb_core                      OK
	videobuf2_vmalloc             OK
	videobuf2_memops              OK
	videobuf2_v4l2                OK
	videobuf2_common              OK
	videodev                      OK
	media                         OK
kernel USB (1-3) autosuspend values...
	(1-3)autosuspend_delay_ms     [-1000] -> OK
	(1-3)autosuspend              [   -1] -> OK
kernel sysctl values... 
	vm.dirty_expire_centisecs     [  300] -> OK
	vm.swappiness                 [    1] -> OK

Normally should see something similar in kernel dmesg:

[  557.806644] em28xx: New device HCW 955D @ 480 Mbps (2040:026d, interface 0, class 0)
[  557.815308] em28xx: DVB interface 0 found: isoc
[  557.820423] em28xx: chip ID is em28174
[  558.939915] em28174 #0: EEPROM ID = 26 00 01 00, EEPROM hash = 0x3d790eca
[  558.947531] em28174 #0: EEPROM info:
[  558.951857] em28174 #0: 	microcode start address = 0x0004, boot configuration = 0x01
[  558.966683] em28174 #0: 	AC97 audio (5 sample rates)
[  558.972234] em28174 #0: 	500mA max power
[  558.976620] em28174 #0: 	Table at offset 0x27, strings=0x0a72, 0x187c, 0x086a
[  558.984753] em28174 #0: Identified as Hauppauge WinTV-dualHD 01595 ATSC/QAM (card=100)
[  558.994647] tveeprom 8-0050: Hauppauge model 204101, rev B2I6, serial# 11584195
[  559.002824] tveeprom 8-0050: tuner model is SiLabs Si2157 (idx 186, type 4)
[  559.010649] tveeprom 8-0050: TV standards PAL(B/G) NTSC(M) PAL(I) SECAM(L/L') PAL(D/D1/K) ATSC/DVB Digital (eeprom 0xfc)
[  559.023133] tveeprom 8-0050: audio processor is None (idx 0)
[  559.029491] tveeprom 8-0050: has no radio, has IR receiver, has no IR transmitter
[  559.038167] em28174 #0: dvb set to isoc mode.
[  559.043177] em28xx: chip ID is em28174
[  560.162726] em28174 #1: EEPROM ID = 26 00 01 00, EEPROM hash = 0x3d790eca
[  560.170323] em28174 #1: EEPROM info:
[  560.174326] em28174 #1: 	microcode start address = 0x0004, boot configuration = 0x01
[  560.189064] em28174 #1: 	AC97 audio (5 sample rates)
[  560.194613] em28174 #1: 	500mA max power
[  560.199009] em28174 #1: 	Table at offset 0x27, strings=0x0a72, 0x187c, 0x086a
[  560.207139] em28174 #1: Identified as Hauppauge WinTV-dualHD 01595 ATSC/QAM (card=100)
[  560.216915] tveeprom 10-0050: Hauppauge model 204101, rev B2I6, serial# 11584195
[  560.225192] tveeprom 10-0050: tuner model is SiLabs Si2157 (idx 186, type 4)
[  560.233070] tveeprom 10-0050: TV standards PAL(B/G) NTSC(M) PAL(I) SECAM(L/L') PAL(D/D1/K) ATSC/DVB Digital (eeprom 0xfc)
[  560.245327] tveeprom 10-0050: audio processor is None (idx 0)
[  560.251757] tveeprom 10-0050: has no radio, has IR receiver, has no IR transmitter
[  560.260220] em28xx: dvb ts2 set to isoc mode.
[  560.465298] em28174 #0: Binding DVB extension
[  560.476140] i2c i2c-8:...