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

https://www.cnx-software.com/2013/04/21/how-to-use-libhybris-and-android-gpu-libraries-with-mer-linux-on-the-cubieboard/

 

Posted on April 21, 2013 by cnxsoft - 18 Comments

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:

mkdir openbox && cd openbox repo init --no-repo-verify -u git://github.com/cubieboard/manifests -b cb -m jb.xml repo sync

1

2

3

mkdir openbox && cd openbox

repo init --no-repo-verify -u git://github.com/cubieboard/manifests -b cb -m jb.xml  

repo sync


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:

source build/envsetup.sh lunch

1

2

source build/envsetup.sh

lunch


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

make -j10

1

make -j10


The build initially failed with this error:

****************************** You have tried to change the API from what has been previously approved. To make these errors go away, you have two choices:    1) You can add "@hide" javadoc comments to the methods, etc. listed in the       errors above.    2) You can update current.txt by executing the following command:          make update-api       ^^^^^^^^^^^^^^^^^^       NO. NO. STOP BEING LAZY. SERIOUSLY.       DO NOT DO THIS in CM. THIS IS A LIE. IF YOU DO THIS I WILL HATE YOU.       USE OPTION #1.                     -Koush       To submit the revised current.txt to the main Android repository,       you will need approval. ******************************

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

******************************

You have tried to change the API from what has been previously approved.

 

To make these errors go away, you have two choices:

   1) You can add "@hide" javadoc comments to the methods, etc. listed in the

      errors above.

 

   2) You can update current.txt by executing the following command:

         make update-api

      ^^^^^^^^^^^^^^^^^^

      NO. NO. STOP BEING LAZY. SERIOUSLY.

      DO NOT DO THIS in CM. THIS IS A LIE. IF YOU DO THIS I WILL HATE YOU.

      USE OPTION #1.

                    -Koush

 

      To submit the revised current.txt to the main Android repository,

      you will need approval.

******************************


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:

cd bionic wget  http://pastie.org/pastes/7649385/download -O bionic_libhybris.patch patch -p1 < bionic_libhybris.patch cd .. make -j10

1

2

3

4

5

cd bionic

wget  http://pastie.org/pastes/7649385/download -O bionic_libhybris.patch

patch -p1 < bionic_libhybris.patch

cd ..

make -j10


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):

pushd out/target/product/cubieboard/system/ tar cjvf ../../../../../cubie_android_system.tar.bz2 . popd

1

2

3

pushd out/target/product/cubieboard/system/

tar cjvf ../../../../../cubie_android_system.tar.bz2 .

popd

 

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):

sudo dd.sh if=nemo-cubieboard-tablet-cubieboard-mer-testing-armv7hl-weekly-20130511-1516-mmcblk0p.raw of=/dev/<sd_device> bs=1M sync

1

2

sudo dd.sh if=nemo-cubieboard-tablet-cubieboard-mer-testing-armv7hl-weekly-20130511-1516-mmcblk0p.raw of=/dev/<sd_device> bs=1M

sync


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:

e2fsck -y /dev/sdc2 resize2fs  /dev/sdc2 +3300K

1

2

e2fsck -y /dev/sdc2

resize2fs  /dev/sdc2 +3300K


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:

zypper rm uxlauncher reboot

1

2

zypper rm uxlauncher

reboot


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:

scp cubie_android_system.tar.bz2 root@192.168.0.107:/

1

scp cubie_android_system.tar.bz2 root@192.168.0.107:/


and complete the install in the board:

mkdir system cd /system tar xjvf ../cubie_android_system.tar.bz2

1

2

3

mkdir system

cd /system

tar xjvf ../cubie_android_system.tar.bz2


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:

 

test_egl

1

test_egl

 

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

 

test_egl: test_egl.c:43: main: Assertion `eglChooseConfig((EGLDisplay) display, attr, &ecfg, 1, &num_config) == 1' fai. Aborted

1

2

test_egl: test_egl.c:43: main: Assertion `eglChooseConfig((EGLDisplay) display, attr, &ecfg, 1, &num_config) == 1' fai.

Aborted        

 

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:

 

test_glesv2

1

test_glesv2

 

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:

 

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 zypper in vim zypper in qt5-qtdeclarative-import-particles2 zypper in qt5-qtquick* 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

1

2

3

4

5

6

7

8

9

10

11

12

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

zypper in vim

zypper in qt5-qtdeclarative-import-particles2

zypper in qt5-qtquick*

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

 

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

Finally run the demo:

 

QT_QPA_EGLFS_DEPTH=24 qmlscene -platform eglfs Qt5_CinematicExperience.qml

1

QT_QPA_EGLFS_DEPTH=24 qmlscene -platform eglfs Qt5_CinematicExperience.qml

 

Et voila!

 

Support CNX Software - Donate via PayPal or become a Patron on Patreon 

Related posts:

  1. Libhybris Let You Use Android Drivers & HW Libraries in Linux
  2. $49 Cubieboard: AllWinner A10 Open Hardware Development Board
  3. Cubieboard Unboxing and Quick Start Guide
  4. Headless Connected Oscilloscope based on Cubieboard or Beaglebone
  5. Wandboard Releases Updated Android and Ubuntu Linux Images and Source Code

CategoriesAllwinner A-Series, Android, Graphics, Linux, Video TagsAndroid, cubieboard, how-to, libhybris, Linux, mer, qt, tutorial

 

18

Leave a Reply

Connect with:

Facebook Twitter

avatar

18

0

0

 

9

maribuwickwirePVLuc Verhaegenvgrade

  Subscribe  

newest oldest most voted

Marius Cirsta

Member

Marius Cirsta

 

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

0  Reply

5 years ago

misko

Guest

misko

 

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

0  Reply

5 years ago

cnxsoft

Author

cnxsoft

 

@misko
In this setup he’s using a standard Linux kernel and drivers with the Android libraries.
I’ve checked, and confirmed, the rootfs is armhf, and the Android libs are armel, I’m not sure what kind of magic happens with libhybris.

0  Reply

5 years ago

m][sko

Guest

m][sko

 

you should try another board ?

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

0  Reply

5 years ago

The Cageybee

Guest

The Cageybee

 

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. ?

0  Reply

5 years ago

vgrade

Guest

vgrade

 

@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

0  Reply

5 years ago

Luc Verhaegen

Guest

Luc Verhaegen

 

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

0  Reply

5 years ago

cnxsoft

Author

cnxsoft

 

@vgrade
I also have a Mele, I guess I just need to change script.bin and the bootloader, right?

@Luc Verhaegen
Just for experimentation.

0  Reply

5 years ago

PV

Guest

PV

 

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 ?

0  Reply

5 years ago

cnxsoft

Author

cnxsoft

 

@PV
It’s still not working for me (I haven’t fixed my Cubie), as per the error message in this blog. I haven’t seen your error before. Have you tried to follow the advice from the log?:

Try: zypper install -C “debuginfo(build-id)=4b82b0a4d8b1e617453c92539129e9ea245f4124”

0  Reply

5 years ago

PV

Guest

PV

 

@cnxsoft

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.

0  Reply

5 years ago

cnxsoft

Author

cnxsoft

 

@PV
I’ve tried (and failed) to remove the microSD card slot from my Cubieboard with a soldering iron and desoldering wire, but it seems quite challenging for me.

You’d better check the original article, and ask Martin Brook directly. I’ve probably done a small mistake in this tutorial.

0  Reply

5 years ago

wickwire

Guest

wickwire

 

“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

0  Reply

5 years ago

cnxsoft

Author

cnxsoft

 

@wickwire
Sorry, I’ve updated the post.
The latest image is available at ftp://5.9.162.110/nemo/cubieboard/tablet/cubieboard/mer/testing/armv7hl/weekly/

0  Reply

5 years ago

wickwire

Guest

wickwire

 

@cnxsoft

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.

0  Reply

5 years ago

wickwire

Guest

wickwire

 

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.

0  Reply

5 years ago

maribu

Guest

maribu

 

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

0  Reply

5 years ago

maribu

Guest

maribu

 

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

0  Reply

5 years ago

### 回答1: 无法打开一些 GPU 库。如果您想使用 GPU,请确保上面提到的This error message indicates that some GPU libraries required for TensorFlow are missing or not properly installed on your system. If you want to use GPU for TensorFlow, you need to install these libraries properly. The error message also provides a link to the official TensorFlow website with a guide on how to download and set up the required libraries. You should follow the instructions in this guide to ensure that the required libraries are installed correctly. Note that using GPU for TensorFlow can significantly speed up the training process, especially for large models and datasets. However, it requires a compatible GPU and proper installation of the necessary software and drivers. ### 回答2: 这个错误提示意味着无法加载一些GPU库。如果想使用GPU,请确保上述缺失的库已经正确安装。您可以根据https://www.tensorflow.org/install/gpu上的指南下载和设置所需的库文件。 Tensorflow是一种广泛使用的机器学习框架,它支持许多硬件架构,包括CPU和GPUGPU在深度学习中表现出色,可以大大加速训练速度,也降低了训练成本。因此,使用GPU进行机器学习是很重要的。 在使用Tensorflow时,如果您想要使用GPU,那么您的计算机需要具有对应的GPU和驱动程序,并安装相关的CUDA和cuDNN等库。安装这些库可能有些困难,因为库文件之间可能存在依赖关系,需要进行一些系统配置和编译。 为了避免该错误,您需要按照https://www.tensorflow.org/install/gpu的指南安装必要的库文件。该指南分为两个部分,第一部分介绍了如何安装CUDA,第二部分介绍了如何安装cuDNN。这些库的安装过程比较繁琐,但是按照指南中的步骤一步一步进行,可以确保正确安装并避免出错。 总之,如果您想在Tensorflow中使用GPU,请确保安装了所需的库文件。如果您没有安装这些文件,那么您将不得不使用CPU进行计算,这将导致训练速度显著降低。 ### 回答3: 这是一个关于TensorFlow使用GPU时遇到的错误提示信息。其中提示说无法打开一些GPU库,要求检查这些缺失的库是否已经正确地安装,如果想要使用GPU,则需要按照https://www.tensorflow.org/install/gpu的指南下载和设置必需的库。 首先,我们需要了解什么是GPUGPU即图形处理器,是一种高效的并行处理器。与CPU相比,GPU在进行并行计算时有着更快的速度和更高的能力。因此,使用GPU可以在TensorFlow的模型训练和推理中获得较好的性能。 那么,当我们使用TensorFlow时,为什么会遇到无法打开GPU库的问题呢?答案是因为在使用GPU之前,需要确保系统中已经安装了正确的GPU驱动和CUDA(Compute Unified Device Architecture,计算统一设备架构)工具包。这些组件是使用GPU进行TensorFlow计算所必需的。此外,还需要安装cuDNN(CUDA Deep Neural Network library,CUDA深度神经网络库)等附加的库。 回到提示信息中,它提醒我们检查缺失的库是否已经正确地安装,如果没有安装,则需要按照指南下载和设置必需的库。具体来说,我们需要遵循以下步骤: 1. 检查GPU驱动程序是否已正确安装和配置:这通常需要查看GPU制造商的网站以获取相应的驱动程序,并按照说明进行安装和配置。注意,必须确切地安装与GPU、操作系统和CUDA版本相匹配的驱动程序。 2. 安装CUDA工具包:可以从NVIDIA的网站上下载CUDA工具包,并按照说明进行安装。CUDA toolkit的版本也必须与GPU和驱动程序的版本相匹配。 3. 安装cuDNN库:可以从NVIDIA的开发者网站上下载cuDNN库,按照说明进行安装。cuDNN库的版本也必须与CUDA的版本相匹配。 以上是安装和配置GPU所必需的步骤。一旦这些步骤完成,我们就可以再次尝试使用TensorFlow,以查看问题是否已经解决。如果遇到其他问题,则可能需要进一步调试和设置。 总之,使用GPU可以加速TensorFlow的计算,但是必须先安装正确的驱动、工具包和库,才能使用GPU进行计算。如果遇到无法打开GPU库的情况,请按照提示信息和指南进行检查和设置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值