Hello everyone!
In this document you'll find an example on how to setup your own recipe for Yocto Project to add your own custom changes, such as custom device tree, patches, custom drivers, etc.
Linux kernel used in this guide 6.1.36_2.1.0
At least 120(250)GB HDD in the host PC
Ubuntu 20.04 or later host PC
##Host Setup
$ sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev python3-subunit mesa-common-dev zstd liblz4-tool file locales -y
$ sudo locale-gen en_US.UTF-8
##Setup Repo utility
$ mkdir ~/bin (this step may not be needed if the bin folder already exists)
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH
##Git Setup
$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"
$ git config --list
##Yocto Setup
$ mkdir imx-yocto-bsp
$ cd imx-yocto-bsp
$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-mickledore -m imx-6.1.36-2.1.0.xml
$ repo sync
$ DISTRO=fsl-imx-wayland MACHINE=imx8mp-lpddr4-evk source imx-setup-release.sh -b buildwayland
##Create the new layer
$ cd ../sources
$ bitbake-layers create-layer meta-newlayer
##Add the new layer to the bblayers.conf in the build directory
$ bitbake-layers add-layer meta-newlayer
##Check that it has been added correctly
$ tree -L 4 ./meta-newlayer
##Edit the new layer and delete the samples created by yocto
$ cd meta-newlayer
$ rm -r recipes-example
$ rm conf/layer.conf
##Use any text editor to create the layer configuration
$ nano conf/layer.conf
##Add the following to the layer configuration file
BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "meta-newlayer"
BBFILE_PATTERN_meta-newlayer := "^${LAYERDIR}/"
BBFILE_PRIORITY_meta-newlayer = "8"
LAYERSERIES_COMPAT_meta-newlayer = "mickledore"
##Prepare bbappend files so the patches get applied
$ mkdir -p recipes-kernel/linux
$ cd recipes-kernel/linux
$ nano linux-imx_%.bbappend
##Add the following to the .bbappend file
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += "file://001-add-imx8mp-dts-test.patch"
PACKAGE_ARCH = "${MACHINE_ARCH}"
KERNEL_DEVICETREE:append = " freescale/imx8mp-evk-test.dtb"
##Copy the patches to the layer file path, for this example I have created a simple patch to just rename the default device tree.
$ mkdir files
$ cp ~/patches/001-add-imx8mp-dts-test.patch files
##Make sure that the layers is created correctly
$ bitbake-layers show-layers
##Finally we bitbake our image
$ cd ~/imx-yocto-bsp/buildwayland
$ bitbake imx-image-multimedia
#All the images built should appear at <build directory>/tmp/deploy/images/<machine>
Hope everyone finds this useful!
For any question regarding this document, please create a community thread and tag me if needed.
Saludos/Regards,
Aldo.