Qt is a versatile C++ framework known for its rich GUI elements and cross-platform capabilities. It excels in embedded Linux applications due to its efficiency, hardware acceleration support, and seamless integration. Supporting multiple languages like C++, Python, and JavaScript, Qt offers developers flexibility and ease of use.
- Download the Poky build system (kirkstone branch)
$ git clone -b kirkstone git://git.yoctoproject.org/poky
- Download RPI BSP (kirkstone branch)
$ git clone -b kirkstone https://github.com/agherzan/meta-raspberrypi.git
- Download openembedded (kirkstone branch)
$ git clone -b kirkstone https://github.com/openembedded/meta-openembedded.git
Note: for my steps, both poky, meta-raspberrypi and meta-openembedded repos are in the same path
- Source “oe-init-build-env” script
$ source poky/oe-init-build-env
- Edit build/bblayers.conf and add layers to BBLAYERS variable
BBLAYERS ?= " \
/ABSOLUTE/PATH/poky/meta \
/ABSOLUTE/PATH/poky/meta-poky \
/ABSOLUTE/PATH/poky/meta-yocto-bsp \
/ABSOLUTE/PATH/meta-raspberrypi \
/ABSOLUTE/PATH/meta-openembedded/meta-oe \
/ABSOLUTE/PATH/meta-openembedded/meta-python \
/ABSOLUTE/PATH/meta-openembedded/meta-networking \
/ABSOLUTE/PATH/meta-openembedded/meta-multimedia \
"
-
Edit build/local.conf by changing
MACHINE ??= "qemux86-64"
to beMACHINE ?= "raspberrypi4-64"
-
Edit build/local.conf and add the following line
DISTRO_FEATURES:append = " systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
VIRTUAL-RUNTIME_init_manager = "systemd"
VIRTUAL-RUNTIME_initscripts = "systemd-compat-units"
IMAGE_INSTALL += " packagegroup-core-boot"
- For developing you might need rootfs extra space, to add additional space as 5G edit build/local.conf and add the following line
IMAGE_ROOTFS_EXTRA_SPACE = "5242880"
Connect to your target through VNC server, then edit build/local.conf and add x11vnc to IMAGE_INSTALL_append variable
IMAGE_INSTALL:append = " x11vnc"
- Download the qt5 layer (kirkstone branch)
$ git clone -b kirkstone https://github.com/meta-qt5/meta-qt5
- Edit build/bblayers.conf and add the layer to BBLAYERS variable
BBLAYERS ?= " \
....
/ABSOLUTE/PATH/meta-qt5 \
"
- To support Qt5 on image, edit build/local.conf and add
IMAGE_INSTALL:append = " make cmake"
IMAGE_INSTALL:append = " qtbase-tools qtbase qtdeclarative qtimageformats qtmultimedia qtquickcontrols2 qtquickcontrols qtbase-plugins cinematicexperience liberation-fonts"
PACKAGECONFIG_FONTS_append_pn-qtbase = " fontconfig"
- To enable remote deployment on RPI using Qt platform, you need to add extra network configuration to build/local.conf
IMAGE_INSTALL:append = " openssh-sftp-server rsync"
- Build the image using the build engine BitBake
It may take many hours to finish the build process
$ bitbake core-image-sato -k
-
If the build process was successful, the raspberry pi image will be under
bashbuild/tmp/deploy/images/raspberrypi3-64/core-image-sato-raspberrypi3-64.rpi-sdimg
-
Flash the image on the SD card and make sure that it's formatted as free space
my SD card is /dev/mmcblk0
$ sudo dd if=tmp/deploy/images/raspberrypi4-64/core-image-sato-raspberrypi4-64.rpi-sdimg of=/dev/mmcblk0 status=progress conv=fsync bs=4M
- After the image is ready, connect RPI with having the next interface
$ x11vnc
then you open VNC viewer from your host and give it the IP of RPI and the port number that appear after executing x11vnc
- Install Qt5 Creator command line launcher, my Qt version is 15.5.2 from link Qt.download and choose linux
-
Download the file, run and i choose version_15.5.2
- Install Qt5 toolchain for cross compilation. The installation path may differ, just check your terminal output
$ bitbake meta-toolchain-qt5
$ cd tmp/deploy/sdk
$ ./poky-glibc-x86_64-meta-toolchain-qt5-aarch64-raspberrypi3-64-toolchain-3.0.2.sh
- First, you need to source the SDK toolchain. The source path may differ depending on the output of your SDK installation
$ source /home/ibrahim/yocto/poky/build/target/environment-setup-cortexa72-poky-linux
- From the same terminal launch qtcreator
$ ~/Qt/Tools/QtCreator/bin/qtcreator
-
After Qt creator launches, you need to configure the device from Tools -> External -> Configure
- Add new Generic Linux Device providing the name you want, the hostname/IP address of your device and the username
-
Then configure your Kits options from Tools -> External -> Configure
- Create New Kit (Raspberrypi4)
- Qt Versions -> add the path of the SDK qmake
/home/ibrahim/yocto/poky/build/target/sysroots/x86_64-pokysdk-linux/usr/bin/qmake
with any name - Compilers -> add the path of C and C++ compilers
/home/ibrahim/yocto/poky/build/target/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc
and the same forg++
/home/ibrahim/yocto/poky/build/target/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gdb
5. CMake -> it might be auto detected, in case if not add the path/home/ibrahim/yocto/poky/build/target/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-gcc