How to Use Libhybris and Android GPU Libraries with Mer (Linux) on the Cubieboard

You may have heard about libhybris, a library that cleverly loads Android HW adaptations and convert calls from bionic to glibc. One of the greatest achievement of this library is to allow Android GPU drivers to be used with Linux, and is notably used by Canonical, although they did not write it, for Ubuntu 14.04 which will be compatible with any recent Android smartphones or tablets.

One way to get started with libhybris is to port a device to Ubuntu Touch, but this may take a while. However, I’ve found a faster and easier way to play with libhybris thanks to Martin Brook (vgrade) who wrote a tutorial on how to use libhybris with Mer on the Cubieboard. Mer is an open source mobile Linux distribution powered by Qt/QML and HTML5, that’s born from the ashes of Meego, and is now used in the upcoming Sailfish OS.

Qt5 Cinematic Experienced Rendered at 25 fps in Cubieboard via Android GPU Drivers in Linux Thanks to libhybris
Qt5 Cinematic Experienced Rendered at 25 fps in Cubieboard via Android GPU Drivers in Linux Thanks to libhybris

You’ll need to follow 4 main steps:

  • Build Android
  • Build a minimal Mer image
  • Install Libhybris
  • Run demos

I’ll skip the Mer image build since Martin has provided a binary image. I’ll use a build machine running Ubuntu 12.04.2 LTS. You should make sure the build environment is setup correctly, you’ve installed repo, and that it’s in your path. I’ll use the Cubieboard (1GB RAM), but you may want to try other hardware platform, or Linux distribution as the instructions should be similar.

Build Android for the Cubieboard

This is basically following the instructions provided here. First let’s code Android Jelly Bean (CyanogenMod) source code:


repo sync may take quite a while depending on your Internet connection. It took 10 hours, after several attempts over three days… Once this is done, we’ll need to configure the build for the Cubieboard:


Select Cubieboard (#4), and start the build:


The build initially failed with this error:


So I shamelessly typed “make update-api” to automatically update current.txt, and continued the build with “make -j10”. The build may also take quite a while depending on your computer performance and available RAM. This step was much faster than repo sync in my case, as it just took about 45 minutes in total.

The Android build is now completed, but we need still to patch Bionic library, and rebuild:


Now let’s tar Android’s system directory as we’ll need to copy the will have the patched bionic library plus all the android libs (EGL, GLESv2, RIL etc):

Installing and Running Mer

Since we don’t build the image ourself, this step is rather easy, as we just need to download the image, and dump it to a micro SD card.

wget ftp://5.9.162.110/nemo/cubieboard/tablet/cubieboard/mer/testing/armv7hl/weekly/nemo-cubieboard-tablet-cubieboard-mer-testing-armv7hl-weekly-20130511-1516-mmcblk0p.raw.bz2
bzip2 -d nemo-cubieboard-tablet-cubieboard-mer-testing-armv7hl-weekly-20130511-1516-mmcblk0p.raw.bz2

Burn the image to a microSD card (4GB or greater):


Where you need to replace <sd_device> by your actual SD card device such as “sdc”.

My 4GB microSD is slightly smaller than the image provided, so dd failed at the very end. But you can usually run the following 2 commands on the last partition (in this case ext4) in order to resize the partition, and fix any potential boot problems:


Interestingly, this time those commands failed, but I still inserted the microSD in my Cubieboard, and I was able to login successfully into Mer via the serial console as root (password: mer). You should also have access a terminal on the HDMI monitor.

We don’t want X to start anymore, so let’s disable it and restart the Cubieboard:


If you’re using HDMI console, switch to VT2 (Ctrl+Alt+F2) before running the command.

Installing libhybris and Android system folder

Let’s log-in again via the serial console, or via VT2 on the HDMI monitor if this works for you, and 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

You may want to enlarge your terminal for the steps above, as the text goes over the window, and you have to answer some questions for the installation. The next step is to install Android’s system files to /system in the Cubieboard. Copy the files from the Linux PC to the Cubieboard:


and complete the install in the board:


The installation is now complete and it’s time to try it out.

Graphics Demos

To test whether libhybris is correctly installed run the following:

The only problem is that it did not work exactly as expected:

After a reboot, Cubieboard decided to boot Android from flash, so I tried to remove and re-insert the micro SD, and noooooooooo! The micro SD socket let me down and refuses to lock the card in place, so I’ll have to replace the slot which will take me few weeks since I have to order the thing.

So I count on you to let me know what has gone wrong. Thanks 🙂

Let’s carry on as if everything worked just fine, and run the next demo:

This should display a white diamond shape filled with an animated Catherine wheel.

Martin also has instructions for several other demos, but the most interesting one (we have a video), is Qt5 Cinematic Experience that you can install in the board as follows:

Now edit content/Mainview.qml with vim, and comment out the PathAnimation part.

Finally run the demo:

Et voila!

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX Rockchip RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
18 Comments
oldest
newest
Marius
11 years ago

This is really interesting and I think I’m going to try it out sometime. I’m even more excited about LIMA though.

misko
11 years ago

I don’t understand one think Android is always build as softfp (drivers same)
and rest of os run as armv7hl (hard fp)
it looks like libhybrids solve this part too right?

there is some hack for NOKIA N9 (all hardfp libs) that is able to run softfp software for example angly birds star wars

m][sko
11 years ago

you should try another board 🙂

can you try to set up 50,60 Hz refresh rate
it it still works fine 🙂

The Cageybee
The Cageybee
11 years ago

Doh. I was hoping that all that would be needed would be to copy a few files from and Android release for the target device over to Linux and et voila, the library do its work. Life’s never that simple though. 🙁

vgrade
vgrade
11 years ago

@m][sko

I’ll try on my mele A1000 soon.

Also video mode on TV was 12×7 at 50Hz, not sure yet why the framerate output was showing 25Hz

Luc Verhaegen
Luc Verhaegen
11 years ago

Why even use libhybris on the cubieboard? We have proper armhf binaries for both X11 and fb for sunxi.

PV
PV
11 years ago

Hi Jean,

Thanks for gr8 tut.
I follow the instruction but when I run on device egl_test it crash with sigfault.

here is log http://ais.im/test_glesv2.log

Any suggestion on issue. or is there any ready to use image ?

PV
PV
11 years ago

Aah sorry for late reply. I was expecting a email notification :).

Yes I did try that. In fact with some further test I realise that error is same no matter I patch or not.

I have also ensure that it’s patched properly but still situation same.

wickwire
wickwire
11 years ago

“Installing and Running Mer

Since we don’t build the image ourself, this step is rather easy, as we just need to download the image, and dump it to a micro SD card.

wget nemo-cubieboard-tablet-cubieboard-mer-testing-armv7hl-weekly-20130413-1612-mmcblk0p.raw.bz2

Proper URL please, thanks

wickwire
wickwire
11 years ago

Hi, many thanks for the guide. I have a cubieboard, think I’ll have a look at Mer before anything else, and then move on to your guide!

Thank you once again.

wickwire
wickwire
11 years ago

I’ve managed to play the Qt5_CinematicExperience_rpi_1.0 example using qmlscene but something curious is happening:

– I have no text being displayed, only graphical elements and images
– near the top left corner of the screen I’m getting an intermittent cursor blinking
– qmlscene crashes after a while and won’t allow me to re-run the example – only works after reboot

I also tried the minimer example, with that I get the rotating/scaling wallpaper.

maribu
maribu
11 years ago

Hi, there!

Thanks for the guide. I struggled for a while with compiling the android image (I had to downgrade jdk, python and gnu make and still have some errors building it) and now decided to ask for help. If someone who manged to build the android image could provide the tar-archive of the /system folder (e. g. via ubuntu one, dropbox, …) you would save me hours of work. (And maybe others are interested in this, too?)

Thanks in advance!

Regards,
maribu

maribu
maribu
11 years ago

Hi, again!

It looks like I got it working. Here is my /system folder of the output: http://ubuntuone.com/64JdjdWVq9F2E5p6gMQE1J I don’t have my Cubieboard at hands, so I haven’t tested it right now.

Another interesting thing you can do with libhybris is using the android CedarX driver, which is said to work better than the native glibc version. Have a look here: http://linux-sunxi.org/CedarX/libve

I also like to provide the extracted headers (using lutils/extranct-headers.sh from https://github.com/libhybris/libhybris) from the android Cubieboard source: http://ubuntuone.com/6PwRhU0CN1MZFrBUNJFnHL

Regards,
maribu

Boardcon Rockchip RK3588S SBC with 8K, WiFI 6, 4G LTE, NVME SSD, HDMI 2.1...