Raspberry Pi 4 + Linux Slackware ARM -current + Kodi 18.4 + FFmpeg 4.2 with x265 under X11


NOTICE: This instruction is obsolete and no longer updated however it might still work. Please use the new instructions found here.


Please feel free to modify these steps and the slackbuild package if you need to.


In the last few days I have been trying to combine the great technologies together, latest Linux Slackware ARM -current with latest Kodi 18.4 Leia running on the Raspberry Pi 4.


I wanted to create a single SlackBuild package to generate the needed installation package of Kodi that could be easily installed under Slackware. Unfortunately the latest SlackBuilds that I found was made for Kodi 17.6 Krypton and I wanted to try something newer than that.

This version of SlackBuild is taken from slaxbmc Kodi 17.6 Krypton at http://slackware.uk/slaxbmc/14.2/slaxbmcsrc-14.2/patches/xbmc/ (thanks to Konstantinos Mantzaris) and heavily optimised according to instructions found in git repository under https://github.com/xbmc/xbmc/blob/master/docs/README.RaspberryPi.md.

After numerous adjustments of the source code of different dependencies and configuration changes (see file kodi.patch) I was able to come up with a working solution that can get Kodi up and running under Linux Slackware ARM in a short time.

I had some troubles trying to compile old dependencies that are bundled together with the latest Kodi so I decided to get the latest versions of these dependencies and go from there and try to fix any errors should they happen. It was much easier rather than trying to fix the old ones against the newest Slackware libraries. I have already included the latest version of patched libcec inside the slackbuild folder instead of trying to patch it in the middle of the build process since kodi.patch would not cover it at the beginning of build. It is a small package and can be easily bundled together with the slackbuild.

I am not sure if those latest dependencies (especially FFmpeg) will break some optimisations made by the Kodi Team for the older releases as those optimisations are not included in the latest dependencies (see the top of xbmc.SlackBuild) but after couple of days of running and testing Kodi on my Pana plasma TV it looks very good (tested with resolutions up to 1080p60).

With the below instruction I was able to successfully build and install Kodi 18.4 on three Raspberry Pi's 4.

--- Prerequisites Start ----

Please make sure that you have at least 64GB SD card on your Pi 4 and at least 1GB swap space (even when you have 4GB RAM, see errors below for more info). There is around 75 dependencies which will be downloaded to /usr/xbmc-tarballs/ by Kodi build and they need some space. Also kodi.log can take some amount of space as well. I do not recommend using WiFi connection because the downloaded dependencies may be corrupted on broken internet connection causing the build process to fail, sometimes after one hour of compilatiion :(

Before we go ahead with preparations of the required packages, first you need to install Slackware ARM -current on your Raspberry Pi 4. I have done mine according to the instructions found at http://sarpi.fatdog.eu/.

After the Slackware ARM -current is installed please install and run the rpi-update && reboot to get the required mmal libs and headers in /opt/vc. Instructions can be found at http://sarpi.fatdog.eu/
   
    echo '/opt/vc/lib' >> /etc/ld.so.conf
   
    install libopus -> found at https://slackbuilds.org/repository/14.2/audio/opus/
    install libfdk-aac -> git clone https://github.com/mstorsjo/fdk-aac.git (cd fdk-aac, ./autogen.sh, ./configure --enable-shared --enable-static, make install, ldconfig)
   
    get raspi tweaks files (just in case they are needed):
        wget http://sarpi.fatdog.eu/files/rpi4/current/syspkg/sarpi4-hacks-4.0-armv7l-1_slackcurrent_31Aug19_sp1.txz
        installpkg sarpi4-hacks-4.0-armv7l-1_slackcurrent_31Aug19_sp1.txz
    get java:
        wget http://sarpi.fatdog.eu/files/pkg/jdk-8u221-armv7-1_slackcurrent_sp1.txz
        installpkg jdk-8u221-armv7-1_slackcurrent_sp1.txz

    install nasm compiler:
        wget http://ftp.arm.slackware.com/slackwarearm/slackwarearm-current/slackware/d/nasm-2.14.02-arm-2.txz   
        installpkg nasm-2.14.02-arm-2.txz
   
    install libmicrohttpd (it gives problems from Kodi build):
        wget https://slackbuilds.org/slackbuilds/14.2/libraries/libmicrohttpd.tar.gz
        tar xvf libmicrohttpd.tar.gz
        cd libmicrohttpd
        wget https://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.66.tar.gz
        vi libmicrohttpd.SlackBuild and adjust the version to 0.9.66
        ./libmicrohttpd.SlackBuild
        upgradepkg --install-new /tmp/libmicrohttpd-0.9.66-arm-1_SBo.tgz
   
    install libx264:
        wget https://slackbuilds.org/slackbuilds/14.2/multimedia/x264.tar.gz
        tar xvf x264.tar.gz
        cd x264
        wget https://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20190925-2245-stable.tar.bz2
        vi x264.SlackBuild and adjust the snapshot version to 20190925
        ./x264.SlackBuild
        upgradepkg --install-new /tmp/x264-20190925-arm-1_SBo.tgz
       
    install libx265 (included patch from patchwork.ozlabs.org):
        wget http://axes2solution.com/kodi/files/x265.tar.gz
        tar xvf x265.tar.gz
        cd x265
        wget https://bitbucket.org/multicoreware/x265/downloads/x265_3.2.tar.gz
        ./x265.SlackBuild
        upgradepkg --install-new /tmp/x265-3.2-arm-1_SBo.tgz
       
    upgrade doxygen to 1.8.16 since version 1.8.15 segfaults on libdvdcss (you will need src2pkg):
        wget http://doxygen.nl/files/doxygen-1.8.16.src.tar.gz
        src2pkg -C doxygen-1.8.16.src.tar.gz
        upgradepkg --install-new /$directory/doxygen-1.8.16-armv7l-1.txz
     
    reboot

--- Prerequisites End ----

    install Kodi:
        wget http://axes2solution.com/kodi/files/kodi-slackware.tar.gz
        tar xvf kodi-slackware.tar.gz
        cd kodi
        wget https://github.com/xbmc/xbmc/archive/18.4-Leia.tar.gz
        mv 18.4-Leia.tar.gz xbmc-18.4-Leia.tar.gz
        ./xbmc.SlackBuild   (this will take around 2 hours)
        upgradepkg --install-new /tmp/xbmc-18.4-arm-1new.txz
   
    On error:
        /usr/bin/tar: Unexpected EOF in archive
        /usr/bin/tar: Unexpected EOF in archive
        /usr/bin/tar: Error is not recoverable: exiting now
       
        check the last downloaded tar archive in /usr/xbmc-tarballs/ if it is not corrupted and download it again and/or see the error below (increase swap space)
       
    On error:
        g++: fatal error: Killed signal terminated program as
        compilation terminated.
        ./configure: line 41081: 12690 Killed
   
        make sure you have at least 1 GB of swap
        dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
        mkswap /var/swap.img
        swapon /var/swap.img
   
    To enable hardware acceleration v3d please:
edit the /boot/config.txt and make sure you have the following two set:
   
    gpu_mem=320 (please do not go above the 1GB limit or you won't boot your system)
   
dtoverlay=vc4-fkms-v3d (I have put it at the end of file)
adjust the /etc/X11/xorg.conf.d/xorg.conf as below:
    Section "Device"
        Identifier      "Allwinner A10/A13 FBDEV"
        Option          "fbdev" "/dev/fb0"
        Option          "SwapbuffersWait" "true"
    EndSection
reboot

    If your audio stutters then please add tsched=0 to the load-module module-udev-detect in /etc/pulse/default.pa as below:
    ### Automatically load driver modules depending on the hardware available
    #.ifexists module-udev-detect.so
    load-module module-udev-detect tsched=0
    #.else
    ### Use the static hardware detection module (for systems that lack udev support)
    #load-module module-detect
    #.endif


Test & Enjoy,
Lukasz


Last updated on 01.10.2019


WE TAKE NO RESPONSIBILITY FOR ANY DAMAGE OR HARM THAT MAY ARISE AS A RESULT OF YOUR OR ANYONE'S USE OF THIS INSTRUCTION.


Slackware® is a registered trademark of Patrick Volkerding and Slackware Linux, Inc.
Kodi is a trademark of the XBMC Foundation
Raspberry Pi™ is a trademark of the Raspberry Pi Foundation
Linux® is the registered trademark of Linus Torvalds