Building XBMC

From SolidRun CuBox Wiki
Jump to: navigation, search

These are instructions on compiling and developing XBMC on and for the CuBox. This specific article is meant for developers and advanced users. See also XBMC

XBMC has already have an initial port for the CuBox, this experimental port was made by SolidRun developer rabeeh in his fork on GitHub but the code patches has not yet made it upstream into mainline XBMC.

Application binaries of this port are not available, therefore you will need to compile XBMC yourself, until the code makes it into the mainline XBMC, upstream at

More information can be found on Wikipedia, the XBMC wiki and forums.


Technical notes on developing for the CuBox hardware

Note that the Marvell Armada 510 ARM (ARMv7) processor in CuBox does not use NEON (SIMD instruction set), it instead features WMMX/WMMX2 (Wireless MMX) iwMMXt instruction set SIMD extension, which XBMC's GUI engine and image loading code has not yet been optimized for.

CuBox for Linux defaults to 1920x1080-32bpp at 60Hz but if you run then xrandr is supported and you can switch to 50Hz frequencies.

Note that XBMC currently requires Xorg since it runs over EGL with X backend. Rendering instead direct to frame buffer wwould be much more effective on an embedded platform like the CuBox, so hopefully someone will add support for that in the future. For porting XBMC to DirectFB using DoveFB instead see and DoveFB X.Org and FBDev DirectFB 2D / 3D graphics engine drivers.


The video acceleration inside CuBox uses the GStreamer open source multimedia framework as the base for offloading video decoding to the hardware engine hooked up to XBMC's DVDFactory video player.

A simple sample application that also uses GStreamer is Totem (the official movie player of the GNOME desktop environment).


This code uses the Marvell Dove overlay video rendering backend for OpenGL ES (GLES) graphics overlay instead of XBMC's LinuxRenderer.

The code is mainly based on the wonderful work by topfs2 from the XBMC team on his GSoC 2010 work. It uses /dev/fb1 to communicate with the overlay. It also uses bmm to get, via zero copy, a buffer from the video engine (gstreamer) and display it on the overlay.

Native VMeta Decoder

XBMC team developer gimli has also uploaded a reworked marvell-dove tree that contains a native VMeta decoder implementation that does not rely on GStreamer, which is better for playback performance, however the ability to still optionally use GStreamer for some audio and video sources (such as DRM encrypted streams and media) would be best of both worlds: (this link currently doesn't work, however the most recent set of patches for XMBC can likely be found in the openbricks repository:

Just use the ./configure line:

 ./configure --prefix=/usr --disable-vdpau --disable-vaapi --disable-crystalhd --disable-vdadecoder \
	     --disable-vtbdecoder --disable-vtbdecoder --disable-projectm \
	     --enable-gles --disable-pulse --disable-projectm --enable-dbus \
	     --disable-optimizations --enable-debug --with-platform=marvell-dove


While rabeeh did add --with-iwmmxt to ffmpeg configure, he have disabled it because the CuBox processor (iwmmxt vector operations) and Linux kernel used in his current builds did not support use NEON (SIMD instruction set). However this needs to be fixed as soon as possible in the future as it will increase FFmpeg performance by using Dove vector operations when the audio and/or video codec is not supported by the video engine and instead raw CPU decoding power is required.

Cross-Compiling XBMC for Linux on Ubuntu

You can cross-compile XBMC for CuBox using Scratchbox2 on a x86 computer with Ubuntu for much faster compilation times then what you would get by compiling XBMC natively directly on the Cubox itself.

XBMC for CuBox port source code is available on GitHub

Most of this information is Linux distribution specific so is therefor copied from XBMC wiki articles on how to compile XBMC on Linux

Installing the required libraries and headers for XBMC

See the XBMC README.linux for the required libraries and headers for XBMC

Note that the CuBox processor does not use NEON instruction set, but instead WMMXI instruction set.

Getting the source code

You will have to grab the source code of course. First install the git package provided by your distribution. Then from a terminal, type:

$ cd $HOME
$ git clone git:// xbmc

Building XBMC under Scratchbox

Populate an Ubuntu rootfs under Scratchbox

./configure --enable-gles --enable-dove --enable-dove-overlay --enable-gstreamer --disable-pulse 

You can build this under Scratchbox while populating a Scratchbox root filesystem with the Ubuntu rootfs as previously pointed to here:

Ubuntu Filesystem and kernel shipped with CuBox

Ubuntu Filesystem and kernel shipped with CuBox

The following is a link for a rootfs containing a minimal Ubuntu and XBMC install:

The following are links to separately download the rootfs and other images that are needed if working from scatch:

To set this up

1. cat rootfs.tar.bz2.dd? > rootfs.tar.bz2
2. Create ext3 rootfs on SD card
3. Extract rootfs.tar.bz2 (when extracting you must be inside the SD card directory since there is no leading top directory)
3. Copy uImage, boot.scr to /boot/ under the SD card
4. Extract modules.tar.gz

The last file ubuntu-mmc0p1.txt is the script file we use to create boot.scr

If you wish to be able to compile XBMC yourself then you will also need the packages.tar.gz to get the GLES (OpenGL ES) packages, which contains drivers including GLES2 for gl2.h

Compiling XBMC-PVR on CuBox Ubuntu

XBMC-PVR is an official but experimental branch of XBMC by Team-XBMC, not yet in XBMC mainline code tree, that features a unified PVR (Personal Video Recorder) / DVR (Digital Video Recorder) frontend with EPG (TV-Guide) and an backend API for PVR backend client addons that support several different PVR backends that can be used locally or over the network depending on the platform and operating-system used.

There are today PVR backend client addons available for PVR backends such as HTS TVHeadend, MediaPortal TV-Server, MythTV, VDR, and For The Record, letting XBMC act as a multi-client TV extender.

NOTE: This section is experimental. The binaries have not been tested on the CuBox, yet.

Install XBMC build depends

NOTE: This list may be incomplete because I cannot recall if additional packages were required. Please update if you need more packages.

NOTE: A rootfs on USB or SATA HDD is recommended for compiling XBMC on CuBox.

sudo apt-get install debhelper python-support cmake autotools-dev autoconf automake unzip libboost-dev zip libtool \
      libgl1-mesa-dev libglu1-mesa-dev libglew-dev libmad0-dev libjpeg-dev libsamplerate-dev libogg-dev libvorbis-dev \
      libfreetype6-dev libfontconfig-dev libbz2-dev libfribidi-dev libsqlite3-dev libmysqlclient-dev libasound2-dev \
      libpng12-dev libpcre3-dev liblzo2-dev libcdio-dev libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libenca-dev \
      libjasper-dev libxt-dev libxmu-dev libxinerama-dev libcurl4-gnutls-dev libdbus-1-dev libhal-storage-dev libhal-dev \
      libpulse-dev libavahi-common-dev libavahi-client-dev libxrandr-dev libavcodec-dev libavformat-dev libavutil-dev \
      libpostproc-dev libswscale-dev libmpeg2-4-dev libass-dev libmpcdec-dev libflac-dev python-dev gawk gperf nasm libcwiid1-dev \
      libbluetooth-dev zlib1g-dev libsmbclient-dev libboost-thread-dev libiso9660-dev libssl-dev lsb-release libvdpau-dev \
      libmicrohttpd-dev libmodplug-dev curl python-dev libyajl-dev libplist-dev libusb-dev libudev-dev git-core libgstreamer0.10-dev \

Extract cubox related patches from rabeeh/xbmc

git clone git:// xbmc-rabeeh
cd xbmc-rabeeh
git diff b98c1b4d9ac9fe313a37c1e88e6463308ff8f332 > ../xbmc-cubox.diff 
cd ..

Clone XBMC-PVR and apply CuBox related patches

git clone git:// xbmc-pvr
cd xbmc-pvr
patch -p1 -i 0001-Revert-fixed-ios-Add-memory-barriers-to-atomic-Add-S.patch 
patch -p1 -i 0002-Revert-fixed-ios-Add-memory-barriers-to-cas-assembly.patch 
patch -p1 < ../xbmc-cubox.diff

Bootstrap and configure XBMC-PVR

You will also need the packages.tar.gz, which contains drivers including GLES2 for gl2.h

./configure --enable-gles --enable-dove --enable-dove-overlay --enable-gstreamer --disable-pulse --disable-vdpau

Build and install XBMC-PVR

sudo make install

Setup and run XBMC-PVR

NOTE: Actually this does not work with the above build process. The binaries created do start but xbmc never displays anything except a black screen. I will try again asa all build depependencies for xbmc/rabeeh have been released (EGL/GLES2 includes, more patches that are not in git, yet)

Login as root (password cubox if using Solid-Run's complete rootfs containing minimal Ubuntu and XBMC)

export DISPLAY=:0

Stuff left to do for capable C++ developers

This is an informal ToDo list for stuff to do to improve XBMC for CuBox, and this list is meant for all capable C/C++ developers, both SolidRun employees as well as any other C/C++ programmer willing to volunteer help develop XBMC for the CuBox and submit any finished patches upstream to XBMC:

Optimize XBMC for the Marvell Armada 510 ARM SoC used in CuBox

Fully utilize vMeta hardware acceleration of video, audio, and images

  1. Implement Marvell vMeta hardware engine decoding of JPEG and PNG (and other image / picture formats) decoding, as done by the XBMC for iOS and Sigma Designs ports, as this should noticeably increase the GUI speed/smoothness and image caching/thumbnailing performance immensely. Contact XBMC team developers TheUni and Davilla about how this is done in XBMC for iOS and Sigma Designs ports.
  2. Look into gimli's native vMeta decoder implementation in his reworked marvell-dove tree to use as an alternative to GStreamer =>

Utilize TrustZone cryptographic engine CESA co-processor

  1. Utilize TrustZone cryptographic engine CESA co-processor for hardware acceleration encryption / decryption crypto and ciphers calculations tasks such as SSL, SCP, SSH, AES, TLS, DES, 3DES, SHA-1, MD5, hashes, dm-crypt, luks, etc. (such as hardware decryption with OpenSSL, OpenSSH, and GnuTLS libraries via CryptoDev to offload cryptographic tasks from CPU and therefore every dependency module that XBMC utilizes which support CryptoDev cryptographic accelerator drivers via /dev/crypto) =>

Improve XBMC for Marvell Armada 510 ARM SoC with ARMv7 (iwmmxt vector operations) CPU

  1. Build XBMC on ARM HardFP (Hard Floating Point), a.k.a. armhfp for the CuBox's SoC VFPv3 - Vector Floating Point (VFP) v3 engine, on top of a Linux distribution with hard float support, for more information see
  2. MathUtils doesn't build correctly with the native ARM code already in XBMC (probably scratchbox toolchain issue). Notice that sometimes when launching XBMC we get some assert on MathUtils, unclear if it's related or not.
  3. Get the CuBox integrated CEC (Consumer Electronics Control) over HDMI to work with the libcec and thus also work with XBMC =>

Improve GStreamer for the CuBox

  1. Add better reset implementation instead of flushing by seeking, look at the GStreamer and EGL patches created by Rob Clark in this XBMC fork on GitHub =>
  2. Add delay for pipeline gstreamer creation and wait for paused state. The reason is that there is always hickups when video starts to play since XBMC starts sending frames for decoding, but gstreamer pipe still not ready.
  3. Fix proper pipe closing. There seems to be missing 30 frames at the end of every playback. The reason is that gstreamer is done on decoding but video renderer is still showing those decoded frames.
  4. Change ffmpegcolorspace in gstreamer to output either YUV420, UYVU and other supported dove-overlay video layer color formats (I420 is YUV420 but with swapped color space etc...)
  5. DVDVideoCodecGStreamer has lots of cleanup to do. Internally it has lots of printfs that needs to be removed.

Improve XBMC rendering for Vivante GC600 GPU

  1. Possible try to make XBMC run with DirectFB using DoveFB or a other direct frame buffer support method, to run XBMC without X, (as currently XBMC requires X since it runs over EGL with X backend). This will at least depend on latest DirectFB/Mesa, for more information see
  2. Ugly hack to make XBMC build. Somehow although we don't build LinuxRendererGLES.cpp that header file still being used. For now it's a hack, should be removed in the future.
  3. Second hack is that Status typedef is missing when building WinEventsSDL which leads to build error on XKBlib.h

Improve XBMC for embedded platforms like CuBox

  1. Currently builds for CuBox using a hack to disable eglCreateContext that Dove GL driver does not like, so that needs to be sorted out.
  2. Implement the GPU backoff algorithm when playing a video. Since the video is rendering directly via a video overlay, no need for tens of fps for GPU in that time since it might only be used for subtitles. Instead of running tens of fps, lower the fps of the gpu and thus keep more DDR bandwidth for the video engine so higher bitrate content can be played.
  3. When playing in 1080p, LCD refreshes the graphics overlay by 1920x1080x60hzx32bpp = ~500MB/sec. While playing the graphics overlay is either 100% transparent, or there are subtitles in the bottom of the screen. Implement a hardware mechanism that checks graphics overlay every one second; and by partitioning it and crc32 (by hardware engine) each part adjust the starting and ending point of the graphics overlay. This should drastically lower the LCD graphics overlay refresh.
  4. Assert failures at the beginning when running XBMC. Similar to the item mentioned in XBMC forums here =>
  5. * Add an optional auto video out resolution select mode, with the ability to run a split display resolution for GUI and video playback on embedded platforms. On the GUI go for 720p since the graphics is best (images are 720p optimized and fps is faster - more smooth). When playing back switch to either 1080p or to the native resolution of the content with it's corresponding refresh rate.<ref> Add the ability to run a split gui/display resolution for embedded platforms</ref>
  6. Disable Xorg screen blanking when playing a movie.

Improve FFmpeg build toolchain for CuBox

  1. While rabeeh did add --with-iwmmxt to ffmpeg configure, he have disabled it because the CuBox processor (supports iwmmxt) and Linux kernel used in his current builds did not support use NEON (SIMD instruction set). However this needs to be fixed as soon as possible in the future as it will increase FFmpeg performance by using Dove vector operations when the audio and/or video codec is not supported by the video engine and instead raw CPU decoding power is required.

Improve XBMC audio output on CuBox

  1. asound.conf is not good enough. there are some noises in 44.1KHz and others.


  1. Check to if Rob Clark from Intel's OpenEmbedded project has any other relevant GStreamer, EGL, ARM, etc. patches in this XBMC fork on GitHub =>

See also

Personal tools