AMF-AUT-T3891-Yocto Project 101 - Rev
AMF-AUT-T3891-Yocto Project 101 - Rev
Bryan Thomas
Field Applications Engineer
Company Public – NXP, the NXP logo, and NXP secure connections for a smarter world are trademarks of NXP
B.V. All other product or service names are the property of their respective owners. © 2019 NXP B.V.
Agenda
• i.MX8 Reference Boards
• Linux Introduction
• Yocto Introduction
• NXP Yocto BSP Release
• Host Machine Setup
• Yocto Setup
• Running a Yocto Build
• Using the Results
• Finding Help
COMPANY PUBLIC 1
i.MX8 Reference Boards
COMPANY PUBLIC 2
Linux Introduction
What is Linux?
Obtaining and Installing a Linux Distribution
The Terminal
COMPANY PUBLIC 3
Yocto Project: What is Linux?
• Linux is an operating system
• GNU/Linux is a collection of programs and the Linux kernel that
forms the Operating System
• Many of the components of are licensed under an open source
license such as the General Public License (GPL)
• The open source nature of Linux allows you to view the source code
of many of the components of the system
COMPANY PUBLIC 4
Yocto Project: Obtaining and Installing a Linux Distribution
• Select a distribution that others within your company are using.
• If you are completely new to Linux then pick a distribution like
Debian, Fedora, or Ubuntu
• Distributions are distributed as iso files that can be written to a
CD/DVD or USB flash Drive
COMPANY PUBLIC 5
Yocto Project: Obtaining and Installing a Linux Distribution
• Use https://rufus.ie/ to flash an iso to a USB flash drive
COMPANY PUBLIC 6
Yocto Project: Obtaining and Installing a Linux Distribution
• Set the computer to boot from USB and insert the flash drive into one
of the USB ports
• Some distributions have LIVE preview modes that run out of RAM
and allow you to try out the distribution before installing
• Follow the installation guides available on the distribution’s
homepage to install
• 500 GB is a good size for an install hard disk
COMPANY PUBLIC 7
Yocto Project: The Terminal
• The terminal will be your new home!
• Cheat sheet (http://overapi.com/linux/)
COMPANY PUBLIC 8
Yocto Introduction
What is the Yocto Project?
Yocto Project Development Environment
Yocto Project Components
Yocto Project Documentation
COMPANY PUBLIC 9
Yocto Project: What is the Yocto Project?
• Open-source collaborative project focused on embedded Linux
development
• Currently provides a build system that is referred to as OpenEmbedded
build system in the Yocto Project Documentation
• Helps developers create custom Linux-based systems for embedded
products
• Source: http://www.yoctoproject.org/docs/current/yocto-project-qs/yocto-
project-qs.html
COMPANY PUBLIC 10
Yocto Project: Yocto Project Development Environment
COMPANY PUBLIC 11
Yocto Project: Yocto Project Components
Poky
• Poky is a reference system of the Yocto Project - a collection of Yocto
Project tools and metadata that serves as a set of working examples. To
use the Yocto Project tools, you can download Poky and use it to bootstrap
your own distribution.
• Poky is the platform-independent, cross-compiling integration layer that
utilizes OpenEmbedded Core. It provides the mechanism to build and
combine thousands of distributed open source projects together to form a
fully customizable, complete, coherent Linux software stack.
• Poky's objective is to provide all the features and functionalities an
embedded developer needs from one solution.
Source: https://www.yoctoproject.org/tools-resources/projects/poky
COMPANY PUBLIC 12
Yocto Project: Yocto Project Components
• BitBake is a build engine that follows recipes in a specific format in
order to perform sets of tasks. BitBake is a core component of the
Yocto Project.
COMPANY PUBLIC 13
Yocto Project: Yocto Project Documentation
The Yocto Project documentation is available on the Yocto Project
website: (https://www.yoctoproject.org/documentation)
Recommended Reading:
1. Yocto Project Quick Start (Link)
2. BitBake User Manual (Link)
3. Yocto Project Reference Manual (Link)
COMPANY PUBLIC 14
NXP Yocto Release
Introduction to the NXP Yocto BSP Release
Obtaining the NXP Yocto Release
COMPANY PUBLIC 15
Yocto Project: NXP Yocto BSP Release
The NXP Yocto BSP Release is an extension
of OpenEmbedded and Poky that supports
NXP reference boards
COMPANY PUBLIC 16
Yocto Project: Obtaining the NXP Yocto BSP Release
The NXP Yocto BSP Release is available from our website under
Software & Tools Section (Link)
COMPANY PUBLIC 17
i.MX Linux Roadmap
Yocto Project 2.2 – “Morty” Yocto Project 2.4 – “Rocko” Yocto Project 2.5 – “Sumo”
GA
J F M A M J J A S O N D J F M A M J J A S O N D J F M
1Q 2Q 3Q 4Q 1Q 2Q 3Q 4Q 1Q
GA
COMPANY PUBLIC 19
Yocto Project: A Suitable Host Machine
• Depending on the number of processors and cores, the amount of
RAM, the speed of your Internet connection and other factors, the
build process could take several hours the first time you run it.
Subsequent builds run much faster since parts of the build are
cached.
• Multiple build directories can consume large amounts of hard drive
space
• Virtual Machines are not recommended for daily development
COMPANY PUBLIC 20
Yocto Project: Supported Linux Distributions
Each Yocto release adds additional supported distributions. Other distributions can also work but are not specifically tested by
the Yocto Project.
These are supported by Sumo:
• Ubuntu 14.10
• Ubuntu 15.04
• Ubuntu 15.10
• Ubuntu 16.04 (LTS)
• Fedora release 22
• Fedora release 23
• CentOS release 7.x
• Debian GNU/Linux 8.x (Jessie)
• Debian GNU/Linux 9.x (Stretch)
• openSUSE 13.2
• openSUSE 42.1
COMPANY PUBLIC 21
Yocto Project: Required Host Packages
The list of packages you need on the host development system can be large when
covering all build scenarios using the Yocto Project
COMPANY PUBLIC 22
Yocto Project: Required Host Packages
Fedora based distributions:
Essential packages
$ sudo dnf install gawk make wget tar bzip2 gzip python3 unzip perl patch \
diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \
ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue perl-bignum socat \
python3-pexpect findutils which file cpio python python3-pip xz
Documentation packages
$ sudo dnf install make docbook-style-dsssl docbook-style-xsl docbook-dtds docbook-utils fop
libxslt dblatex xmlto
OpenEmbedded Self-Test
$ sudo dnf install python3-GitPython
COMPANY PUBLIC 23
Yocto Project: Repo
What is Repo?
• Repo is a tool that Google built on top of Git
• Repo helps manage many Git repositories
• Repo is not meant to replace Git
• The repo command is an executable Python script that you can put
anywhere in your path
COMPANY PUBLIC 24
Yocto Project: Repo
Installing Repo
Source (Link)
COMPANY PUBLIC 25
Yocto Project: Repo
Adding ~/bin directory to your path
• Debian with BASH, other distributions will vary slightly
Temporary:
$ export PATH=/home/YOURUSERNAME/bin:$PATH
$ source .bashrc
Permanent:
$ vim .profile
+ if [ -d "$HOME/bin" ] ; then
+ PATH="$HOME/bin:$PATH"
+ fi
* NOTE: most distros include ~/bin in your default path, the
directory just doesn’t exist!
COMPANY PUBLIC 26
Yocto Setup
Repo Initialization
Repo Sync
Sourcing a Build
COMPANY PUBLIC 27
Yocto Project: Repo Initialization
• We will use repo to pull our Yocto sources from multiple Git trees based on the
manifest for the particular branch we are using. In this case we will use the
current GA release based on the previous Yocto Project release
• Git.freescale.com (Link)
• If we look in the directory we only see that a hidden directory has been created
called .repo. This directory contains information that tells repo what Git
repositories and commits to pull into our directory. Repo doesn’t pull the source
until we run the sync command.
COMPANY PUBLIC 28
Yocto Project: Repo Initialization
COMPANY PUBLIC 29
Yocto Project: Repo Initialization
COMPANY PUBLIC 30
Yocto Project: Repo Sync
Some output
omitted for clarity
COMPANY PUBLIC 31
Yocto Project: Repo Sync
• After the sync command completes the source directory will contain a setup script and a
sources directory.
├── fsl-setup-release.sh
├── README
├── README-IMXBSP
├── setup-environment
└── sources
1 directory, 4 files
COMPANY PUBLIC 32
Yocto Project: Sourcing a Build
• Now you need to pick a machine type that you want to set up to build. These machines are available in the specific
<layer>/conf/machine/*.conf files
• You can find available machines with the following command in your yocto top directory
$ ls sources/meta-fsl-*/imx/meta-bsp/conf/machine/*.conf
sources/meta-fsl-arm/conf/machine/imx23evk.conf
sources/meta-fsl-arm/conf/machine/imx28evk.conf
sources/meta-fsl-arm/conf/machine/imx31pdk.conf
sources/meta-fsl-arm/conf/machine/imx35pdk.conf
sources/meta-fsl-arm/conf/machine/imx51evk.conf New Machines!!
sources/meta-fsl-arm/conf/machine/imx53ard.conf
sources/meta-fsl-arm/conf/machine/imx53qsb.conf
imx8qxpmek
sources/meta-fsl-arm/conf/machine/imx6dlsabreauto.conf
sources/meta-fsl-arm/conf/machine/imx6dlsabresd.conf
imx8qmmek
sources/meta-fsl-arm/conf/machine/imx6qsabreauto.conf
sources/meta-fsl-arm/conf/machine/imx6qsabresd.conf
sources/meta-fsl-arm/conf/machine/imx6slevk.conf
sources/meta-fsl-arm/conf/machine/imx6solosabreauto.conf
sources/meta-fsl-arm/conf/machine/imx6solosabresd.conf
sources/meta-fsl-arm/conf/machine/twr-vf65gs10.conf
COMPANY PUBLIC 33
Yocto Project: Sourcing a Build
• The machine name tells setup script which board you will be using for
development
COMPANY PUBLIC 34
Yocto Project: Sourcing a Build
COMPANY PUBLIC 35
Yocto Project: Sourcing a Build
• The setup script will create the conf directory and copy some files that are
needed to create the build. When the script is completed you will be placed into
the build directory that you specified. We will use bitbake to spawn off the build
from inside this directory
user@machine:~/projects/nxp/imx/linux-bsp/imx-yocto-bsp/build-xwayland$ tree
.
└── conf
├── bblayers.conf
├── bblayers.conf.org
├── local.conf
├── local.conf.org
├── local.conf.sample
└── templateconf.cfg
COMPANY PUBLIC 36
Yocto Project: Optimizing Host Machine
• <build>/conf/local.conf has a few options that you can change in order to speed up building on your host machine
MACHINE ??= ‘imx8qxpmek'
DISTRO ?= ‘fsl-imx-xwayland'
PACKAGE_CLASSES ?= "package_rpm"
EXTRA_IMAGE_FEATURES = "debug-tweaks"
USER_CLASSES ?= "buildstats image-mklibs image-prelink"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS = "\
STOPTASKS,${TMPDIR},1G,100K \
STOPTASKS,${DL_DIR},1G,100K \
STOPTASKS,${SSTATE_DIR},1G,100K \
ABORT,${TMPDIR},100M,1K \
ABORT,${DL_DIR},100M,1K \
ABORT,${SSTATE_DIR},100M,1K“
PACKAGECONFIG_append_pn-qemu-native = “ sdl”
PACKAGECONFIG_append_pn-nativesdk-qemu = “ sdl”
CONF_VERSION = "1"
DL_DIR ?= "${BSPDIR}/downloads/” <- make a common directory if you have several builds
SSTATE_DIR ?= "/share/sstate-cache“ <- make a common directory to speed builds
ACCEPT_FSL_EULA = ””
COMPANY PUBLIC 37
Running a Yocto Build
Using BitBake
First Build Time
COMPANY PUBLIC 38
Yocto Project: Using BitBake
• Now we use bitbake to spawn off the build
• <image-name> are images that are provided from the release. We can find them with find . –name
fsl-image* from the yocto top directory
COMPANY PUBLIC 39
Yocto Project: Using BitBake
COMPANY PUBLIC 40
Yocto Project: First Build Time
• The first build can take up to several hours depending on the speed
of your machine
• Subsequent builds will take much less time because the built
packages are cached to improved build times
• Only modified or added recipes will be built and deployed in the
subsequent builds
COMPANY PUBLIC 41
Using the Results
Location of the Build Output
Flashing SD Card Image
COMPANY PUBLIC 42
Yocto Project: Location of the Build Output
• The build output is inside the ../tmp/deploy/images directory in the build directory
you created:
user@machine:~/projects/nxp/imx/linux-bsp/imx-yocto-
bsp/yocto/build-xwayland/tmp/deploy/images/imx8qxpmek$ ls
*** More file are in the directory but here is a sample ***
fsl-image-gui-imx8qxpmek-20190921000528.rootfs.tar.bz2
fsl-image-gui-imx8qxpmek-20190921000528.rootfs.sdcard
uImage
u-boot.imx
fsl-image-gui-imx8qxpmek.sdcard
COMPANY PUBLIC 43
Yocto Project: Flashing SD Card Image
• Inside the images directory there is a .sdcar image file that is a
complete SD card image that can be flashed and used on the
reference board.
• Use dmesg or lsblk to find the name of your disk (sdX)
COMPANY PUBLIC 44
Yocto Project: Finding Help
• Community.NXP.com
• Meta-NXP mailing list
• Yocto Project Documentation
COMPANY PUBLIC 45
NXP and the NXP logo are trademarks of NXP B.V. All other product or service names are the property of their respective owners. © 2019 NXP B.V.