Page MenuHomePhabricator

Updated 1,050 Days AgoPublic


We are going to see all the steps from the build to the boot in order to get enlightenment running as wayland compositor on nexus5.

Nexus 5 is used here for two reasons. It's a reference design for Android Project. It's very well supported by libhybris.

Differents technologies are use here :

  • Yocto
  • Android
  • LibHybris

Yocto Project

From their website : "The Yocto Project is an open source collaboration project that provides templates, tools and methods to help you create custom Linux-based systems for embedded products regardless of the hardware architecture"

We will use it to build the distribution and the SDK.


Android is the embedded system developped by Google for mobile devices, targetting phones and tablets. It's based on Linux kernel and on the Bionic libc for the lowest part. It means that all the libraries developed for Android are linked against the bionic libc, which is different from the glibc. Glibc is used in the GNU/Linux distribution and is what we will use and build with Yocto.

EGL and OpenGL/ES librairies used in android devices are also using bionic so you can't use them directly in your linux distribution. That's the purpose of libHyris.


From their github repository: "Hybris is a solution that commits hybris, by allowing us to use bionic-based HW adaptations in glibc systems"

LibHybris is a gateway between Android and GNU/Linux world. With it, we can use Android's binaries in a standard linux distribution.
LibHybris has been developped by Sailfish OS's team and is used in the Jolla Phone. It's also used by Canonical to get Ubuntu Phone running on different kind of hardware. We also found this technology in LuneOS (formerly WebOS).

EFL and Enlightenment

Our goal here is to get all EFL applications running as Wayland Client, and Enlightenment running as a composite manager.

DRM is the graphics API for recent graphics drivers, mostly Intel's one. Most of Hardware vendors doesn't provide this API. But they are providing binaries blob for Android.

To fill the gap, eglfs EFL backend uses OpenGLES api on top of fbdev devices. The name is the same used by Qt to name their QPA Platform supporting the same kind of API.

There is also a wl_eglfs module for enlightenment. With it Enlightenment can be used as a Wayland Compositor.

In the following steps you will need a lot of bandwith and several gigabits of disk space, to be safe 100GB should be enough.
We will use Yocto to build the GNU/Linux distribution and Android CyanogenMod for the Android parts.
To continue you need :

  • A PC with a recent linux distribution supporting Yocto build tools. I'm using Debian 8.
  • A Nexus 5 (White or Black we don't care ;))

Steps to boot

0 - Prepare your machine

Install all the packages needs to build with yocto and to generate an Android build :
Examples for debian Jessie

sudo apt-get install sed wget cvs subversion git-core coreutils \
     unzip texi2html texinfo libsdl1.2-dev docbook-utils gawk \
     python-pysqlite2 diffstat help2man make gcc build-essential \
     g++ desktop-file-utils chrpath libgl1-mesa-dev libglu1-mesa-dev \
     mercurial autoconf automake groff man cpio
sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
  lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
  libgl1-mesa-dev libxml2-utils xsltproc unzip

Add java6 ppa as root (on debian)

apt-get install software-properties-common python-software-properties
add-apt-repository "deb trusty main"
apt-key adv --keyserver --recv-keys EEA14886
apt-get update
apt-get install oracle-java6-installer
update-alternatives --config java
update-alternatives --config javac
#Select java-6-oracle for both java and javac

Interesting links :

I - Building mer-hybris/android

First step is to build Android minimal librairies and programs that we will added to our linux distribution in the second step. For that we are reusing mer-hybris which is based on CyanogenMod.
CyanogenMod is an Android distribution. mer-hybris add a new build target wich is a subset of a complete CyanogenMod build. It's interesting, as it downloads and build only what we need. Dalvik and all java stuff are not built for example.
hybris-mer also added few changes in android bricks. One of the most important change is patch on top of bionic. Theses changes are mandatory to get libhybris running correctly.

get repo

mkdir ~/bin
curl > ~/bin/repo
chmod a+x ~/bin/repo
export PATH=$PATH:$HOME/bin/

get sources and build

mkdir droid-hybris && cd droid-hybris
repo init -u git:// -b hybris-11.0
mkdir .repo/local_manifests

Edit the file .repo/local_manifests/hammerhead.xml and add this content :

<?xml version="1.0" encoding="UTF-8"?>
<project path="device/lge/hammerhead"
               revision="stable/cm-11.0" />
<project path="kernel/lge/hammerhead"
               revision="stable/cm-11.0" />

Sync repo :

repo sync -j8 #quite long, depends on your network bandwith
source build/
breakfast hammerhead
make hybris-hal -j8

After the build, we are going to create an archive in order to use it with yocto later

#! /bin/bash


if [[ "$1" == "--help" ]]; then
    echo "Usage: ./extract-android-hal <ANDROID_ROOT> <ANDROID_HAL_PATH> <MACHINE>(default:hammerhead)"
    if [ ! -z $1 ]; then
        echo $ANDROID_ROOT
        if [ ! -z $2 ]; then
            echo $ANDROID_HAL_PATH
            if [ ! -z $3 ]; then

pushd .
cd $ANDROID_ROOT/out/target/product/$MACHINE
tar cJf $ANDROID_HAL system root
echo "$ANDROID_HAL created"

Libhybris needs the kernel headers to work. So similarly to the previous part, an android-header package is generated and will be used with yocto later. For that purpose, the extract-header script from libhybris is used:

cd droid-hybris
chmod +x 
sh . android-headers 4 4 2
tar cJf android-headers.tar.xz android-headers/

two tarballs have been created :

  • android-hal.tar.xz
  • android-headers.tar.xz

II - Build image with Yocto

git clone
cd boot2efl

Below the 4 metas used for this build:

  • bitbake
  • meta-boot2efl our customized one.
  • meta-openembedded
  • openembedded-core

A lot of recipes are coming from meta-smartphone :
We import them to meta-boot2efl in order to keep a version for the nexus 5 which is independant on the meta-smartphone'es changes.

Copy Android parts

In src/meta-boot2efl/recipes-android/android:

mkdir android-hal
cp $DIR_ANDROID_IMAGE/system.tar.xz android-image-hammerhead
mkdir android-headers 
cp $DIR_ANDROID_HEADERS/android-headers.tar.xz android-headers

To Build:

bitbake boot2efl-image 
bitbake boot2efl-image-dev

The second image contains will embedded in the image all the tools need to build software on the phone (gcc, autotools, all the headers, ...) and tools for debug (strace, gdb, valgrind, ...)

At the end of the build, you get your images in *build/tmp-glibc/deploy/images/hammerhead*.

The interesting binaries are boot2efl-image.tar.gz and zImage-dtb-hammerhead.fastboot.

  • The zImage-dtb-hammerhead.fastboot is an bootable image for fastboot containing the kernel and dtb, the initramfs and configurations like the kernel command line.
  • The boot2efl-image.tar.gz contains the rootfs for our distro.

III - Unlock your device

In order to boot your nexus with the code build in the previous step, make sure to have adb and fastboot on your machine. abootimg is also interesting as it's used to extract and pack different binaires into a ".img"

i] enable usb debugging from developer options in settings

in android 5.1 lollipop:

  • go to _settings/about phone_
  • tap several times on _build number_
  • a notification will inform that your are now a developper
  • go to _setting/developer options_
  • add USB Debugging
  1. ii] connect the device to the computer
  2. iii] from computer: boot the device in fastboot mode:
adb reboot bootloader

iv] check the device

fastboot devices

v] unlock bootloader

fastboot oem unlock

IV - Install cyanogen recovery image

For copying your rootfs, you have to use a recovery image.
If you want to install the cyanogen recovery see the following part, if not, boot your recovery image and go the next part.

_download recovery image_:

adb reboot bootloader #(if not in fastboot mode)
fastboot flash recovery $RECOVERY.img

unplug the device
start the recovery mode with volume up and down and power key

V - Install CyanogenMod 11 on your nexus 5

You have to install CyanogenMod 11 on your nexus 5 in order to match the android binaries we build previously.

Get Cyanogen11 here:

  • Boot in recovery mode and in the menu:
  • go to install zip
  • go to 0/
#push your .zip image
adb push /data/media/0
  • Select and reboot

You have now CyanogenMod11 installed, go to the developper options to allow options to adb.

VI - Copying your rootfs

You recovery image is now booting, do:

adb root
adb shell
mkdir -p /data/media/0/linux/rootfs

On your machine:

adb push boot2efl-rootfs.tar.gz /data/media/0/linux

In adb shell:

adb shell
cd /data/media/0/linux
gunzip -f boot2efl-rootfs.tar.gz
tar xf boot2efl-rootfs.tar -C rootfs

The init of the initramfs will switch_root in the rootfs of the linux distro from this path: /data/media/0/linux/rootfs.

VII - Flash your boot image

adb reboot bootloader
fastboot flash boot zImage-dtb-hammerhead.fastboot

Your image is now flashed, you can reboot your device or if you only want to boot without flashing your image:

fastboot boot zImage-dbt-hammerhead.fastboot

VIII - Quickstart (temporary)

For now, you have to start android services by hand:

adb shell
sh /usr/bin/droid/droid-hal-startup/ &

Below some macros to set:

export EGL_PLATFORM=eglfs
export HYBRIS_EGLPLATFORM=hwcomposer
export ECORE_EVAS_ENGINE=wayland-egl
export ELM_ACCEL=opengl
export XDG_RUNTIME_DIR=/tmp

Some tests to do:

expedite -e eglfs -p 1080p-p


Last Author
Last Edited
Jan 25 2016, 3:08 AM