4. Installing the Kivy layer in Yocto

Before proceeding, make sure you have set up Yocto following the First Steps with Yocto.

4.1. Installing the Layer

To install the meta-phykivy layer, follow these steps:

  1. Install the BSP with Qt6 demo image (also called qtphy) by running:

DISTRO=ampliphy-vendor-xwayland MACHINE=phyboard-pollux-imx8mp-3 ./phyLinux init -p imx8mp -r BSP-Yocto-NXP-i.MX8MP-PD22.x.y

You can also only use ./phyLinux init and see all the options for the parameters before choosing one. If you want more information on how to install your Phytec BSP with phyLinux, you can check the PHYTEC Yocto Reference Manual

  1. Uncomment ACCEPT_FSL_EULA = "1" in the local.conf file.

  2. Git clone the meta-phykivy layer in the source folder and add it to your bblayer.conf file.

  3. Build the final image by using the bitbake phytec-kivydemo-image command after starting bitbake.

That’s it, you should then have the exact same image as the one you download during the first tutorial in Installation.

NOTE: If you want to use Wayland insted of XWayland, you need to change the distro and add REQUIRED_DISTRO:remove = "X11" in the bbappend file of Kivy.

4.2. Understanding the Layer

The files necessary to run Kivy are:

  • sdl2.bbappend

  • kivy.bbappend

  • Patch for the cameras (camera_gi.patch and kivy_opencv.patch)

All the other files are optional. Some patch are present to fix some warnings in Kivy while other are added for the demo. You can choose what to add inside your image in the kivyphy_0.1.bb recipe.

4.3. Kivy Recipe and Minimal Version

Kivy uses sdl2 to work, but sdl2 does not work out of the box for this product. To use Wayland instead of X11, you need to add the sdl2.bbappend.

Similarly, the cameras in Kivy do not work as expected on the product, so you need a patch to fix this depending on you provider for the camera (gstreamer or opencv). For more information about the cameras, you can check Camera with Kivy.

4.4. Disabling Kivy Demo

To disable the Kivy demo inside the image, add the following line inside the local.conf file:

SYSTEMD_AUTO_ENABLE:kivyphy-service = "disable"

You can also disable the service on the board with:

# to stop the service
systemctl stop kivyphy

# to start the service again
systemctl start kivyphy

#to disable permanently, so it does not start on boot
systemctl disable kivyphy

That way, you can avoid to have the demo each time you boot the board.