From ProventusNova DeveloperWiki

Introduction

This wiki will provide a detailed guide on how to create a custom Yocto meta-layer for a MediaTek Genio 510 board.

Pre-requisites

1. The host machine must have the following requirements:

  • At least 90GB of space
  • At least 8GB RAM
  • Host OS must be a supported Linux distribution. (To see supported Linux Distributions, click supported distributions)

2. The following packages must be present in the host machine:

apt install build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd

Create Base Meta-Layer

This section contains steps to create the base custom meta-layer.
Creating a layer can be done manually or automatically via bitbake.
After completion, the custom base meta-layer will contain the following parts:

  • Custom layer configuration
  • Custom distro configuration
  • Custom machine
  • Custom config template files
  • Custom image recipe

Manually create layer

Step 1. Add base layer.conf file

The layer configuration file provides Yocto with the configuration for the custom meta-layer. It shall be stored in a directory called conf inside the base meta-layer directory, and it shall be named layer.conf. According to the Yocto documentation it is recommended to start from an existing layer.conf file from a different meta-layer and change it according to the custom requirements.

For instance, here is an example of how the directory structure should look after creating the layer.conf file.

meta-pn-mtk/
├── conf
│   └── layer.conf
└── README.md

An example layer.conf file based on MediaTek RITY meta-rity-demo is shown in the following code snipped.

# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"

# We have recipes-* directories, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "pn-mtk"
BBFILE_PATTERN_pn-mtk = "^${LAYERDIR}/"
BBFILE_PRIORITY_pn-mtk = "9"

# This should only be incremented on significant changes that will
# cause compatibility issues with other layers
LAYERVERSION_pn-mtk = "1"

LAYERDEPENDS_pn-mtk = " \
	core \
	mediatek-bsp \
	mediatek-tsn \
	mediatek-bluedroid \
	mediatek-demo \
	multimedia-layer \
	openembedded-layer \
	networking-layer \
	meta-python \
"

LAYERSERIES_COMPAT_pn-mtk = "scarthgap"

Step 2. Add base distro config

In order to add the initial distro configuration, it is necessary to create distro configuration file inside the meta-layer/conf/distro directory.

Here is an example of how the directory structure should look like:

meta-pn-mtk/
├── conf
│   ├── distro
│      └── pn-mtk.conf
│   └── layer.conf
└── README.md

The same as with the layer.conf, it is easier to start with an existing distro configuration file and modify it in order to fit the project requirements. For example, the following corresponds to a distro configuration file based on the MediaTek meta-rity-demo:

require conf/distro/rity.inc

DISTRO = "pn-mtk"
DISTRO_NAME = "PN MTK Layer"

INIT_MANAGER = "systemd"

DISTRO_FEATURES:append = " pipewire demo pam fwupdate expand-rootfs btf"
DISTRO_FEATURES_FILTER_NATIVESDK:append = " wayland"
VIRTUAL-RUNTIME_vim = "vim"

# Mount /var/log/ in persistence storage,
# so it is possible to keep journalctl logs.
VOLATILE_LOG_DIR = "0"

PACKAGECONFIG:append:pn-weston-init = " no-idle-timeout"

PACKAGE_CLASSES ?= "package_deb"
PACKAGE_FEED_URIS ?= "http://192.168.96.20:9876"
EXTRA_IMAGE_FEATURES:append = " package-management "

Step 3. Add base machine

This step might not be required, if there is already a machine that can be used from a different meta-layer. However, it is still recommended to create a custom machine configuration based on that machine in order to keep better order of the machine used in the custom Yocto build.

To create a custom machine, it is necessary to add a machine.conf file in the meta-layer/conf/machine directory. For example, this is how the directory structure should look when adding a new machine to the custom meta-layer:

meta-pn-mtk/
├── conf
│   ├── distro
│      └── pn-mtk.conf
│   ├── layer.conf
│   └── machine
│       └── mtk-g510.conf
└── README.md

And, as a reference, here is a custom machine based on MediaTek meta-mediatek-bsp mt8370-evk.conf machine.

require conf/machine/include/mt8370.inc
require conf/machine/include/mt7921.inc

# Kernel
KERNEL_DEVICETREE = "mediatek/mt8370-genio-510-evk.dtb"


# U-Boot
UBOOT_MACHINE = "genio_510_evk_defconfig"

# libdram
LIBDRAM_BOARD_NAME = "genio-700-evk"

# OP-TEE
OPTEE_DRAM_SIZE = "0x100000000"

# LK
LK_BOARD_NAME = "genio-510-evk"

MACHINE_FEATURES:append = " alsa bluetooth pci usbgadget usbhost wifi tsn uc-fde"

MACHINEOVERRIDES =. "mt8370-evk:genio-510-evk:"

# onsemi-firmware
ONSEMI_BOARD_NAME = "MediaTek_Genio"
MACHINE_EXTRA_RRECOMMENDS:append = " \
        onsemi-firmware-ap1302-ar0430 \
        onsemi-firmware-ap1302-ar0830 \
"

# Drivers for external I2C device
MACHINE_EXTRA_RRECOMMENDS:append = " \
        ite-it6510-driver \
        lontium-lt6911-driver \
"

Step 4. Add initial config template files

Bitbake will require 2 configuration files for building an image:

bblayers.conf: This file contains information about the location of the required meta-layers for the project.

local.conf: This file contains general build configuration for bitbake. For instance, in this file it is possible to determine where to store downloads, cache and even which package management configuration to use.

Now, in order to simplify the configuration of a custom Yocto build, it is possible to include template configuration files on the custom meta-layer. This practice is encouraged in order to increase build repeatability.

These 2 files are generally created inside meta-layer/conf/templates/template-name. For reference, this is how the directory structure would look like after the files are created:

meta-pn-mtk/
├── conf
│   ├── distro
│      └── pn-mtk.conf
│   ├── layer.conf
│   ├── machine
│      └── mtk-g510.conf
│   └── templates
│       └── default
│           ├── bblayers.conf.sample
│           └── local.conf.sample
└── README.md

Here is an example of a custom bblayers.conf.sample file based on MediaTek meta-rity:

# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

BBLAYERS ?= " \
  ##OEROOT##/meta \
  ##OEROOT##/meta-poky \
  ##OEROOT##/meta-yocto-bsp \
  ##OEROOT##/../meta-arm/meta-arm \
  ##OEROOT##/../meta-arm/meta-arm-toolchain \
  ##OEROOT##/../meta-clang \
  ##OEROOT##/../meta-mediatek-bsp \
  ##OEROOT##/../meta-mediatek-tsn \
  ##OEROOT##/../meta-mediatek-bluedroid \
  ##OEROOT##/../meta-mediatek-demo \
  ##OEROOT##/../meta-nn \
  ##OEROOT##/../meta-security \
  ##OEROOT##/../meta-openembedded/meta-multimedia \
  ##OEROOT##/../meta-openembedded/meta-networking \
  ##OEROOT##/../meta-openembedded/meta-oe \
  ##OEROOT##/../meta-openembedded/meta-python \
  ##OEROOT##/../meta-openembedded/meta-perl \
  ##OEROOT##/../meta-rity/meta \
  ##OEROOT##/../meta-rity/meta-rity-bringup \
  ##OEROOT##/../meta-rity/meta-rity-demo \
  ##OEROOT##/../../../meta-pn-mtk \
  "

And, this is an example of a custom local.conf.sample file based on MediaTek meta-rity:

# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"

BBPATH = "${TOPDIR}"
BBFILES ?= ""

BBLAYERS ?= " \
  ##OEROOT##/meta \
  ##OEROOT##/meta-poky \
  ##OEROOT##/meta-yocto-bsp \
  ##OEROOT##/../meta-arm/meta-arm \
  ##OEROOT##/../meta-arm/meta-arm-toolchain \
  ##OEROOT##/../meta-clang \
  ##OEROOT##/../meta-mediatek-bsp \
  ##OEROOT##/../meta-mediatek-tsn \
  ##OEROOT##/../meta-mediatek-bluedroid \
  ##OEROOT##/../meta-mediatek-demo \
  ##OEROOT##/../meta-nn \
  ##OEROOT##/../meta-security \
  ##OEROOT##/../meta-openembedded/meta-multimedia \
  ##OEROOT##/../meta-openembedded/meta-networking \
  ##OEROOT##/../meta-openembedded/meta-oe \
  ##OEROOT##/../meta-openembedded/meta-python \
  ##OEROOT##/../meta-openembedded/meta-perl \
  ##OEROOT##/../meta-rity/meta \
  ##OEROOT##/../meta-rity/meta-rity-bringup \
  ##OEROOT##/../meta-rity/meta-rity-demo \
  ##OEROOT##/../../../meta-pn-mtk \
  "

Step 5. Add base image recipe

In order to create a custom image, it is necessary to add a custom image recipe file. This file is usually added inside the meta-layer/recipes-layer/images directory.

For example:

meta-pn-mtk/
├── conf
│   ├── distro
│      └── pn-mtk.conf
│   ├── layer.conf
│   ├── machine
│      └── mtk-g510.conf
│   └── templates
│       └── default
│           ├── bblayers.conf.sample
│           └── local.conf.sample
├── README.md
└── recipes-pn-mtk
    └── images
        └── pn-mtk-image-base.bb

Once again, a custom image recipe can be based on another image recipe. And, it can also import other image recipes in order to include their base configurations.

As reference, the following image recipe was based on MediaTek meta-rity rity-demo-image recipe:

require rity-bsp-image.bb

DESCRIPTION = "PN MTK Demo Image"

#FIXME: Removed pkggroups
IMAGE_INSTALL += "\
	packagegroup-rity-graphics \
	rity-demo-opencl \
	python3-pip \
	python3-opencv \
	opkg \
	benchmark-suite \
	ltp \
	stress-scripts \
	packagegroup-rity-ai-ml \
"

IMAGE_INSTALL:append:genio-510 = " \
	packagegroup-rity-tsn \
"

Need Further Support?

📞 Book Consultation Call: Show Calendar!

📩 Contact Via Email: support@proventusnova.com

🌐 Visit Our Website: ProventusNova.com