Build the BSP

This guide will walk through setting up and building the BSP in order to generate default software images for the phyCORE-i.MX8X development kit. Once the BSP is built, it can serve as a starting point for which you can apply changes on-top to suit the needs of your application and system design.

Note

You do not need to build the BSP to begin evaluating the default phyCORE-i.MX8X development kit. Please start by working through the Quickstart if you just received your development kit. You can also create a bootable SD Card using Pre-Built Binaries and evaluate the development kit’s standard peripherals by following the Interface Guides. You can also jump right into Application Development by working with a pre-built SDK.

Requirements

The following system requirements are necessary to successfully follow this BSP Development Guide. Deviations from these requirements may or may not have other workarounds:

  • Ubuntu 18.04 LTS, 64-bit Host Machine with root permission

    If using a virtual machine, VMWare Workstation, VMWare Player, and VirtualBox are all viable solutions.

  • 200GB or greater free disk space

  • 8GB or greater of RAM

  • 4x processing cores or greater available to the Ubuntu Host Machine

  • SD card reader operational under Linux

  • Active Internet connection

Host Setup

Yocto development requires certain packages to be installed on the host machine to satisfy the build requirements. Run the following commands to ensure these are installed:

Host (Ubuntu)
sudo apt-get update
sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python python3 python3-pip python3-pexpect xz-utils libsdl1.2-dev curl vim libyaml-dev

The above is the recommended package installation for Yocto development on an Ubuntu 18.04 LTS Linux distribution, it also includes a couple recommended packages from PHYTEC. For a breakdown of the packages, as well as a list of packages required for other Linux distributions, see the “Required Packages for the Host Development System” section in the Yocto Project Reference Manual.

Verify that the preferred shell for your Host PC is ‘’bash’’ and not ‘’dash’’:

Host (Ubuntu)
sudo dpkg-reconfigure dash
# Respond "No" to the prompt asking "Install dash as /bin/sh?"

Install the ‘repo’ tool:

Host (Ubuntu)
mkdir -p ~/.bin
PATH="${HOME}/.bin:${PATH}"
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+rx ~/.bin/repo

Git

If you have not yet configured your git environment on the Host Machine, please execute the following commands to set your user name and email address:

Host (Ubuntu)
git config --global user.email "[email protected]"
git config --global user.name "Your Name"

Note

New to git? See here for more information about getting started with git: https://git-scm.com/

Setup and Build the BSP

Firstly, dedicate a directory on your Host Machine for housing the BSP and navigate there:

Host (Ubuntu)
mkdir ~/BSP-Yocto-FSL-i.MX8X-PD21.1.0
cd ~/BSP-Yocto-FSL-i.MX8X-PD21.1.0

Download the BSP Meta Layers

Note

There was a significant change to the git protocol recently that impacts this BSP version’s manifest: https://github.blog/2021-09-01-improving-git-protocol-security-github/

In order to successfully synchronize your host environment with the repositories called for in the BSP manifest, you will need to modify your git config in the following way:

Host (Ubuntu)
echo -e '[url "https://github.com/"]\n  insteadOf = "git://github.com/"' >> ~/.gitconfig

Yocto based Linux BSPs are comprised of many meta-layers each containing recipes for fetching, building and packaging various components destined for the bootable software image. Some meta-layers are provided by the Linux community, such as meta-python for example. Other meta-layers are more platform specific and are made available by PHYTEC or the silicon vendor. All the meta-layers required by PHYTEC’s Linux BSP are outlined in a manifest file which we can give to the Repo Tool:

Host (Ubuntu)
repo init -u https://stash.phytec.com/scm/pub/manifests-phytec.git -b imx8x -m BSP-Yocto-FSL-i.MX8X-PD21.1.0.xml
repo sync

When the above process is completed, the meta-layers and the recipes they contain are all checked out to the ~/BSP-Yocto-FSL-i.MX8X-PD21.1.0/sources directory.

Initialize the BSP Environment

Source the build environment and setup a ‘build’ directory ($BUILDDIR will be automatically exported here and it will reflect the name of the ‘build’ directory that is provided):

Host (Ubuntu)
export TEMPLATECONF=`pwd`/sources/meta-phytec/meta-phytec-fsl/conf/
source sources/poky/oe-init-build-env build

The TEMPLATECONF variable is set first to specify the default build configuration files to be used by the build system. These configuration files include the conf/bblayers.conf and conf/local.conf from meta-phytec.

Note

You will need to ‘source’ the BSP build environment every time you intend to build the BSP in a new Terminal session.

Configure the Build

We’ll need to make some small changes to the build’s configuration file prior to kicking off the build. Open the build’s configuration file using your favorite text editor. This guide will use vim in order to modify the file directly in the terminal:

Host (Ubuntu)
vim conf/local.conf

Note

vim is perhaps the most popular command line text editor in Linux but it’s not the only way to modify text files. If you are new to vim, try out this interactive tutorial for vim to get an introduction: https://www.openvim.com/.

Modify conf/local.conf after considering the following:

  • Note the MACHINE variable being set in the conf/local.conf. This variable is used to define the machine configuration the target image will be built for and it should equal ‘imx8x-phycore-kit’ by default.

  • Once you have built a custom embedded system around the phyCORE-i.MX8X, you can consolidate your modifications to your own custom meta-layer and build images for that system via the MACHINE variable. Documentation on this process is coming soon!

  • The variables BB_NUMBER_THREADS and PARALLEL_MAKE can be used to limit the maximum number of parallel tasks and threads used by the build system. By default, both of these are set to 4 and should not exceed the number of cores available to the Host Machine.

conf/local.conf
# Parallelism options - based on cpu count
BB_NUMBER_THREADS ?= "4"
PARALLEL_MAKE ?= "-j 4"
  • Read the file ~/BSP-Yocto-FSL-i.MX8X-PD21.1.0/sources/meta-imx/EULA.txt and add the following to the end of your conf/local.conf if you accept:

conf/local.conf
 ACCEPT_FSL_EULA = "1"
  • Remember to save your changes before closing the file.

Start the Build

Use the following commands to navigate to the build directory (if you aren’t already there) and start the build process for the phyCORE-i.MX8X Linux BSP:

Host (Ubuntu)
cd $BUILDDIR
bitbake imx-image-multimedia

This command instructs the bitbake build system to run all the tasks associated with the imx-image-multimedia build target, which is the default image used by PHYTEC to validate the BSP-Yocto-FSL-i.MX8X-PD21.1.0 release.

Note

Depending on the resources available on the Host Machine, this build process can take a long time to complete the first time. Subsequent builds introducing incremental changes can be completed MUCH faster because the build system can intelligently re-build only what is necessary.

Ideally, the BSP is built on a dedicated build server with a high core/thread count.

Components of a Built BSP

All generated images deployed during the build can be found in the $BUILDDIR/tmp/deploy/images/imx8x-phycore-kit/ directory.

BSP Components

Component

Filename

Details

SD Image

imx-image-multimedia-imx8x-phycore-kit.sdcard.bz2

Complete SD Card image in compressed format, can be flashed directly to boot media.

Bootloader

imx-boot-imx8x-phycore-kit-sd.bin-flash

u-boot.bin

Includes U-Boot, System Controller Firmware, SECO Firmware, and i.MX Arm Trusted Firmware

Standalone U-Boot binary; needs to be packaged with other binaries using NXP’s imx-mkimage tool to create complete bootloader image

Kernel

Image

Linux Kernel

Kernel Device Tree Files

phytec-imx8qxp-phycore-rdk-emmc.dtb

phytec-imx8qxp-lvds0-peb-lvds-01.dtbo

phytec-imx8qxp-parallel-camera.dtbo

phytec-imx8qxp-uart2.dtbo

phytec-imx8qxp-wifi.dtbo

Base Kernel DTB

DTB overlay for LCD-018 support

DTB overlay for phyCAM-P support

DTB overlay to enable UART2 and disable CAN

DTB overlay to enable WIFI

Root Filesystem

imx-image-multimedia-imx8x-phycore-kit.tar.bz2

Filesystem in compressed tar format

With these output files generated, checkout the Create a Bootable SD Card guide to use them to boot the hardware.

Source Locations

During the build process, the source repositories for various image components included in the BSP are unpacked locally in the build directory. The kernel and bootloader sources, for example, can be found at the following locations in the built PD21.1.0 Linux BSP.

Kernel: $BUILDDIR/tmp/work/imx8x_phycore_kit-poky-linux/linux-phytec-fsl/5.4.24-r0/git

  • The main device tree file for the phyCORE-i.MX8X development kit within the Linux kernel source: arch/arm64/boot/dts/phytec/phytec-imx8qxp-phycore-rdk-emmc.dts and its dependencies

  • Device tree overlays can be found in the same directory: arch/arm64/boot/dts/phytec/phytec-imx8qxp-<interface>.dtso

  • The phyCORE-i.MX8X kernel defconfig can be found at: arch/arm64/configs/imx8x_phycore_kit_defconfig

U-Boot: $BUILDDIR/tmp/work/imx8x_phycore_kit-poky-linux/u-boot-phytec/1_2020.04-2.1.0/git

  • Board file is located at: board/phytec/pcm065/pcm065.c

  • Device tree file: arch/arm/dts/phytec-imx8qxp-kit.dts

  • Device tree overlays: arch/arm/dts/phytec-imx8qxp-<interface>.dtso

Building the SDK Installer

Once you have successfully followed the steps outlined above for building the BSP, you can similarly build the SDK installer.

Warning

There is a known issue related to running the populate_sdk task for the imx-image-multimedia target in BSP PD21.1.0 and you must implement the following workaround in order to successfully build the SDK installer:

Add the following line to the end of your conf/local.conf when building the SDK installer:

conf/local.conf
PACKAGE_EXCLUDE += "linux-firmware"

This line can be commented when building images otherwise. Adding this line to the local build configuration will cause the build system to exclude some firmware packages that are not needed for full operation of the development kit interfaces. Otherwise, the populate_sdk task will fail due to some conflicts that were overlooked at the time of release. This issue is planned to be fixed in a future release.

Build the SDK installer:

Host (Ubuntu)
cd $BUILDDIR
bitbake imx-image-multimedia -c populate_sdk

The SDK installer will be deployed to $BUILDDIR/tmp/deploy/sdk

Note

For technical support, please visit PHYTEC’s Support Portal