Customizing the BSP

This page describes how to add a custom layer to our NXP BSP. You will also get an idea how Yocto recipes work and how you can create your own image.

Your possibilities with Yocto are endless - if you know how to use it. The sections below shall just give common examples and an easier entry.

Further information can be found in the Yocto Project Documentation.

Hint

All below commands are examples and have to be fitted to your needs.

Set up your build-directory with the desired machine and distro like explained in BSP Setup.

DISTRO=karo-minimal MACHINE=tx8m-1610 source karo-setup-release.sh -b build-tx8m-1610

Kernel & Devicetree

The following steps describe how Kernel and Devicetree can be modified.
You can use these steps to develop Kernel and Devicetree fitted to your needs.
Once you’re done you can read further to persist your changes.

Create Custom Layer

To persist your developed changes and extend our BSP the best way is to create your own layer.

Use bitbake-layers to create a new layer.

bitbake-layers create-layer ../sources/meta-custom

This creates an empty example layer for you:

../sources/meta-custom/
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
    └── example
        └── example_0.1.bb

3 directories, 4 files

To make your layer available, add it to conf/bblayers.conf inside your build-directory.

(...)
BBLAYERS += "${BSPDIR}/sources/meta-karo-nxp"
BBLAYERS += "${BSPDIR}/sources/meta-karo-distro"
BBLAYERS += "${BSPDIR}/sources/meta-custom"

Append Kernel Recipe

You can remove the recipes-example folder inside your custom layer. Instead add a folder recipes-kernel with different subdirectories.

rm -rf ../sources/meta-custom/recipes-example/
mkdir -p ../sources/meta-custom/recipes-kernel/linux/linux-karo/patches
mkdir ../sources/meta-custom/recipes-kernel/linux/linux-karo/mx8

Now create the *.bbappend file to extend the kernel recipe.

touch ../sources/meta-custom/recipes-kernel/linux/linux-karo_%.bbappend

The content of linux-karo_%.bbappend could be something like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}/patches:${THISDIR}/${PN}:"
SRC_URI:append = " \
    file://custom_defconfig;subdir=git/arch/arm64/configs \
      file://0001-custom-magic-kernel-source.patch \
"

SRC_URI:append:mx8-nxp-bsp = " \
      file://dts/freescale/imx8mm-tx8m-1610-customboard.dts;subdir=git/arch/arm64/boot \
"

KBUILD_DEFCONFIG:tx8m-1610 = "custom_defconfig"

KERNEL_DEVICETREE:append:tx8m-1610 = " \
    freescale/imx8mm-tx8m-1610-customboard.dtb \
"

The files in your custom-layer then would look like this:

../sources/meta-custom/
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-kernel
    └── linux
        ├── linux-karo
        │   ├── mx8-nxp-bsp
        │   │   ├── custom_defconfig
        │   │   └── dts
        │   │       └── freescale
        │   │           └── imx8mm-tx8m-1610-customboard.dts
        │   └── patches
        │       └── 0001-custom-magic-kernel-source.patch
        └── linux-karo_%.bbappend

8 directories, 7 files

Tip

Build your modified Kernel Recipe.

bitbake linux

This will compile and deploy your modified Kernel and additionally the Devicetree you added.

Note

The way you expanded our kernel recipe, you can customize any recipe inside the BSP. You can use our layers as a reference if unsure what you can do.

You can also add new recipes.

Create Custom Image

To add a custom image you can add a new recipe under recipes-core/images. Your custom layer will then look like this:

../sources/meta-custom/
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
├── recipes-core
│   └── images
│       └── custom-image.bb
└── recipes-kernel
    └── linux
        ├── linux-karo
        │   ├── mx8-nxp-bsp
        │   │   ├── custom_defconfig
        │   │   └── dts
        │   │       └── freescale
        │   │           └── imx8mm-tx8m-1610-customboard.dts
        │   └── patches
        │       └── 0001-custom-magic-kernel-source.patch
        └── linux-karo_%.bbappend

10 directories, 8 files

The custom-image.bb below would include the karo-image-weston as basis and additionally add the pip3 python package manager.

1
2
3
4
5
6
7
SUMMARY = "A custom image with Weston desktop"

require recipes-core/images/karo-image-weston.bb

IMAGE_INSTALL:append = " \
                       python3-pip \
"

Tip

Build your custom image.

bitbake custom-image

With this example you would get the desired weston desktop image with included pip3.

U-Boot Default Environment

An example default environment file from tx8m-1610 can be found on GitHub.

https://github.com/karo-electronics/karo-tx-uboot/blob/lf_v2020.04-karo/board/karo/tx8m/tx8m-1610_env.txt

To update the default environment of u-boot, simply overwrite the desired env file via SRC_URI in u-boot recipe with something like:

1
SRC_URI:append = " file://<modulename>_env.txt;subdir=git/board/karo/tx8m"