Embedded Software Raspberry Pi - Yocto - Raspberry - PIGPIO - Qt a screenshot of a computer program

Yocto - Raspberry - PIGPIO - Qt

Linux with pigpio library and Qt toolchain

bitbake recipe pigpio

Create recipe for pigpio library

For this project we need to have the pigpio library to have access to I2C, SPI and other GPIOs with one library.

Unfortunately we found no recipe for it in the common meta-layers for Yocto and have to create our own.

pigpio_git.bb recipe

Creating a custom recipe for Yocto is not so difficult - but in detail it can be.

The standard procedure is, to get the source and let it bitbake:

DESCRIPTION = "pigpio"
SECTION = "devel/libs"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = "file://UNLICENCE"

COMPATIBLE_MACHINE = "^rpi$"

SRC_URI = "git://github.com/joan2937/pigpio.git;protocol=https;tag=v79 \
"

S = "${WORKDIR}/git"

inherit pkgconfig cmake

But if you "bitbake pigpio", it throws some errors, because there are no versioned libraries configured and the location of the manpages files are not handled correct.

manpages error

First the following error occurs:

ERROR: pigpio-git-r0 do_package: QA Issue: pigpio: Files/directories were installed but not shipped in any package:
  /usr/man
  /usr/man/man1
  ...

You can fix this error with the following settings:

FILES:${PN}-doc += "\
     /usr/man/man1/pigs.1 \
     /usr/man/man1/pig2vcd.1 \
     /usr/man/man1/pigpiod.1 \
     /usr/man/man3/pigpio.3 \
     /usr/man/man3/pigpiod_if.3 \
     /usr/man/man3/pigpiod_if2.3 \
"

non-symlink error

After fixing the error with the manpages, the next error comes up:

ERROR: pigpio-git-r0 do_package_qa: QA Issue: pigpio rdepends on pigpio-dev [dev-deps]
ERROR: pigpio-git-r0 do_package_qa: QA Issue: -dev package pigpio-dev contains non-symlink .so '/usr/lib/libpigpio.so'
-dev package pigpio-dev contains non-symlink .so '/usr/lib/libpigpiod_if2.so'
-dev package pigpio-dev contains non-symlink .so '/usr/lib/libpigpiod_if.so' [dev-elf]

This happens, because there are no versioned libraries generated from "CMakeLists.txt". To fix this, we add:

SOLIBS = ".so"
FILES_SOLIBSDEV = ""

systemd autostart pigpiod

To autostart the pigpio daemon, we add the following:

do_install() {
    install -d ${D}${bindir}
    install -d ${D}${libdir}
    install -d ${D}${PYTHON_SITEPACKAGES_DIR}
     
    install -m 0644 ${S}/pigpio.py ${D}${PYTHON_SITEPACKAGES_DIR}

    install -d ${D}${systemd_system_unitdir}
    install -m 0644 ${S}/util/pigpiod.service ${D}${systemd_system_unitdir}

    cmake_do_install
}

SYSTEMD_SERVICE:${PN} = "pigpiod.service"

Note

If you need header files installed for development, you have to install IMAGE_FEATURES "dev-pkgs

IMAGE_FEATURES += "package-management dev-pkgs doc-pkgs"

Download the zipped meta-layer with the recipe from meta-interelectronix-rpi.

Global image configuration

local.conf settings

Download the zipped build configuration files from rpi4-build.

First have a look at the bblayers.conf file. Inside you find the needed meta-layers. Download the meta-layers, if you don't already have done and adjust your bblayers.conf file.

Second have a look at the local.conf file.

I2C settings

If you want to use a sensor chip (e.g. a temperature sensor) connected with I2C, you have to enable I2C in the local.conf file.

ENABLE_I2C = "1"
KERNEL_MODULE_AUTOLOAD_rpi += " i2c-dev"

Remove X11 and Wayland

There are many errors in the bitbake process, if we not remove X11 and Wayland

In our case - as we don't need multiple windows - we remove them.

DISTRO_FEATURES:remove = "ptest x11 wayland vulkan directfb"

To use eglfs properly, we add:

VC4DTBO ?= "vc4-fkms-v3d"

bitbake Raspberry image

Create image configuration file

In the file "rpi4-64-qt5-gpio-image.bb" we define, which packages we need in our linux distribution. Here you can - as mentioned before - include the IMAGE_FEATURES "dev-pkgs".

The file is separated into several sections as for example DEV-SDK, EXTRA_TOOLS and so on, to add easily needed packages.

pigpio package

This package is added under CUSTOM_STUFF:

CUSTOM_STUFF = " \
    pigpio \
"

Qt packages

The packages needed for Qt are added into package groups and this package groups are added here:

IMAGE_INSTALL:append += " packagegroup-qt5 packagegroup-qt5-toolchain-target packagegroup-qt5-qtcreator-debug"

You can find "packagegroup-qt5" in the file "packagegroup-qt5.bb" and add or delete Qt packages.

Download the zipped meta-layer with the image from meta-interelectronix-rpi-qt.

After that you can bitbake the image:

bitbake rpi4-64-qt5-gpio-image

bitbake SDK

Create SDK toolchain

If you want to develop a Qt application for this custom Linux distribution, you surely want to have cross compile toolchain, to add it to your QtCreator configuration.

You can easily create a SDK with the following bitbake command:

bitbake -c populate_sdk rpi4-64-qt5-gpio-image

We have the package groups "packagegroup-qt5-toolchain-target packagegroup-qt5-qtcreator-debug" added to the image configuration file.

Install SDK

You find the generated SDK in the following directory:

/tmp/deploy/sdk

In our case it is named "poky-glibc-x86_64-rpi4-64-qt5-gpio-image-cortexa72-raspberrypi4-64-toolchain-3.4.3.sh".

This file contains setup instructions and all the needed files (in a compressed format).

Copy this file to your development computer and execute it:

./poky-glibc-x86_64-rpi4-64-qt5-gpio-image-cortexa72-raspberrypi4-64-toolchain-3.4.3.sh

Follow the instructions to install the SDK.

Copyright License

Copyright © 2022 Interelectronix e.K.
This Project source code is licensed under the GPL-3.0 license.