Sunday 27 September 2015

My HTPC project

Previously I had a Thecus N2520 NAS. I was satisfied with this because It had strong (Intel Atom) CPU, two 3.5" HDD bays and the most important: HDMI connector and XBMC support.

After half year it dead, and the shop could not replace it. I've got my money back, but I did not have NAS nor HTPC.

The NAS systems with HDMI port are very expenseve (except the N2520), so I decided to build own HTPC.

I would like to use one of my 3.5" HDD but wanted a really small PC case.
The A4 5000 AMD CPU looked very good option to this purpose, so I bought that with 4GB cheap DDR3 1600MHz RAM.
The biggest question was the PC case. The above mentioned CPU has 15W TDP, and I have a NAS ready Samsung HD154UI HDD which costs ~10W.
I needed a Mini ITX PC case with 3.5" HDD support and small PSU included.

Finally I decided to buy the LC-Power LV-1370BII 

HTPC case with 3.5" HDD support

HTPC components

I also bought a silent fan to keep the CPU and the HDD cool:
Silent HTPC fan

Assembling the HTPC hardware

Assembling the HTPC was a bit tricky, because first I could not find how to put a 3.5" HDD into LC-Power LB-1370BII PC case.

how to put a 3.5" HDD into LC-Power LB-1370BII PC case

It was a bit tricky, because after I removed the bracket for the optical drive or 2.5" HDD/SSD I found the holes for the 3.5" HDD, but could not put it into the place. I found out, if I bend the small metal plates at the front of the case, I can put the HDD in and fix it with the 4 included screws.

3.5" HDD assembed into LC-Power 1370BII
I also planed to put an USB 3 Pen drive into the case for backuping importand files. Luckily I could loose two screws which fixed one USB3 port into the case's front panel and fix it to the metal bracket:

USB 3 frontpanel
I planed to extend the PSU's 40mm fan with a 60mm fan to keep the case cool, but there wasn't enough space (less than 25mm) to fix the fan to the botom of the case, so I put it into the top:
60mm fan in LC-Power LC-1370BII
Here is the result:
Asrock QC5000 in LC-Power LC-1370BII
And my remote controller connected into the USB connector:
HTPC remote controller


Install Kodi (XBMC) on Debian 7 (Wheezy) server



This post show you how to install Kodi and a minimal Linux environment. My goal was to build a NAS / HTPC based on cheap hardware and with minimal software environment. My request was to keep the possibility to extend the software with further services. This is why I ignored OpenElec.

First I installed on Debian Jessie, but this sytem with the buggy systemd is...
So I changed to Debian Wheezy. I had good experiences with it






Linux installation


To install Debian on Asrock QC 5000 mainboard, you may need the support for the Realtek  network card. It is a non-free driver, which is not included in the normal Debian insallers. You will receive similar error messages during Linux install:
Missing non-free module: rtl8168

The solution was here: https://raphaelhertzog.com/2011/03/14/missing-firmware-in-debian-learn-how-to-deal-with-the-problem/

The installer can be downloaded from here:
http://live.debian.net/cdimage/release/stable+nonfree/amd64/iso-hybrid/debian-live-7.6.0-amd64-standard+nonfree.iso

After a smooth installation I continued with the Kodi related installation

Kodi Installation on Debian 7

Some help can be found on Kodi's Wiki pages: http://kodi.wiki/view/HOW-TO:Install_Kodi_for_Linux at chapter 2.1

Install the following package to support http repository:
apt-get install apt-transport-https

Add the following to /etc/apt/sources.list.d/kodi.list
deb https://people.debian.org/~rbalint/ppa/xbmc-ffmpeg xbmc-ffmpeg-unstable/
deb http://http.debian.net/debian unstable main


Install Kodi and xinit to run it:
apt-get update
apt-get install kodi xinit

Install suitable xserver-xorg for VGA card


For A4 5000 CPU and QC5000 main board:
apt-get install xserver-xorg-video-radeon

Test it with xinit command

If xinit adds "No screen found" then you may installed wrong version from xserver-xorg-video-radeon. After removing the wrong one (apt-get remove) it installs the default, not VGA card specific versions and the application should start smoothly

Kodi basic configuration

Some help can be found here
https://trick77.com/how-to-install-kodi-ubuntu-server-14-04/

Create the user and add to related groups:
adduser --disabled-password --disabled-login --gecos "" kodi
usermod -a -G audio kodi
usermod -a -G video kodi
usermod -a -G input kodi
usermod -a -G dialout kodi
usermod -a -G plugdev kodi
usermod -a -G tty kodi


It is not a serious issue, happens on Wheezy and on Ubuntu
usermod: group 'input' does not exist

Let Kodi user to start graphical application:

dpkg-reconfigure x11-common
chose anybody from the list
Or
Edit /etc/X11/Xwrapper.config and replace allowed_users=console with allowed_users=anybody

Kodi init script for automatic starup at system boot:


Create a /etc/init.d/kodi with following content:
#! /bin/sh

### BEGIN INIT INFO
# Provides:          kodi
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts instance of Kodi
# Description:       starts instance of Kodi using start-stop-daemon and xinit
### END INIT INFO

############### EDIT ME ##################

# path to xinit exec
DAEMON=`which xinit`

# startup args
DAEMON_OPTS="`which kodi-standalone` -- :0"
# script name
NAME=kodi

# app name
DESC=Kodi

# user
RUN_AS=kodi

# Path of the PID file
PID_FILE=/var/run/kodi.pid

############### END EDIT ME ##################

test -x $DAEMON || exit 0

set -e

case "$1" in
  start)
        echo "Starting $DESC"
        start-stop-daemon --start -c $RUN_AS --background --pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
        ;;
  stop)
        echo "Stopping $DESC"
        start-stop-daemon --stop --pidfile $PID_FILE
        ;;

  restart|force-reload)
        echo "Restarting $DESC"
        start-stop-daemon --stop --pidfile $PID_FILE
        sleep 5
        start-stop-daemon --start -c $RUN_AS --background --pidfile $PID_FILE  --make-pidfile --exec $DAEMON -- $DAEMON_OPTS
        ;;
  *)
        N=/etc/init.d/$NAME
        echo "Usage: $N {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0


Set the permission:
chmod +x /etc/init.d/kodi
Set the automatic startup:
update-rc.d kodi defaults

Jessie complains about the init script, but chkconfig you can wokaround it:
apt-get install chkconfig
chkconfig kodi on

Test it with the following:
# find /etc/rc?.d| grep kodi
/etc/rc0.d/K01kodi
/etc/rc1.d/K01kodi
/etc/rc2.d/S04kodi
/etc/rc3.d/S04kodi
/etc/rc4.d/S04kodi
/etc/rc5.d/S04kodi
/etc/rc6.d/K01kodi



Kodi power off issue

Some information can be found http://forum.kodi.tv/showthread.php?tid=130419
and https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=108209

Install some packages:
apt-get install policykit-1 upower acpi-support consolekit


Create the /var/lib/polkit-1/localauthority/50-local.d/50-kodi.pkla file with the following content:

[Actions for kodi user]
Identity=unix-user:kodi
Action=Action=org.freedesktop.upower.*;org.freedesktop.consolekit.system.*;org.freedesktop.udisks.*
ResultActive=yes
ResultAny=yes
ResultInactive=no



Clean up


apt-cache clean

Reboot the system. Kodi should start automatically and everything should work properly.


If you notice that Kodi uses CPU more than 100% (if you have more than one cores) check the following:
Log in to that machine and with top -H check the threads
If you notice that, llvmpipe processes are running (each for every CPU core)
Then your system uses software rendering. If your system supports hardware rendering, then you need to install the proper VGA driver.
For Ashrock QC5000 and Ati Radeon HD 8330 please check my other post.
The CPU usage with idle Kodi should be under 5%

Kodi VGA video driver for Asrock QC500 on Debian 7 Wheezy

Asrock QC500 has ATi HD 8330 VGA chip.

To use in Debian 7 (Wheezy) do the following:

  1. Download this or the last stable version from http://support.amd.com/en-us/download/desktop?os=Linux+x86:
    E.g.
    http://www2.ati.com/drivers/linux/amd-catalyst-15.9-linux-installer-15.201.1151-x86.x86_64.zip
  2. unizp and run with:
  3. bash AMD-Catalyst-15.9-Linux-installer-15.201.1151-x86.x86_64.run
  4. Accept the basic answers

You may receive similar error messages:
For further configuration of the driver, please run aticonfig from a terminal window or AMD CCC:LE from the Desktop Manager Menu.
System must be rebooted to avoid system instability and potential data loss.
See /usr/share/ati/fglrx-install.log for installation details.
Removing temporary directory: fglrx-install.1tusX7

It needs gcc and make packages, so install them:
apt-get install gcc make -y
and try again.

I hope it helps.