- Steps to boot
- 0 - Prepare your machine
- I - Building mer-hybris/android
- II - Build image with Yocto
- III - Unlock your device
- IV - Install cyanogen recovery image
- V - Install CyanogenMod 11 on your nexus 5
- VI - Copying your rootfs
- VII - Flash your boot image
- VIII - Quickstart (temporary)
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 :
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).
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 ;))
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 http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" apt-key adv --keyserver keyserver.ubuntu.com --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 :
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.
bash mkdir ~/bin curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo export PATH=$PATH:$HOME/bin/
get sources and build
bash mkdir droid-hybris && cd droid-hybris repo init -u git://github.com/mer-hybris/android.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"?> <manifest> <project path="device/lge/hammerhead" name="CyanogenMod/android_device_lge_hammerhead" revision="stable/cm-11.0" /> <project path="kernel/lge/hammerhead" name="CyanogenMod/android_kernel_lge_hammerhead" revision="stable/cm-11.0" /> </manifest>
Sync repo :
repo sync -j8 #quite long, depends on your network bandwith source build/envsetup.sh breakfast hammerhead make hybris-hal -j8
After the build, we are going to create an archive in order to use it with yocto later
cat extract-android-hal.sh #! /bin/bash ANDROID_ROOT=$(pwd) ANDROID_HAL_PATH=$(pwd) MACHINE="hammerhead" ANDROID_HAL=android-hal.tar.xz if [[ "$1" == "--help" ]]; then echo "Usage: ./extract-android-hal <ANDROID_ROOT> <ANDROID_HAL_PATH> <MACHINE>(default:hammerhead)" else if [ ! -z $1 ]; then ANDROID_ROOT=$1 echo $ANDROID_ROOT if [ ! -z $2 ]; then ANDROID_HAL_PATH=$2 echo $ANDROID_HAL_PATH if [ ! -z $3 ]; then MACHINE=$3 fi fi fi fi pushd . cd $ANDROID_ROOT/out/target/product/$MACHINE tar cJf $ANDROID_HAL system root mv $ANDROID_HAL $ANDROID_HAL_PATH echo "$ANDROID_HAL created" popd
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:
bash cd droid-hybris wget https://raw.githubusercontent.com/libhybris/libhybris/master/utils/extract-headers.sh chmod +x extract-headers.sh sh extract-headers.sh . android-headers 4 4 2 tar cJf android-headers.tar.xz android-headers/
two tarballs have been created :
bash git clone https://github.com/Openwide-Ingenierie/boot2efl.git cd boot2efl ./bootstrap
Below the 4 metas used for this build:
- meta-boot2efl our customized one.
A lot of recipes are coming from meta-smartphone : https://github.com/shr-distribution/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.
bash 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
bitbake boot2efl-image #or 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.
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"
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
- ii] connect the device to the computer
- iii] from computer: boot the device in fastboot mode:
adb reboot bootloader
fastboot oem unlock
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.
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
You have to install CyanogenMod 11 on your nexus 5 in order to match the android binaries we build previously.
- Boot in recovery mode and in the menu:
- go to install zip
- go to 0/
#push your .zip image adb push cm-11-20140805-SNAPSHOT-M9-hammerhead.zip /data/media/0
- Select cm-11-20140805-SNAPSHOT-M9-hammerhead.zip and reboot
You have now CyanogenMod11 installed, go to the developper options to allow options to adb.
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.
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
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:
test_hwcomposer expedite -e eglfs -p 1080p-p elementary_test