The first Rasperry Pi's boards have been shipped to their new owners and in response to high demand for an OpenELEC/XBMC image we have merged our RPi development work into our public github repository. The OpenELEC RPi project code that you can download has already been run by the XBMC team on pre-production Raspberry Pi boards so we know it can be used to build a working system; although we also know there are some issues that need solving and the complete package needs optimising.
Once the OpenELEC developers get their hands on their own production boards we will release a pre-built and supported OpenELEC RPi image alongside our normal ION, Fusion, Ultra and AppleTV (etc.) builds.
OpenELEC fully supports Raspberry Pi's main goal of providing a low cost platform for kids to develop programming, software and hardware development skills on. Through learning how to package and compile OpenELEC to run on Raspberry Pi you can build a working knowledge of the following essential “developer” skills:
- How to compile software packages
- How to build software for different hardware architectures (crosscompiling)
- How to fix packages and build-scripts provided by software vendors
- How to create and using toolchains
- How to design and construct a complete Operating System from nothing
- How to create and manage your own Linux distribution
Cross Compiling and Build Systems
The heart of the OpenELEC project is our software build system. It supports a software building technique called cross-compiling; the process of creating executable code that runs on one hardware platform from something other than that platform. Cross compiling is a crucial function for the OpenELEC project for the following reasons:
- It allows us to build 32bit and 64bit packages and OpenELEC images. It does not matter whether the build-host itself is 32bit or 64bit.
- It allows us to build OpenELEC for a range of different CPU architectures like x86, ARM and PowerPC. This tutorial will help you cross compile an ARM compatible OpenELEC image from an x86 compatible build-host.
- There is no dependency on the particular versions of compiler, libc and Linux kernel headers installed on the build-host. We cross-compile our own versions to ensure we always produce consistent and properly built software packages.
- It allows you to run any Linux distribution as your build system. No matter what your personal preference the resulting OpenELEC image will always be the same.
- It allows us to use the full power of the build-host. Like most ARM devices the Raspberry Pi does not have super fast CPU’s or lots of memory and it uses low-cost but slow USB and flash-card memory for storage; making it unsuitable for native building of large and complex software. Other Linux distributions targetting Raspberry Pi plan to use emulator tools like QEMU that were designed to test and run small software projects to build a full Operating System and it scares us to think how slow and error prone this will be. Even a highly optimised “minimalist” OS like OpenELEC involves the creation of ~500,000 small files during compilation so it’s simple common sense to cross compile and leverage the significantly better resources of a fast local build-host.
How to get the OpenELEC sources?
To build OpenELEC you will need a Linux system like Fedora, Ubuntu, ARCH Linux or SuSE Linux to use as your build-system. To “check out” OpenELEC's sources you must have the git software package installed. OpenELEC is hosted on github so the command to run is:
git clone git://github.com/OpenELEC/OpenELEC.tv.git
After doing this you will have an "OpenELEC.tv" folder. Change to this folder with:
OpenELEC is project based and each pre-built OpenELEC image has its own project folder. If you navigate to "projects/RPi" you will find the "options" file which defines the core packages and drivers used in the RPi project and the Linux kernel configuration. Another folder to look at is the "packages/" folder-tree which contains the build-scripts, patches, configs and meta (info) file for each software package included within OpenELEC.
To create an OpenELEC image for Raspberry Pi we need to tell the build-system the project and architecture to build for. The Raspberry Pi project uses the "arm" architecture so the “make” command to start the build process with is:
PROJECT=RPi ARCH=arm make
That’s all that’s needed! ..but make sure you type the command EXACTLY as shown here as the make command is case-sensitive.
The first thing the build-system does is check for the essential software packages it needs to function. If any are missing it “should” automatically download and install them for you. It may not work automatically on every Linux distro, but if it cannot install them automatically it will print a list of missing package-names on screen so you can install them manually.
The speed of the build process depends on the hardware you’re running. On “current” hardware with multi-core CPUs and several GB of RAM it can be as quick as 2.5 hours. If you are using older hardware it could run to 10-12 hours. The first time you build will always be slower as the build-system needs to download and cache the sources for each package we use. Future builds will run faster as the sources have been cached and only a small number of new or changed packages will need to be fetched.
Have some fun learning how to create your own OpenELEC build and use the development forum if you have any questions. The next part of this tutorial series will follow in a couple of days and will explain how to install OpenELEC on an SD-card and boot your Raspberry Pi.
- OpenELEC wiki: http://wiki.openelec.tv/index.php?title=Compile_from_source
- OpenELEC developer forum: http://openelec.tv/forum/20-development-discussion
- Sources on github: https://github.com/OpenELEC/OpenELEC.tv
- Issues (bug) tracker: https://github.com/OpenELEC/OpenELEC.tv/issues
- IRC chat support: http://openelec.tv/find-help/chat