Last active
May 13, 2024 12:17
-
-
Save omrdk/d5618275ca07e9e7c13a72d151997ccf to your computer and use it in GitHub Desktop.
Qt for Embedded Linux(raspberry pi)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf | |
# changes incompatibly | |
POKY_BBLAYERS_CONF_VERSION = "2" | |
BBPATH = "${TOPDIR}" | |
BBFILES ?= "" | |
BBLAYERS ?= " \ | |
${HOME}/poky-dunfell/meta \ | |
${HOME}/poky-dunfell/meta-poky \ | |
${HOME}/poky-dunfell/meta-openembedded/meta-oe \ | |
${HOME}/poky-dunfell/meta-openembedded/meta-multimedia \ | |
${HOME}/poky-dunfell/meta-openembedded/meta-networking \ | |
${HOME}/poky-dunfell/meta-openembedded/meta-perl \ | |
${HOME}/poky-dunfell/meta-openembedded/meta-python \ | |
${HOME}/poky-dunfell/meta-qt5 \ | |
${HOME}/poky-dunfell/meta-raspberrypi \ | |
${HOME}/poky-dunfell/meta-jumpnow \ | |
${HOME}/poky-dunfell/meta-security \ | |
${HOME}/rpi/meta-rpi \ | |
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bitbake -g <image> && cat pn-buildlist | grep -ve "native" | sort | uniq -> list image packages | |
bitbake -s | grep <pkg> -> Check if certain package is present on current | |
build/tmp/work/cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi/qtbase/5.13.2+gitAUTOINC+a7a24784ee-r0/build/config.summary -> Check egfls or other things |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is an instruction of building Raspberry Pi systems with Yocto Project. | |
1# Below packages must installed on your host system(18.04 or 20.04 ubuntu). | |
build-essential, chrpath, diffstat, gawk, libncurses5-dev, python3-distutils, texinfo | |
2# You should change the default Ubuntu shell from dash to bash by running this command from a shell: | |
sudo dpkg-reconfigure dash :: Choose No to dash when prompted. | |
3# First clone the main Yocto project poky layer with this command: | |
~$ git clone -b dunfell git://git.yoctoproject.org/poky.git poky-dunfell | |
4# Then the dependency layers under that: | |
~$ cd poky-dunfell | |
~/poky-dunfell$ git clone -b dunfell git://git.openembedded.org/meta-openembedded | |
~/poky-dunfell$ git clone -b dunfell https://github.com/meta-qt5/meta-qt5 | |
~/poky-dunfell$ git clone -b dunfell git://git.yoctoproject.org/meta-raspberrypi | |
~/poky-dunfell$ git clone -b dunfell git://git.yoctoproject.org/meta-security.git | |
5# Changing some upstream package defaults and adding a few custom recipes(I didn't compile it) | |
~/poky-dunfell$ git clone -b dunfell https://github.com/jumpnow/meta-jumpnow | |
6# Create a separate sub-directory for the meta-rpi repository before cloning. This is where you will be doing your customization | |
~$ mkdir ~/rpi | |
~$ cd ~/rpi | |
~/rpi$ git clone -b dunfell git://github.com/jumpnow/meta-rpi | |
7# Initialize the build directory | |
~$ source poky-dunfell/oe-init-build-env ~/rpi/build(this one has different machine names) | |
or | |
$ mkdir -p ~/rpi/build/conf(this one has machine names of raspberrypi devices) | |
~/rpi$ cp meta-rpi/conf/local.conf.sample build/conf/local.conf | |
~/rpi$ cp meta-rpi/conf/bblayers.conf.sample build/conf/bblayers.conf | |
Warning: Do not use the ‘~’ character when defining directory paths in the Yocto configuration files. | |
8# Edit bblayer.conf according to below file which named bblayers.conf. | |
9# Edit local.conf according to below file which named local. | |
The important things in local.conf: | |
DL_DIR = "/home/merdak/rpi/build/sources" - Fetched files in here | |
SSTATE_DIR = "/home/merdak/rpi/build/sstate-cache" | |
TMPDIR = "/home/merdak/rpi/build/tmp" - Compiled files in here | |
IMAGE_INSTALL_append_pn-qt5-image=" openssh" - It might not installed openssh to qt5-image | |
DISTRO_FEATURES_remove = "x11" - In Qt5 there is no need X11 wayland platform | |
MACHINE_FEATURES_remove = "vc4graphics" | |
PACKAGECONFIG_append_pn-qtbase = " eglfs" - Activate eglfs | |
10# Run the build | |
~$ source poky-dunfell/oe-init-build-env ~/rpi/build | |
~/rpi/build$ bitbake qt5-image(it takes some time...) | |
If the build for qt5-image failed for some reason, run this commands in order: | |
~/rpi/build$ bitbake -c cleansstate qt5-image | |
~/rpi/build$ bitbake qt5-image | |
11# Copying the binaries to an SD card (or eMMC) | |
This script will partition an SD card with the minimal 2 partitions required for the RPI: | |
~$ cd ~/rpi/meta-rpi/scripts | |
~/rpi/meta-rpi/scripts$ sudo ./mk2parts.sh sdb (if you get mount errors, you must unmount before run the script) | |
12# Temporary mount point | |
You will need to create a mount point on your workstation for the copy scripts to use. | |
This is the default: | |
~$ sudo mkdir /media/card | |
13# copy_boot.sh | |
This script copies the GPU firmware, the Linux kernel, dtbs and overlays, config.txt and cmdline.txt to the boot partition of the SD card. | |
OETMP and MACHINE values must be exported before run the script: | |
~/rpi/meta-rpi/scripts$ export OETMP=/home/merdak/rpi/build/tmp(this is the TMPDIR direction in the local.conf file) | |
~/rpi/meta-rpi/scripts$ export MACHINE=raspberrypi0-wifi | |
~/rpi/meta-rpi/scripts$ ./copy_boot.sh sdb | |
14# copy_rootfs.sh | |
This script copies the root file system to the second partition of the SD card. | |
~/rpi/meta-rpi/scripts$ ./copy_rootfs.sh mmcblk0 qt5 rpi3(disk partition name, image name, user name) | |
15# Create toolchain | |
~/rpi/build$ bitbake meta-toolchain-qt5 | |
This command will create files which named 'sdk' under /home/merdak/rpi/build/tmp/deploy | |
Go to this path and run the *.sh file. | |
This file will create 'sysroot' file under /opt/poky/3.1.9, unless otherwise stated.(Which means you can specify the 'export path' but don't) | |
16# Cross compile | |
In the sysroot file there are two files; | |
-arm1176jzfshf-vfp-poky-linux-gnueabi(this folder is an example of the target operational system) | |
-x86_64-pokysdk-linux(this folder for host pc to configure qt for target device) | |
17# Create kit for target device | |
Open Qt Creator, go to Tools->Options->Kits | |
For compilers: | |
Add a GCC and give the path: | |
/opt/poky/3.1.9/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc | |
Add a G++ and give the path: | |
/opt/poky/3.1.9/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ | |
For debugger: | |
Add a GDB and give the path: | |
/opt/poky/3.1.9/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gdb | |
For Qt Versions: | |
Add a version and give the path: | |
/opt/poky/3.1.9/sysroots/x86_64-pokysdk-linux/usr/bin/qmake | |
Finally add a kit and: | |
-Configure the device as Linux Generic Device | |
-Give sysroot path as: /opt/poky/3.1.9/sysroots/arm1176jzfshf-vfp-poky-linux-gnueabi | |
-Select compilers, debugger, and Qt version | |
18# Configure SSH | |
-Open the target device, configure /etc/wpa_supplicant and /etc/network/interfaces and reboot for internet connection | |
-Query the IP address of target device. | |
-Go to Qt and Tools->Options->Devices. | |
Host Name: target-device-ip | |
Username : Root | |
Leave default the other configurations. | |
Open a new project and configure for target device. When you play it, it will run on target device. | |
19# Play video & open Qt application on target device | |
Go to under /etc/init.d/ folder. | |
Create a shell script file(touch tem_start.sh) and modify: | |
#!/bin/sh | |
omxplayer -o /home/root/temterazi.mp4 | |
Under /etc/init.d/ run this command: | |
update-rc.d temstart.sh defaults(this cmd will add the script to startup) | |
Under /home/root create file(touch ~/.profile) and modify | |
cd /home/root && ./qtapplication | |
With this operation, Qt application will start every log in. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://jumpnowtek.com/rpi/Raspberry-Pi-Systems-with-Yocto.html | |
https://askubuntu.com/questions/299792/why-is-the-command-in-etc-rc-local-not-executed-during-startup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Local configuration for meta-rpi images | |
# Yocto Project 3.1 Poky distribution [dunfell] branch | |
# This is a sysvinit system | |
# mask wireguard from meta-openembedded/meta-networking | |
# use version in meta-jumpnow to support kernels < 5.6 | |
# with wireguard-linux-compat | |
BBMASK = "meta-networking/recipes-kernel/wireguard" | |
LICENSE_FLAGS_WHITELIST = "commercial" | |
DISTRO_FEATURES = "ext2 opengl usbhost ${DISTRO_FEATURES_LIBC}" | |
DISTRO_FEATURES_BACKFILL_CONSIDERED += "pulseaudio" | |
PREFERRED_PROVIDER_jpeg = "libjpeg-turbo" | |
PREFERRED_PROVIDER_jpeg-native = "libjpeg-turbo-native" | |
PREFERRED_PROVIDER_udev = "eudev" | |
VIRTUAL-RUNTIME_init_manager = "sysvinit" | |
MACHINE_FEATURES_remove = "apm" | |
IMAGE_FSTYPES = "tar.xz" | |
# Choose the board you are building for | |
#MACHINE = "raspberrypi" | |
#MACHINE = "raspberrypi0" | |
MACHINE = "raspberrypi0-wifi" | |
#MACHINE = "raspberrypi2" | |
#MACHINE = "raspberrypi3" | |
#MACHINE = "raspberrypi4" | |
#MACHINE = "raspberrypi-cm" | |
#MACHINE = "raspberrypi-cm3" | |
# Choices are Image or zImage if NOT using u-boot (no u-boot is the default) | |
# Choices are uImage or zImage if using u-boot, though if you choose zImage | |
# with u-boot you will also have to change the boot script boot command | |
KERNEL_IMAGETYPE = "zImage" | |
# uncomment for kernels < 5.6 | |
WIREGUARD_COMPAT = "1" | |
DISABLE_VC4GRAPHICS = "1" | |
DISABLE_OVERSCAN = "1" | |
ENABLE_UART = "1" | |
ENABLE_RPI3_SERIAL_CONSOLE = "1" | |
SERIAL_CONSOLES = "115200;ttyAMA0" | |
# SERIAL_CONSOLES_forcevariable = "" | |
# default is still 4.19, uncomment the following for 5.4 | |
# PREFERRED_VERSION_linux-raspberrypi = "5.4.%" | |
DL_DIR = "/home/merdak/rpi/build/sources" | |
SSTATE_DIR = "/home/merdak/rpi/build/sstate-cache" | |
TMPDIR = "/home/merdak/rpi/build/tmp" | |
DISTRO = "poky" | |
PACKAGE_CLASSES = "package_ipk" | |
# i686 or x86_64 | |
SDKMACHINE = "x86_64" | |
# for no root passwd uncomment the following and comment the two extra user lines | |
EXTRA_IMAGE_FEATURES = "debug-tweaks" | |
# for a root passwd, change jumpnowtek below to your password | |
#INHERIT += "extrausers" | |
#EXTRA_USERS_PARAMS = "usermod -P jumpnowtek root; " | |
# this will force root to change password on first login | |
#INHERIT += "chageusers" | |
#CHAGE_USERS_PARAMS = "chage -d0 root; " | |
USER_CLASSES = "image-mklibs image-prelink" | |
PATCHRESOLVE = "noop" | |
RM_OLD_IMAGE = "1" | |
#INHERIT += "rm_work" | |
CONF_VERSION = "1" | |
DISTRO_FEATURES_remove = "x11" | |
MACHINE_FEATURES_remove = "vc4graphics" | |
PACKAGECONFIG_append_pn-qtbase = " eglfs" | |
#IMAGE_INSTALL_remove = "checksec ncrack" | |
IMAGE_INSTALL_append_pn-qt5-image=" openssh" | |
#BB_NUMBER_THREADS = "4" | |
#PARALLEL_MAKE = "-j6" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment