Changes between Version 1 and Version 2 of Yocto/qt


Ignore:
Timestamp:
02/08/2018 07:21:05 AM (7 years ago)
Author:
Tim Harvey
Comment:

updated for Yocto 2.3 qtglviddemo

Legend:

Unmodified
Added
Removed
Modified
  • Yocto/qt

    v1 v2  
    1 {{{#!html
    2           <div id="wikipage" class="trac-content"><p>
    3 </p><div class="wiki-toc">
    4 <ol>
    5   <li>
    6     <a href="#QtforEmbedded">Qt for Embedded</a>
    7     <ol>
    8       <li>
    9         <a href="#InstructionsforHelloWorldQTE4.8.6onYocto1.7">Instructions for Hello World QTE 4.8.6 on Yocto 1.7</a>
    10         <ol>
    11           <li>
    12             <a href="#DownloadPre-BuiltQTEImageandSDK">Download Pre-Built QTE Image and SDK</a>
    13           </li>
    14           <li>
    15             <a href="#BuildingtheQTEImage">Building the QTE Image</a>
    16           </li>
    17           <li>
    18             <a href="#CreatingtheHelloWorldProgram">Creating the Hello World Program</a>
    19           </li>
    20         </ol>
    21       </li>
    22     </ol>
    23   </li>
    24 </ol>
    25 </div><p>
    26 </p>
    27 <h1 id="QtforEmbedded">Qt for Embedded</h1>
    28 <p>
    29 Qt for Embedded Linux is a C++ framework for GUI and application development for embedded devices.
    30 </p>
    31 <h2 id="InstructionsforHelloWorldQTE4.8.6onYocto1.7">Instructions for Hello World QTE 4.8.6 on Yocto 1.7</h2>
    32 <p>
    33 <strong>Note these instructions were made using Yocto 1.7 which may no longer be the latest</strong>
    34 </p>
    35 <h3 id="DownloadPre-BuiltQTEImageandSDK">Download Pre-Built QTE Image and SDK</h3>
    36 <p>
    37 Download the following files here:
    38 </p>
    39 <ul><li><a class="ext-link" href="http://blog.gateworks.com/?wpdmpro=gateworks-image-qte-ventana-tar-bz2"><span class="icon">​</span>QTE rootfs tarball</a> - <a class="wiki" href="/wiki/Yocto/Building#InstallingonRemovablestorage:mSATAUSBuSDSD">SD Card flashing instructions here</a>
    40 </li><li><a class="ext-link" href="http://blog.gateworks.com/?wpdmpro=poky-glibc-x86_64-meta-toolchain-qte-cortexa9hf-vfp-neon-toolchain-qte-1-7-2-sh"><span class="icon">​</span>QTE SDK File</a>
    41 </li></ul><h3 id="BuildingtheQTEImage">Building the QTE Image</h3>
    42 <p>
    43 The steps below first require building Yocto from source documented <a class="wiki" href="/wiki/Yocto/Building">here</a>
    44 </p>
    45 <p>
    46 Then, after building, to include QTE 4.8.6, we have modified a base Gateworks recipe file.
    47 </p>
    48 <p>
    49 Below are the lines we have added:
    50 </p>
    51 <pre class="wiki">inherit qt4e
     1[[PageOutline]]
    522
    53 IMAGE_INSTALL += "${QT4EDEPENDS}"
     3The following information refers to the Gateworks Yocto 2.3 (aka pyro) BSP
     4 
     5= Qt for Embedded on Yocto =
     6Since the Qt 5.0 release, Qt no longer contains its own window system (QWS) implementation. For single-process use cases, the Qt Platform Abstraction is a superior solution. Multiple graphical processes can be supported through Wayland.
    547
    55 IMAGE_INSTALL += "\
    56 qt-in-industrial-embedded-smarthome-e \
    57 "
    58 </pre><ul><li>Create a copy of a Gateworks recipe file in /sources/meta-gateworks/recipes-core/images/ and call it gateworks-image-qte.bb (or download attached recipe file and place in /sources/meta-gateworks/recipes-core/images/)
    59 </li></ul><ul><li>Create Image and SDK
    60 <ul><li>Create qte supported image: <tt>bitbake gateworks-image-qte</tt>
    61 </li><li>Create SDK: <tt>bitbake -cpopulate_sdk gateworks-image-qte</tt>
    62 </li><li>Download SDK .sh file and follow <a class="wiki" href="/wiki/Yocto/SDK">SDK instructions</a>
    63 </li></ul></li></ul><h3 id="CreatingtheHelloWorldProgram">Creating the Hello World Program</h3>
    64 <ul><li>Create a new directory and place in it a main.cpp with example code
    65 <ul><li>
    66 <pre class="wiki">#include &lt;QApplication&gt;
    67 #include &lt;QPushButton&gt;
    68 #include &lt;QWidget&gt;
    69  
    70 int main(int argc, char **argv)
    71 {
    72  QApplication app (argc, argv);
    73  QPushButton button ("Hello world !");
    74  button.showFullScreen();
    75  
    76  return app.exec();
    77 }
     8There are multiple platform plugins that are potentially usable on Embedded Linux systems: EGLFS, LinuxFB, DirectFB, Wayland. The availability of these depend on the configuration of Qt. On many boards eglfs is chosen as the default one. If the default is not suitable, the QT_QPA_PLATFORM environment variable parameter can be used to request another plugin. Alternatively, for quick tests, the -platform command-line can be used with the same syntax.
    789
    79 </pre></li></ul></li><li>Use qmake to create a project file (creates .pro file named off directory you are in using the source files in the directory)
    80 <ul><li><tt>qmake -project</tt>
    81 </li></ul></li><li>Use qmake to create makefile using -spec (which uses the project file from the previous step and a mkspecs config directory from the SDK)
    82 <ul><li><tt>qmake -spec $SDKTARGETSYSROOT/usr/share/qtopia/mkspecs/qws/linux-arm-gnueabi-g++</tt>
    83 </li></ul></li><li>You must also tweak Makefile
    84 <ul><li>Comment out CC and CXX and STRIP
    85 </li><li>Set: <tt>LINK= $(CXX)</tt>
    86 </li><li>Modify AR line to say: <tt> arm-none-linux-gnueabi-ar cqs</tt>
    87 </li><li>The total and final lines that are changed in the Makefile:
    88 <pre class="wiki">#CC            = arm-none-linux-gnueabi-gcc
    89 #CXX           = arm-none-linux-gnueabi-g++
    90 #STRIP         = arm-none-linux-gnueabi-strip
    91 AR            = arm-poky-linux-gnueabi-ar cqs
    92 LINK          = $(CXX)
    93 </pre></li></ul></li><li>Run make
    94 <ul><li><tt>make</tt>
    95 </li><li>Find binary output
    96 <pre class="wiki">ryan@ryan-Inspiron-660:~/Downloads/helloworld$ file helloworld
    97 helloworld: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=34e0476f18f251ac85b72131957382f0bd00faeb, not stripped
    98 </pre></li></ul></li><li>Copy application to the Ventana board via a method like wget
    99 <ul><li>chmod the application to be executable
    100 </li></ul></li><li>Run the application
    101 <ul><li><tt> ./helloworld -qws </tt>
    102 </li></ul></li></ul
     10EGLFS is a platform plugin for running Qt5 applications on top of EGL and OpenGL ES 2.0 without an actual windowing system (like X11 or Wayland). In addition to Qt Quick 2 and native OpenGL applications, it supports software-rendered windows (for example QWidget) too. In the latter case the widgets' contents are rendered using the CPU into images, which are then uploaded into textures and composited by the plugin.
     11
     12This is the recommended plugin for modern Embedded Linux devices that include a GPU.
     13
     14EGLFS forces the first top-level window (be it either a QWidget or a QQuickView) to become fullscreen. This window is also chosen to be the root widget window into which all other top-level widgets (for example dialogs, popup menus or combobox dropdowns) are composited. This is necessary because with EGLFS there is always exactly one native window and EGL window surface, and these belong to the widget or window that is created first. This approach works well when there is a main window that exists for the entire lifetime of the application and all other widgets are either non top-levels or are created afterwards, once the main window is shown.
     15
     16For Ventana boards based on the i.MX6 SoC in order to build Qt5 for a specific platform plugin, you must alter the {{{DISTRO_FEATURES}}} variable and remove the backends you don't want. This is typically done in build/local.conf (Note the mandatory space around the options inside the quotes):
     17 * to build for EGLFS (ie no window system):
     18{{{
     19DISTRO_FEATURES_remove = " wayland x11 "
    10320}}}
     21 * for X11 (ie for building an X11 based image like 'gateworks-image-gui')
     22{{{
     23DISTRO_FEATURES_remove = " wayland "
     24}}}
     25 * for Wayland (supports X11 clients but uses Wayland compositor)
     26{{{
     27DISTRO_FEATURES_remove = " x11 "
     28}}}
     29
     30
     31[=#qtglviddemo]
     32== QtGLVidDemo Qt5 Demo Application ==
     33The {{{qtglvviddemo}}} is a GPLv3 licensed Qt5 demo application for rendering videos on 3D objects integrated in !QtQuick 2.
     34
     35The qtglviddemo demo application shows how to render video frames on 3D objects, which in turn are integrated in a QML and !QtQuick 2 based user interface.
     36
     37The video frames are produced by the GStreamer !GstPlayer library. They are uploaded into OpenGL textures, which are then used on 3D meshes. These meshes are rendered in QQuickFramebufferObject !QtQuick 2 items, and the items are composed by a !PathView on screen. The 3D objects can be rotated with the mouse or with touch events. UI controls allow for adjusting several parameters such as opacity, scale, mesh type, etc. and for adding/removing objects. The video frames can come from local video files, network streams, or Video4Linux2 based video capture devices.
     38
     39Subtitles can be shown on screen. The subtitles can come either from the playing media itself, or from a FIFO if one is enabled in the configuration file.
     40
     41There is also special support built in for Vivante GPUs, specifically their direct texture extensions. This makes it possible to render high resolution videos smoothly on i.MX6 machines for example.
     42
     43Dependencies:
     44 * Qt 5.7 or newer
     45 * GStreamer 1.10 or newer
     46 * libudev
     47
     48=== Source ===
     49The {{{qtglviddemo}}} application was written as both a demo application and example Qt5 application source demonstrating video rendering on a Gateworks IMX6 board. The project was commissioned by Gateworks and authorred by Carlos Rafael Giani <dv@pseudoterminal.org>. Carlos is also the author of the [https://github.com/dv1/gstreamer-imx gstreamer-imx], a set of GStreamer 1.0 plugins for i.MX6 based products using Freescale's kernel drivers.
     50
     51The source and documentation is available on github:
     52 * https://github.com/dv1/qtglviddemo
     53
     54
     55=== Building for Ventana ===
     56While the {{{qtglviddemo}}} package can be built from the Gateworks Yocto 2.3 BSP you can also build an entire bootable filesystem image.
     57
     58There are a couple of choices:
     59 * X11 based image {{{gateworks-image-gui}}}:
     60  - includes the matchbox window manager and a host of other X11 based demos
     61  - requires building the enitre BSP with 'DISTRO_FEATURES_remove = " wayland "' defined in {{{build/local.conf}}}
     62 * EGLFS based stand-alone app {{{qtglviddemo-image}}} recipe.
     63  - stand-alone application rendering directly to hardware via EGLFS without any window manager
     64  - requires building the enitre BSP with 'DISTRO_FEATURES_remove = " wayland x11 "' defined in {{{build/local.conf}}}
     65
     66For example to build Yocto with the EGLFS backend as you would do with a stand-alone application managing the entire screen:
     67{{{#!bash
     68echo 'DISTRO_FEATURES_remove = " wayland x11 "' >> build/local.conf
     69bitbake qtglviddemo-image
     70}}}
     71 * takes about 2 hours or less to build on a modern machine
     72 * if you have previously built without removing {{{wayland}}} or {{{x11}}} you need to completely rebuild (ie 'rm -rf tmp')