Developing Qt5 applications natively on Wind River Linux – WIND

Posted: June 1, 2020 at 3:56 am

By Nathan Hartman

Wind River Linux provides the technologies essential to building a flexible, stable, and secure platform for your embedded devices.

Based on OpenEmbedded releases from the Yocto Project, it is designed to let you customize your platform to include only the packages and features you need. Powered by bitbake, it provides the ability to build an entire Linux distribution from source by following repeatable recipes. This is really powerful, but can be foreign to application developers that already have a workflow they are comfortable with.

Developers building graphical user interfaces (GUI) have their own set of tools that they rely on. Often they prefer to use an Integrated Development Environment (IDE) tailored to the language and frameworks they are working with. Typically this IDE and the tools it uses are running natively on the same platform they are building for.

Fortunately, these developers can still do this on Wind River Linux. This tutorial describes building Wind River Linux with the GCC toolchain and Qt Creator included to enable native application development.

Building the entire platform has a few simple requirements to get started. Many Linux distributions are self-hosted meaning you can only build the next version of the distribution with the previous release.

Wind River Linux supports a wide variety of hosts. The official supported list of hosts is below, but many newer releases have been tested and known to work.

For details on necessary Linux Host System Libraries and Executables please refer to the documentation.

For example, on Ubuntu systems the following packages must be installed:

In addition, the deployment steps require root or sudo access for deploying to an SD Card or USB flash device.

Lastly, this tutorial has been validated for the Raspberry Pi 4 and Intel NUC devices (NUC5i3MYBE, NUC6i7KYK, NUC7i5DNK). These instructions should work on other devices, however we tested these devices specifically to ensure that the hardware acceleration was enabled for top performance.

The first step is to clone the Wind River Linux GitHub repository.

Create a directory for the tools needed to create the Wind River Linux image. This will be referred to as the parent directory from this point onwards:

In a Linux terminal, clone the repository into your build folder with the following command:

Note: A clone of wrlinux-x defaults to the WRLINUX_10_19_BASE branch with the latest update tagged. WRLINUX_10_19_BASE_UPDATE0003 or greater is required for the Raspberry Pi 4 BSP. This tutorial was written using WRLINUX_10_19_BASE_UPDATE0007.

This section describes the usage of the Wind River setup.sh tool for easy configuration of the build. We will use it to specify the target board, download the layers required, and pre-populate the configuration file.

In the parent directory that wrlinux-x was cloned into (wrlinux_qt), run the setup.sh script. Accept the End User License Agreement (EULA).

For Raspberry Pi 4 use:

For an Intel NUC use:

Note: The --machine flag specifies that it should include the board support package for your device, the --dl-layers flag downloads the package source now instead of later at build time.

After some time, you will see:

At which point the following files and directories should have been generated:

Run the environment setup scripts that were generated in the parent directory. They will create and change to the build sub-directory.

These scripts will set environment variables for the build tool as well as generate some pre-built configuration files.

Note: If you have previously built an image, running these scripts will not overwrite your existing configurations. Rename, move or delete previous configuration files to ensure the correct configuration files are generated.

This section describes how to add the required template files using git.

Clone the meta-qt5 and the meta-qt5-extra repositories in a my-layers directory

Download the required patches listed below into the wrlinux_qt/build directory:

Credit goes to my colleague, Quanyang Wang, for creating the patches to integrate LxQt desktop on Wind River Linux.

In the meta-qt5-extra directory, apply the first patch:

In the wrlinux layer directory, apply the wrlinux patches:

This section describes how to clone the meta-qt5 and meta-qt5-extra layer repositories. In addition, how to add the layers, GCC toolchain and desktop environment to the image.

Using the bitbake-layers tool, add the layers to the conf/bblayers.conf file. This allow bitbake to locate the custom layer when building the image. In addition, if using a Raspberry Pi add the Raspberry Pi Graphics layer to enable hardware acceleration.

If building for the Raspberry Pi, add in addition for hardware acceleration:

Edit conf/local.conf configuration file to add the GCC toolchain, packages required for Qt5 and the desktop environment. Append the following lines to the end of conf/local.conf:

Note: this tutorial uses the LxQt desktop, but you may replace feature/lxqt with feature/xfce if you prefer to use the desktop featured with the Raspberry Pi Foundation images.

If building for the Raspberry Pi, also add the following to enable hardware acceleration:

If building for Raspberry Pi, edit ../layers/bcm-2xxx-rpi/recipes-bsp/boot-config/boot-config/cmdline.txt file to adjust the kernel parameters.

Note: These changes ensure that the console output appears on the HDMI display and that the boot sequence doesn't wait for a DHCP connection.

This section describes building the Wind River Linux image

Build the image of your choice. As seen in the image in step 4, there are several suggested images. We will build wrlinux-image-std-sato, an image optimized for a desktop environment.

After some time, you will see the following when the build is finished:

This section describes how to identify your USB SD Card adapter or USB flash drive using fdisk.

Use the fdisk command to list the block devices detected by Linux:

Identify your device through the model name or capacity.

Note: In this case the device is '/dev/sdx' as seen by the capacity and 'Disk model'. The device name should take the format of '/dev/sdx' where x is a letter specific to your machine.

This section describes how to write the generated .wic and .wic.bmap or .iso files to the SD card or USB flash drive.

Locate the images generated by bitbake. Relative to the build directory, the image path is:

Specifically, we need the wrlinux-image-std-sato-bcm-2xxx-rpi4.wic and wrlinux-image-std-sato-bcm-2xxx-rpi4.wic.bmap files.

Using bmaptool, flash the generated files to the usb device

After up to several minutes (depending on the speed of your USB device) you should see:

Locate the images generated by bitbake. Relative to the build directory, the image path is:

Specifically, we need the wrlinux-image-std-sato-intel-x86-64.iso file.

Flash your image using dd

In some cases, dd can appear to hang while writing from memory to the USB. Check the progress with:

It should approach the low hundreds when the write is finished.

This section describes how to resize the root filesystem to take up the full capacity of the SD card. With the USB device inserted, run the following commands, replacing /dev/sdx with your device.

For the LxQt desktop, the login and password are wrluser and the $HOME directory is /home/wrluser.

After logging in you will be presented with the LxQt Desktop:

Note: If you chose to use the the XFCE desktop, the login is root with no password and the $HOME directory is /root.

The sample applications come from Qt git repositories. Cloning the repositories requires that you have a working network connection. If for any reason your device didn't automatically get a dynamic IP address you may use the following commands to obtain one.

Open QTerminal by clicking on the icon in the bottom left corner, then click System Tools > QTerminal.

In a QTerminal, execute the su command to become the root user.

Then execute the "ip a" command to verify that your device has retrieved an IP address. Refer to the inet line under eth0 to see your IP address.

If you do not already have an IP address, then you may execute dhclient eth0 to request a dynamic IP address.

Execute exit to stop running commands as the root user and become wrluser again.

This section demonstrates the mesa-demos glxgears application.

Open QTerminal by clicking on the icon in the bottom left corner, then click System Tools > QTerminal.

Execute glxgears to try the OpenGL example. If the hardware acceleration is working, it should report around 60 frames per second on the Raspberry Pi 4.

This section demonstrates an OpenGL example from the Qtbase repository.

Use git to clone the repository containing the OpenGL examples

Copy the examples folder out of the qtbase directory so that Qt Creator will let us build the project.

Launch Qt Creator from the GUI

Open the openglwindow.pro file by selecting File > Open File or Project from the menu.

Navigate to $HOME/examples/opengl/openglwindow/openglwindow.pro. Then click, Open.

Select "openglwindow" as the Active Project, then click the Configure Project button.

Build and run the application by clicking Build > Run in the menu.

(Optional) You may click the "Compile Output" tab along the bottom to watch the toolchain output as the project builds.

After a few moments the openglwindow should appear with a spinning rainbow triangle.

This section demonstrates the QtCluster example from the Qtbase docs repository.

Open a terminal and clone the repository containing the Qt docs:

Launch Qt Creator from the GUI

Open the qtcluster-base.pro file by selecting File > Open File or Project from the menu.

Navigate to $HOME/qtdoc/doc/src/snippets/qtcluster/qtcluster-base.pro. Then click, Open.

Select qtcluster-base"* as the Active Project, then click the Configure Project button.

Build and run the application by clicking Build > Run in the menu.

Note: If the hardware acceleration is working, it should report around 60 frames per second on the Raspberry Pi 4.

View original post here:

Developing Qt5 applications natively on Wind River Linux - WIND

Related Posts