\input{configpres}

\title{YOCTO - Advanced}
\maketitle

\begin{frame}
\frametitle{Agenda}
\begin{itemize}
\item Using BSP layers (sabrelite)
\item Build a predefined image (sabrelite)
\item Define a distribution
\item Create layers \& recipes
\item Create images
\item Yocto \& ELBE combined
\end{itemize}
\end{frame}

\subsection{Using BSP layers}
\begin{frame}[fragile]
\frametitle{get an existing layer}
retrive the layer from your BSP/SoC vendor
\begin{verbatim}
poky % git clone -b daisy https://github.com/Freescale/meta-fsl-arm-extra
\end{verbatim}
have a look at it's dependencies
\begin{verbatim}
poky % cat meta-fsl-arm-extra/conf/layer.conf | grep LAYERDEPENDS
LAYERDEPENDS_fsl-arm-extra = "core fsl-arm"
\end{verbatim}
and retrieve them also
\begin{verbatim}
poky % git clone -b daisy git://git.yoctoproject.org/meta-fsl-arm
\end{verbatim}
check dependencies again
\begin{verbatim}
poky % cat meta-fsl-arm/conf/layer.conf | grep LAYERDEPENDS
\end{verbatim}
\dots no dependencies?! \dots OK - finished.

\vspace{2em}
README says sth. different (openembedded-core) but we have this one already;
it is called 'meta' in poky.
\end{frame}

\begin{frame}
\frametitle{generate a new build environment}
\begin{verbatim}
poky % . oe-init-build-env build-fsl
poky/build-fsl %
\end{verbatim}
\end{frame}

\subsection{Build configuration}
\begin{frame}
\frametitle{overview}
builds are configured using two configuration files
\begin{itemize}
	\item build-fsl/conf/bblayers.conf
	\item build-fsl/conf/local.conf
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{bblayers.conf}
additional layers are added with absolute! path to the BBLAYERS variable
\begin{verbatim}
BBLAYERS ?= " \
  /home/devel/poky/meta \
  /home/devel/poky/meta-yocto \
  /home/devel/poky/meta-yocto-bsp \
  "
\end{verbatim}
\pause
\begin{verbatim}
% bitbake-layers show-layers
layer                 path                                  priority
=====================================================================
meta                  /home/devel/poky/meta                 5
meta-yocto            /home/devel/poky/meta-yocto           5
meta-yocto-bsp        /home/devel/poky/meta-yocto-bsp       5
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{add fsl layers}
modify the BBLAYERS variable in bblayers.conf
\begin{verbatim}
BBLAYERS ?= " \
  /home/devel/poky/meta \
  /home/devel/poky/meta-yocto \
  /home/devel/poky/meta-yocto-bsp \
  /home/devel/poky/meta-fsl-arm \
  /home/devel/poky/meta-fsl-arm-extra \
  "
\end{verbatim}
\pause
\begin{verbatim}
% bitbake-layers show-layers
layer                 path                                  priority
=====================================================================
meta                  /home/devel/poky/meta                 5
meta-yocto            /home/devel/poky/meta-yocto           5
meta-yocto-bsp        /home/devel/poky/meta-yocto-bsp       5
meta-fsl-arm          /home/devel/poky/meta-fsl-arm         5
meta-fsl-arm-extra    /home/devel/poky/meta-fsl-arm-extra   4
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{overlayed recipes}
to see which recipes replace official ones:
\begin{verbatim}
poky/build-fsl % bitbake-layers show-overlayed
Parsing recipes..done.
=== Overlayed recipes ===
directfb:
  meta                 1.7.1
  meta-fsl-arm         1.6.3
directfb-examples:
  meta                 1.7.0
  meta-fsl-arm         1.6.0
xserver-xorg:
  meta                 2:1.15.0
  meta-fsl-arm         2:1.14.4
\end{verbatim}
\end{frame}

\begin{frame}
\frametitle{local.conf}
is used to configure
\begin{itemize}
	\item the target machine
	\item paths
	\item the used distribution
	\item package formats
	\item arch of developer machine
	\item additional image features
	\item use additional classes
	\item enable testing
	\item devshell terminal
	\item patch resolver
	\item disk monitoring
	\item sstate mirrors
	\item qemu configuration
	\item layer priorities
\subsection{Freescale}
\begin{frame}

\begin{frame}[fragile]
\frametitle{configure the machine}
to get a list of currently available machines configs:
\begin{verbatim}
poky/build-fsl % grep -r '@NAME' ../meta*/conf/machine
\end{verbatim}
imx6qsabrelite.conf - seems to be the one for our bord, so set
\begin{verbatim}
MACHINE ??= "imx6qsabrelite"
\end{verbatim}
in conf/local.conf
\end{frame}

\begin{frame}[fragile]
\frametitle{package format}
as we realized with toaster, rpm packaging consumes a lot of CPU time, so lets
try ipk, by setting
\begin{verbatim}
PACKAGE_CLASSES ?= "package_ipk"
\end{verbatim}
in conf/local.conf
\end{frame}

\begin{frame}[fragile]
\frametitle{set extra image features}
we want an image suitable for development, so set
\begin{verbatim}
EXTRA_IMAGE_FEATURES = "debug-tweaks tools-debug eclipse-debug tools-profile"
\end{verbatim}
in conf/local.conf
\end{frame}

\begin{frame}[fragile]
\frametitle{build an predefined image}
use
\begin{verbatim}
ls ../*/*/images/
\end{verbatim}
to get a list of predefined images; however none of them fits my needs\dots
\begin{verbatim}
poky/build-fsl % cd ..
poky % git clone -b daisy https://github.com/Freescale/meta-fsl-demos.git
poky % git clone -b daisy git://git.openembedded.org/meta-openembedded
poky % cd -
\end{verbatim}
and edit conf/bblayers.conf, to match
\begin{verbatim}
BBLAYERS ?= " \
  /home/devel/poky/meta \
  /home/devel/poky/meta-yocto \
  /home/devel/poky/meta-yocto-bsp \
  /home/devel/poky/meta-fsl-arm \
  /home/devel/poky/meta-fsl-arm-extra \
  /home/devel/poky/meta-openembedded/meta-oe \
  /home/devel/poky/meta-fsl-demos \
  "
\end{verbatim}
\end{frame}

\begin{frame}
\frametitle{build a fsl demo image}
\begin{verbatim}
poky/build-fsl % source toaster start
poky/build-fsl % bitbake qt-in-use-image
Currently 4 running tasks (26 of 4459):
\end{verbatim}
\dots coffee break!
\end{frame}

\begin{frame}
\frametitle{define a distribution}
bla
DISTRO\_FEATURES
\end{frame}

\begin{frame}
\frametitle{creating a layer}
bla
\end{frame}

\begin{frame}[fragile]
	\frametitle{meta-*/conf/layer.conf}
	\begin{itemize}
		\item add conf and class directories to BBPATH
			\begin{verbatim}BBPATH =. "${LAYERDIR}"\end{verbatim}
		\pause
		\item add recipe directories to BBFILES
			\begin{verbatim}BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
			${LAYERDIR}/recipes-*/*/*.bbappend"\end{verbatim}
		\pause
		\item add layer name to BBFILE\_COLLECTIONS
			\begin{verbatim}BBFILE_COLLECTIONS += "mylayer"\end{verbatim}
		\pause
		\item set root of the layer
			\begin{verbatim}BBFILE_PATTERN_mylayer = "^${LAYERDIR}/"\end{verbatim}
		\pause
		\item set default priority of the layer
			\begin{verbatim}BBFILE_PRIORITY_mylayer = "5"\end{verbatim}
		\pause
		\item set version of layer (only increment if dependencies with other
			layers are affected)
			\begin{verbatim}LAYERVERSION_mylayer = "2"\end{verbatim}
		\pause
		\item set dependencies to other layers
			\begin{verbatim}LAYERDEPENDS_mylayer = "meta-yocto"\end{verbatim}
	\end{itemize}
\end{frame}

It is possible for a recipe with a lower version number PV in a layer that has a higher priority to take precedence.

Also, the layer priority does not currently affect the precedence order of .conf or .bbclass files. Future versions of BitBake might address this.

itbake-layers <command> [arguments]
                

The following list describes the available commands:

    help: Displays general help or help on a specified command.

    show-layers: Shows the current configured layers.

    show-recipes: Lists available recipes and the layers that provide them.

    show-overlayed: Lists overlayed recipes. A recipe is overlayed when a recipe with the same name exists in another layer that has a higher layer priority.

    show-appends: Lists .bbappend files and the recipe files to which they apply.

    show-cross-depends: Lists dependency relationships between recipes that cross layer boundaries.

    flatten: Flattens the layer configuration into a separate output directory. Flattening your layer configuration builds a "flattened" directory that contains the contents of all layers, with any overlayed recipes removed and any .bbappend files appended to the corresponding recipes. You might have to perform some manual cleanup of the flattened layer as follows:

        Non-recipe files (such as patches) are overwritten. The flatten command shows a warning for these files.

        Anything beyond the normal layer setup has been added to the layer.conf file. Only the lowest priority layer's layer.conf is used.

        Overridden and appended items from .bbappend files need to be cleaned up. The contents of each .bbappend end up in the flattened recipe. However, if there are appended or changed variable values, you need to tidy these up yourself. Consider the following example. Here, the bitbake-layers command adds the line #### bbappended ... so that you know where the following lines originate:

             ...
             DESCRIPTION = "A useful utility"
             ...
             EXTRA_OECONF = "--enable-something"
             ...

             #### bbappended from meta-anotherlayer ####

             DESCRIPTION = "Customized utility"
             EXTRA_OECONF += "--enable-somethingelse"
                                        

        Ideally, you would tidy up these utilities as follows:

             ...
             DESCRIPTION = "Customized utility"
             ...
             EXTRA_OECONF = "--enable-something --enable-somethingelse"

$ yocto-layer create mylayer

\begin{frame}
\frametitle{adding a kernel}
bla
\end{frame}

\begin{frame}
\frametitle{adding own applications}
already available? check http://layers.openembedded.org
bla
\end{frame}

use PR Service

Package Groups
•Package Group Recipe
  DESCRIPTION = “My Package Group”
  LICENSE = “MIT”
  LIC_FILES_CHECKSUM = “file://<licfile>;md5=<chksum>
  inherit packagegroup
  PROVIDES = “${PACKAGES}”
  PACKAGES = “packagegroup-mypkg-apps packagegroup-mypkg-tools”
  RDEPENDS_packagegroup-mypkg-apps = “sqlite3 python-core python-sqlite3”
  RDEPENDS_pacakgegroup-mypkg-tools = “sudo gzip tar”
•Image Recipe
  IMAGE_INSTALL = “packagegroup-core-boot packagegroup-mypkg-apps”
  Inherit core-image



\begin{frame}
\frametitle{create bootable images for x86}
t.b.d.

The boot-directdisk class creates an image that can be placed directly onto a
hard disk using dd and then booted. The image uses SYSLINUX.

The end result is a 512 boot sector populated with a Master Boot Record (MBR)
and partition table followed by an MSDOS FAT16 partition containing SYSLINUX
and a Linux kernel completed by the ext2 and ext3 root filesystems.
\end{frame}

\begin{frame}[fragile]
\frametitle {bootable image for embedded device}
t.b.d. use IMAGE\_FEATURES
% http://www.yoctoproject.org/docs/1.6/ref-manual/ref-manual.html#ref-features-image

% http://www.yoctoproject.org/docs/1.6/dev-manual/dev-manual.html#usingpoky-extend-customimage-imagefeatures
\end{frame}

\begin{frame}[fragile]
\frametitle{user and group configuration}
use this in an image recipe:
\begin{verbatim}
inherit extrausers
EXTRA_USERS_PARAMS = "\
    useradd -p '' tester; \
    groupadd developers; \
    userdel nobody; \
    groupdel -g video; \
    groupmod -g 1020 developers; \
    usermod -s /bin/sh tester; \
    "
\end{verbatim}
or the useradd class, for an example see useradd-example.bb
\end{frame}

\begin{frame}[fragile]
\frametitle{external sources}
e.g. for a heavily customized kernel
\begin{itemize}
\item kernel source directory on the development machine
\item inherit externalsrc class
\item set EXTERNALSRC variable to point to your external source code
\end{itemize}

this local.conf extension:
\begin{verbatim}
INHERIT += "externalsrc"
EXTERNALSRC_pn-myrecipe = "/some/path/to/your/source/tree"
\end{verbatim}
overrides the SOURCE\_URI of pn-myrecipe.bb
\end{frame}

\begin{frame}[fragile]
\frametitle{blacklist packages}
To blacklist a package, inherit the blacklist.bbclass globally and set
PNBLACKLIST for each recipe you wish to blacklist.


Specify the PN value as a variable flag (varflag) and provide a reason,
which is reported, if the package is requested to be built as the value:
\begin{verbatim}
INHERIT += "blacklist"
PNBLACKLIST[exoticware] = "Not supported by our organization."
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Providers}
\begin{verbatim}
--8<- -my-kernel\_3.16.bb --
PROVIDES += "virtual/kernel"
--8<------------------------
\end{verbatim}

PREFEREED\_PROVIDER\_virtual/kernel = "linux-yocto"
\end{frame}

\begin{frame}
\frametitle{Preferences}
\begin{itemize}
\item PREFERRED\_VERSION is used to specify a particular version
\item by default, files have a preference of "0"
\item setting DEFAULT\_PREFERENCE to "-1" makes the recipe unlikely to be used
	unless it is explicitly referenced.
\item setting DEFAULT\_PREFERENCE to "1" makes it likely the recipe is used
\item PREFERRED\_VERSION overrides any DEFAULT\_PREFERENCE setting
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Yocto \& ELBE combined}
	bla
\end{frame}

\input{tailpres}
