Skip to content

How to build and use an SDK for QT

Cristian Cruz edited this page Feb 19, 2024 · 13 revisions

Here, we are going to leverage ST's Distribution Package to build an SDK for a Developer Package.

Reference.

Example article.

Install Dependencies

Install Repo

  sudo apt-get update
  sudo apt-get install repo

Verify:

repo version

Packages Required by OpenEmbedded/Yocto

sudo apt-get install gawk wget git diffstat unzip texinfo gcc-multilib  chrpath socat cpio python3 python3-pip python3-pexpect 

These too??:

sudo apt-get install xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint xterm bsdmainutils

Misc

sudo apt-get install libssl-dev libgmp-dev libmpc-dev lz4 zstd

Might be useful for developer package stuff:

sudo apt-get install build-essential libncurses-dev libyaml-dev libssl-dev 

Useful tools:

sudo apt-get install coreutils bsdmainutils sed curl bc lrzsz corkscrew cvs subversion mercurial nfs-common nfs-kernel-server libarchive-zip-perl dos2unix texi2html libxml2-utils

Yocto-Required Packages for the buildhost

$ sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev python3-subunit mesa-common-dev zstd liblz4-tool file locales
$ sudo locale-gen en_US.UTF-8

Source: System Requirements section 1.4

Initialize and Download the repo

Installing the OpenSTLinux Distribution

Note that the repo init command is pointing to tags from ST's manifest repository.

repo init -u https://github.com/STMicroelectronics/oe-manifest.git -b refs/tags/[latest tag]
repo init -u https://github.com/STMicroelectronics/oe-manifest.git -b refs/tags/openstlinux-6.1-yocto-mickledore-mp1-v23.11.15
repo sync

image

Initializing the OpenEmbedded Build Environment

Accept terms and agreeements

Available DISTRO and MACHINE variables are shown in the OpenSTLinux distribution page.

This command enables the build environment, and creates the build.../ folder.

DISTRO=openstlinux-eglfs MACHINE=stm32mp1 source layers/meta-st/scripts/envsetup.sh

image

image

Inside the build.../ folder, there is a conf/local.conf file. Open the file and write the following at the bottom:

PARALLEL_MAKE = "-j 10"
BB_NUMBER_THREADS = "10"

This will help limit the number of threads building a package for generating the SDK, as well as the number of threads that are performing the do_compile task of each recipe.

Build the Image

bitbake [image]
bitbake st-example-image-qt

You can also use the --continue flag to keep building despite an error with a package

image

Note: Some packages may fail to build. So, use bitbake --continue st-example-image-qt to keep building. All of the failed packages will be listed in the output when the command finally finishes. Then, do the following:

bitbake -c cleanall [failed_package]
bitbake [failed_package]

Do this manually for all the failed packages, and then re-run bitbake --continue st-example-image-qt.

This entire process of building the image took about 5 hours.

Flashing the Board with the New Linux Image

Follow the same process as described in the Starter package for flashing the board with STM32CubeProgrammer.

The .tsv file is located in the following directory:

distribution-package/build-openstlinuxeglfs-stm32mp1/tmp-glibc/deploy/images/stm32mp1/flashlayout_st-example-image-qt/extensible

  • Notice that the subfolder is named on /build-[image]-[machine]/ based on our IMAGE and MACHINE variables when setting the build environment.

Using ll here will yield the following contents:

total 28
drwxr-xr-x 2 user user 4096 Feb  2 23:57 ./
drwxr-xr-x 5 user user 4096 Feb  2 23:57 ../
-rw-r--r-- 1 user user  937 Feb  2 23:57 FlashLayout_sdcard_stm32mp135f-dk-extensible.tsv
-rw-r--r-- 1 user user  942 Feb  2 23:57 FlashLayout_sdcard_stm32mp157a-dk1-extensible.tsv
-rw-r--r-- 1 user user  942 Feb  2 23:57 FlashLayout_sdcard_stm32mp157c-dk2-extensible.tsv
-rw-r--r-- 1 user user  942 Feb  2 23:57 FlashLayout_sdcard_stm32mp157d-dk1-extensible.tsv
-rw-r--r-- 1 user user  942 Feb  2 23:57 FlashLayout_sdcard_stm32mp157f-dk2-extensible.tsv

image

Select the .tsv that is appropriate for your board.

As for selecting the Binaries path on STM32CubeProgrammer, select the following directory:

distribution-package/build-openstlinuxeglfs-stm32mp1/tmp-glibc/deploy/images/stm32mp1

Using ll yields the following contents. Note that there is so many files, that the screenshot below does not show everything.

image

Running Example Qt Applications

These applications are already cross-compiled to run on our particular embedded device.

  • Set both BOOT switches to 1
  • Insert the flashed Micro-SD card
  • Connect to the display
  • Connect to the internet via Ethernet cable
  • Power on

You will see a still "OpenSTLinux" splash screen that does not do anything other than display the image.

On the PC, login to the device:

ssh root@[ip-address]

You should now be logged into the board via SSH. Now, remove the splash screen:

psplash-drm-quit

The screen should be blank now, with nothing to display.

cd /usr/share/examples/

Here, there are plenty of examples in folders/sub-folders with their respective executable. For instance,

cd opengl/hellowindow
./hellowindow

The screen should now display a 3D "Qt" object rotating.

Using the Image to build an SDK

Source your environment again and return to your build/... folder. Run the following command:

bitbake --continue st-example-image-qt -c populate_sdk

Note that this command brought issues unless it ran completely without interruption. If an error occurs (such as the terminal crashing due to lack of memory, or the gcc-crosssdk recipe not being found as shown below), manually delete the build/... folder and repeat the process.

image

Due to the --continue flag, the final output will include a list of packages/recipes that failed to compile -- if any, at all. To fix this, clean and build each package manually before re-runnig populate_sdk.

bitbake -c cleansstate [recipe]
bitbake [recipe]

This build command took about 5 more hours, after reducing how many threads and tasks are to run.

The newly generated SDK can be found in the following directory:

cd tmp-glibc/deploy/sdk

[bitbake tasks](https://wiki.rdkcentral.com/display/RDK/Yocto+Developer+Guide) that work with the `bitbake -c [task]` command.