use libhybris with Mer
https://martinbrook.blogspot.com/2013/04/adventures-with-libhybris-and-andriod.html
THURSDAY, APRIL 18, 2013
ADVENTURES WITH LIBHYBRIS AND ANDRIOD
As promised in my tweet at the weekend I'm going to give some more details on the steps required to get Mer based gfxs apps running on top of Android graphics drivers on the Allwinner A10 based cubieboard. This work was inspired by this blog which sets out the dilemma we face when trying to port regular GNU Linux to fantastic mobile devices.
So, what do you need, well specifically a cubieboard but any Andriod device running a recent version which allows you to boot your own kernel is a potential target for Mer and Libhybris. On the software side you need an Android development environment, access to the andriod source repo for your device, patch for bionic (android's version of libc) and the libhybris library. The reason we need all this android stuff is so that we can rebuild the android bionic library with a couple of tweaks which will allow bionic and libc libraries coexist in our final build.
So first follow these instructions to setup your Android build environment, I welcome any questions on this blog post except this section, please beware this is the most frustrating things I've done in ages and would not like to re-live it. There are plenty of sources of help on the web, if you're lucky the stars will align and you will have no problems.
http://source.android.com/source/initializing.html and the installing repo section from http://source.android.com/source/downloading.html
Now you need access to the Andriod source repo for your device, I will be giving cubieboard specific instructions from now but all Andriod devices have a similar repo structure. There are a couple of pages with Andriod for cubieboard but this is the one I used, https://github.com/cubieboard/manifests. It does give some instructions on setting up a dev environment which I've not tried but you may be more successful than my attempts.
So following that page
$mkdir openbox && cd openbox
$repo init --no-repo-verify -u git://github.com/cubieboard/manifests -b cb -m jb.xml
$repo sync
gets the android code and binary blobs for the cubieboard. Now build with
$source build/envsetup.sh
$lunch 4 (note: select cubieboard option)
$make -j4
You will have time for more than lunch!
So the build should complete with some messages about creating a system.img file. Congratulations you've just built your first Android ROM.
Next we need to patch the bionic library so descend into the bionic directory and apply this patch and rebuild
$make -j4
Now we have to tar up the android system directory so we can install it on the device. This will have the patched bionic library plus all the andriod libs (EGL, GLESv2, RIL etc) which we will now be able via libhybris to access from regular glibc apps. This will be at out/target/product/cubieboard/system.
Ok so next step is to get a minimal Mer image for your device, this is another blog post in itself so I've created a basic image here. Download this and write to an sdcard and boot in the cubieboard. It should boot to xterm on hdmi.
Ok, so we don't want X to start anymore so from VT2 login root/mer and remove uxlaunch before rebooting.
$zypper -e uxlaunch
On next boot X will not start so login again from VT2.
Now we can install libhybris.
$zypper ar http://repo.merproject.org/obs/home:/sage:/libhybris/latest_armv7hl/home:sage:libhybris.repo
$zypper in libhybris
$zypper in libhybris-tests
Next copy the android system dir we made a copy of earlier to /system
Now we can test libhybris is installed correctly
$test_egl
This should give some messages but if all is well it should not crash and print 'stop'
$test_glesv2
This should show a white diamond shape filled with an animated Catherine wheel. Congrats you are now running an EGL/GLES glibc application linking to the Android EGL/GLES bionic drivers.
Next we can now run a couple of more interesting demos
$zypper in qt5-plugin-imageformat-jpeg
$zypper in qt5-plugin-platform-eglfs
$zypper in qt5-qtdeclarative-qmlscene
$zypper in qt5-qtdeclarative-import-qtquick2plugin
$zypper in qt5-qtdeclarative-import-window2
$zypper in qt5-plugin-generic-evdev
$curl -O http://qtl.me/minimer3.tar.gz
$zypper in tar
$tar -xf minimer3.tar.gz
$QT_QPA_EGLFS_DEPTH=24 qmlscene -platform eglfs mail.qml
This should give you a rotating and scaling mer logo, now lets install the Qt Cinematic Experience app which I showed in the youtube video.
$curl -O http://quitcoding.com/download/Qt5_CinematicExperience_rpi_1.0.tgz
$tar -xf
Qt5_CinematicExperience_rpi_1.0.tgz
$cd Qt5_CinematicExperience_rpi_1.0
$zypper in vim
$zypper in qt5-qtdeclarative-import-particles2
$zypper in qt5-qtquick*
$vim content/Mainview.qml - and comment out the PathAnimation part with //
$QT_QPA_EGLFS_DEPTH=24 qmlscene -platform eglfs Qt5_CinematicExperience.qml
So if you've reached this far thanks for reading and if you have used a different Android device please let us know on #mer or #libhybris.
As usual in the open source world we are always building "on the shoulders of giants" so a few thanks to the giants.
Stskeeps for his awsome contributions not just with libhybris but all things Mer and also his patience with me. Thanks to the wider Mer and libhybris teams.
On the cubieboard front thanks to the linux-sunxi team for their work on the bootloader and kernel and to mdfe for his excellent Mer adaptation packaging and awesome Jenkins buld system.
TTFN
vgrade - catch me in #mer on freenode IRC
POSTED BY MARTIN BROOK AT 2:26 PM
3 COMMENTS:
cnxsoft said...
Thanks for the instructions. However when I run test_egl, I get:
test_egl: test_egl.c:43: main: Assertion `eglChooseConfig((EGLDisplay) display, attr, &ecfg, 1, &num_config) == 1' fai.
Aborted
My loaded modules:
lsmod
Module Size Used by
cpufreq_stats 2805 0
gpio_sunxi 7257 0
i2c_algo_bit 5612 0
sunxi_dbgreg 2743 0
disp_ump 1031 0
mali_drm 2600 0
drm 208043 1 mali_drm
mali 108222 0
ump 50837 2 mali,disp_ump
sun4i_keyboard 2134 0
8192cu 599733 0
My /system directory:
ls -l /system/
total 48
drwxrwxr-x 2 mer mer 4096 Apr 21 03:38 app
drwxrwxr-x 2 mer mer 4096 Apr 21 03:47 bin
-rw-rw-r-- 1 mer mer 1881 Apr 21 02:54 build.prop
drwxrwxr-x 11 mer mer 4096 Apr 21 03:38 etc
drwxrwxr-x 2 mer mer 4096 Apr 21 03:19 fonts
drwxrwxr-x 2 mer mer 4096 Apr 21 03:38 framework
drwxrwxr-x 9 mer mer 12288 Apr 21 03:47 lib
drwxrwxr-x 3 mer mer 4096 Apr 21 03:04 tts
drwxrwxr-x 7 mer mer 4096 Apr 21 03:09 usr
drwxrwxr-x 2 mer mer 4096 Apr 21 03:47 xbin
And libhybris is installed.
So I don't see what step I may have missed, or done incorrectly. Any clues? Thanks.
cnxsoft said...
I forgot to mention that:
zypper -e uxlaunch
did not work, so I used the following instead:
zypper rm uxlaunch
Vincent Shieh said...
Hi, thanks for your sharing and I'd like to try it out on my Android device.
I have got the android source and built an image running on my device.
somehow I cannot access the the bionic patch in your post, and I found this one (http://wklej.org/id/1308620/), can you help confirm whether it's the same patch as the one you used?