ODROID-XU3

From Qt Wiki
Jump to navigation Jump to search

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

The ODROID-XU3 is an ARM development board created by HardKernel

HardKernel provides both Android and Ubuntu Linux images for use with the ODROID-XU3. Both environments can be used to run and develop Qt 5 applicaitons.

Qt for Android

To use Android as a development platform, you need to obtain an Android image from HardKernel and flash it to either the eMMC or MicroSD media.

Once the device boots into Android, you treat it like any other Android Mobile/Table and deploy to it using the Qt for Android ARMv7 kit.

Qt for Embedded Linux

To use Linux as a develpment platform, you need to obtain a Ubuntu image from HardKernel and flash it to either the eMMC or MicroSD media.

There are no pre-built versions of Qt for ODROID-XU3 so you need to build Qt for source. It is possible to build Qt on the ODROID-XU3 but it can be impractical because of long build times and limited file system space. Regardless of where you build Qt, the ODORID-XU3 will need to install the development dependencies.

Before you build you will need to setup the toolchain and sysroot. For the toolchain you will need to obtain a ARM cross compile toolchain configured for gnueabihf. I used the Raspberry Pi toolchain which I copied into the folder ~/Code/Odroid/toolchain

To provide the sysroot, you need to use the system image installed on the ODROID-XU3. This is the reason for installing the extra Qt development dependencies on the ODROID-XU3 itself. There are a couple of ways to do this. One is to mount the ODROID-XU3's SD Card or eMMC on your development machine and either make a copy or a link to ~/Code/Odroid/sysroot

Another method is to mount the live system image over ssh using sshfs. To use this method install sshfs on your development machine, an make sure that you have pushed your ssh keys to the ODROID-XU3:

#assuming Ubuntu/debian
sudo apt-get install sshfs
ssh-copy-id odroid@<insert ip or hostname of ODROID-XU3>
ssh-copy-id root@<insert ip or hostname of ODROID-XU3>
mkdir -p ~/Code/Odroid/sysroot
sshfs root@<insert ip or hostname of ODROID-XU3>:/ ~/Code/Odroid/sysroot
 

Just bear in mind that you use this method you will need to maintain a network connection to the device while building anything. If however you use the SD card you will not be able to run the system while building software, or if you make a copy, you will need to update the copy each time you install new development libs on the device. Each method has its own compromises. I choose to use the sshfs method because then I'm easily able to deploy software to the live device and sysroot at the same time with just make install.

However you choose to map your system image as a sysroot, a bit of preparation is still required before it can be used. Any links in the system image's library folders need to be converted from absolute paths to relative ones. This can be done by using this script.

cd ~/Code/Odroid/
wget https://gist.githubusercontent.com/nezticle/affaee3d3905489c95f7/raw/3190bcb3ac6e9173fcfd4f305a551dc767eb1666/fixQualifiedLibraryPaths.sh
chmod a+x fixQualifiedLibraryPaths.sh
./fixQualifiedLibraryPaths.sh ./sysroot arm-linux-gnueabihf
 

Now the sysroot can be used for cross-compiling.

Building Qt

First you will need the Qt source code from at least Qt 5.5 (which at this point is only available from git). Assuming you have your Qt 5 source code in ~/Code/qt5, here is how you would configure and build qt:

mkdir ~/Code/Odroid/qt5-build
cd ~/Code/Odroid/qt5-build

#configure Qt
~/Code/qt5/configure -commercial -confirm-license -debug -developer-build -prefix /usr/local -hostprefix ~/Code/Odroid/qt5-build \
-extprefix ~/Code/Odroid/sysroot/usr/local -device odroid-xu3 -device-option CROSS_COMPILE=~/Code/Odroid/toolchain/bin/arm-linux-gnueabihf- \
-sysroot ~/Code/Odroid/sysroot -nomake tests -no-pch -skip qtwebkit -opengl es2 -xcb -eglfs -qpa xcb

#build Qt
make -j10

#install Qt
make install
 

Now if you were using the sshfs method for getting a sysroot, when you ran make install the Qt library should already by available for use on the device in /usr/local. If not then you will need to copy Qt libraries and plugins manually to your device from your local sysroot.

The Qt development files/tools will be located in ~/Code/Odroid/qt5-build

Testing out Examples

If you use the configure line I provided above unmodified, then the qt examples should have been built and deployed to the device. You can test them out from the device by running them in /usr/local/examples. By default they will use the XCB platform plugin and run in X11.

Qt Creator

Doing Qt application development for ODROID-XU3 from Qt Creator is as simple as creating a new kit for ODROID-XU3 and filling in the details of where the toolchain and new qmake binaries are located. All of these things should be in the ~/Code/Odroid/ folder we created and populated above. Once this is done and a new "device" target is defined, it should be possible to build and deploy applications to your Odroid.

X11 vs fbdev

By default Qt will be built for the ODROID-XU3 to run in the X11 environment provided by Ubuntu. You may however wish to run directly to the framebuffer device via EGL rather than through X11. The Ubuntu image provided by HardKernel does not provide the necessary Mali GPU drivers needed to use OpenGL through "fbdev". It is however possible to install them through the following process:

#Download fbdev mali drivers
wget http://malideveloper.arm.com/downloads/drivers/binary/r4p0-02rel0/mali-t62x_r4p0-02rel0_linux_1+fbdev.tar.gz

#extract and install in /usr/lib/arm-linux-gnueabihf/fbdev-egl
tar -xzf mali-t62x_r4p0-02rel0_linux_1+fbdev.tar.gz
sudo mv fbdev /usr/lib/arm-linux-gnueabihf/fbdev-egl
sudo chown -R root:root /usr/lib/arm-linux-gnueabihf/fbdev-egl

#install an ld.so.conf
echo "/usr/lib/arm-linux-gnueabihf/fbdev-egl" | sudo tee /usr/lib/arm-linux-gnueabihf/fbdev-egl/ld.so.conf > /dev/null
sudo chmod 644 /usr/lib/arm-linux-gnueabihf/fbdev-egl/*

#include links for libEGL.so.1 and libGLESv2.so.2
sudo ln -s /usr/lib/arm-linux-gnueabihf/fbdev-egl/libEGL.so /usr/lib/arm-linux-gnueabihf/fbdev-egl/libEGL.so.1
sudo ln -s /usr/lib/arm-linux-gnueabihf/fbdev-egl/libGLESv2.so /usr/lib/arm-linux-gnueabihf/fbdev-egl/libGLESv2.so.2

#Update-alternatives
sudo update-alternatives --install /etc/ld.so.conf.d/arm-linux-gnueabihf_EGL.conf arm-linux-gnueabihf_egl_conf /usr/lib/arm-linux-gnueabihf/fbdev-egl/ld.so.conf 550

#To switch between mali-egl and fbdev-egl:
sudo update-alternatives --config arm-linux-gnueabihf_egl_conf
#select the EGL provider then update the links
sudo ldconfig
 

Now to start a Qt Application with EGLFS instead of XCB you just need to pass the argument "-platform eglfs" when you start your application, or set the environment variable QT_QPA_PLATFORM=eglfs

Performance and issues with OpenGL

Qt 5.5 will have a number of fixes and workarounds that attempt to correct some of the issues with the drivers. This is tracked under https://bugreports.qt.io/browse/QTBUG-45106

The current drivers, especially the fbdev one, are known to be _slow_. This is likely caused by some missing integration work at the end of the pipeline. See http://community.arm.com/thread/7440

OpenCL

The board supports OpenCL 1.1, with CL-GL interop. This has been tested with the fbdev drivers.

To get it up and running, get the standard OpenCL 1.1 headers from Khronos (or from some other vendor's SDK) as they do not seem to be present in the sysroot by default. You will then have to symlink /usr/lib/arm-linux-gnueabihf/fbdev-egl/libmali.so (note: _not_ libOpenCL.so which seems to be some empty shim) to /usr/lib/libOpenCL.so. Once this is done, you should be able to build CL apps.