\documentclass[aspectratio=169,obeyspaces,spaces,hyphens]{beamer}
\usepackage{minted}
\usepackage{newunicodechar}
\usepackage{hyperref}
\usepackage[font=scriptsize,labelfont=bf]{caption}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{xcolor}

\newcommand*\tick{\item[\checkmark]}
\definecolor{mycolor}{RGB}{255,255,255}

\DeclareCaptionFont{tiny}{\tiny}

\mode<presentation>
\usetheme{Bootlin}

\title{Introduction to the Yocto Project / OpenEmbedded-core}
\authors{Mylène Josserand}
\email{mylene@bootlin.com}
\slidesurl{http://bootlin.com/pub/conferences/2017/embedded-recipes/josserand-introduction-to-yocto-project/}
\conference{Embedded Recipes Conference - 2017}

\begin{document}

\begin{frame}{\insertconference}
  \fontsize{19}{19}\selectfont
  Introduction to the Yocto Project / \\OpenEmbedded-core\\
  \begin{columns}
    \column{0.6\textwidth}
    \fontsize{15}{15}\selectfont
    Mylène Josserand \\
    Bootlin \\
    \normalsize
    {\em \insertemail}
    \column{0.4\textwidth}
    \includegraphics[width=0.8\textwidth]{common/logo-square.pdf}\\
  \end{columns}
\end{frame}

\begin{frame}{Mylène Josserand}
  \begin{columns}
    \column{0.6\textwidth}
    \begin{itemize}
    \item Embedded Linux engineer at Bootlin since 2016
      \begin{itemize}
      \item Embedded Linux {\bf expertise}
      \item {\bf Development}, consulting and training around the Yocto Project
      \item One of the authors of Bootlin' {\bf Yocto Project / OpenEmbedded}
        training materials.
      \end{itemize}
    \item Kernel contributor: audio driver, touchscreen, RTC and more
      to come!
    \end{itemize}
    \column{0.4\textwidth}
    \includegraphics[width=\textwidth]{common/logo-square.pdf}\\
  \end{columns}
\end{frame}

\begin{frame}{Introduction}
  \begin{itemize}[<+->]
  \item In this talk, we will:
    \begin{itemize}
    \item Understand why we should use a build system
    \item How the Yocto Project / OpenEmbedded core are structured
    \item How we can use it
    \item How we can update it to fit our needs
    \item Give some good practices to start using the Yocto Project correctly
    \end{itemize}
  \item Allows to customize many things: it is easy to do things the
    wrong way
  \item When you see a \checkmark, it means it is a
    \textbf{good practice}!
  \end{itemize}
\end{frame}

\begin{frame}{Why use a build system?}
  \pause
  \center\includegraphics[width=0.2\textwidth]{images/bbb.jpg}
  \begin{itemize}[<+->]
  \item In the Embedded world, we have many constraints
  \item Nice to reduce the system to a \textbf{minimal} one
    + add our \textbf{custom application}
  \item A build system will automate the creation of the system
    in a \textbf{reproducible} way
  \item \textbf{Integration} means packaging applications to create
    a final image
%  \item Applications are usually cross-compiled instead of native-compiled
  \end{itemize}
\end{frame}

\begin{frame}{System integration: several possibilities}
  \begin{itemize}[<+->]
  \item {\bf Building everything manually}:
    \begin{itemize}
    \item[$\bigoplus$] Full flexibility
    \item[$\bigotimes$] Dependency hell
    \item[$\bigotimes$] Lack of reproducibility
    \end{itemize}
  \item {\bf Binary distribution} (Debian, Ubuntu, Fedora, etc):
    \begin{itemize}
    \item[$\bigoplus$] Easy to create and extend
    \item[$\bigotimes$] Hard to customize and optimize (boot time, size)
    \item[$\bigotimes$] Hard to rebuild from source
    \item[$\bigotimes$] Native-compilation
    \item[$\bigotimes$] Not available for all architectures
    \end{itemize}
  \item {\bf Build systems} (Buildroot, the Yocto Project, etc):
    \begin{itemize}
    \item[$\bigotimes$] Not as easy as a binary distribution
    \item[$\bigoplus$] Nearly full flexibility
    \item[$\bigoplus$] Built from source: customization and optimization
      are easy
    \item[$\bigoplus$] Fully reproducible
    \item[$\bigoplus$] Cross-compilation
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}{Representation in the Yocto Project}
  \begin{overlayarea}{\textwidth}{0.5\textheight}
    \only<2>{\includegraphics[width=\textwidth]{dia/build-yocto-project-1.pdf}}
    \only<3>{\includegraphics[width=\textwidth]{dia/build-yocto-project-2.pdf}}
    \only<4>{\includegraphics[width=\textwidth]{dia/build-yocto-project-3.pdf}}
    \only<5-6>{\includegraphics[width=\textwidth]{dia/build-yocto-project-4.pdf}}
    \only<7->{\includegraphics[width=\textwidth]{dia/build-yocto-project-5.pdf}}
  \end{overlayarea}
  \begin{itemize}
    \onslide<6-> {\item Common \textbf{tasks} defined in \textbf{OpenEmbedded core}}
    \onslide<7-> {\item Many recipes availables for many applications: organized
      in \textbf{layers}}
    \onslide<8-> {\item Allow to build custom embedded Linux-based systems \\}
    \onslide<9-> {$\Rightarrow$ This is the aim of the Yocto Project
      \hspace{2.5cm}
      \includegraphics[width=0.2\textwidth]{images/logo-yocto-project.png}}
  \end{itemize}
\end{frame}

\begin{frame}{OpenEmbedded core \& Poky}
  \begin{columns}
    \column{0.43\textwidth}
    \center\includegraphics[width=0.2\textwidth]{images/logo-oe.png}
    \pause
    \begin{itemize}[<+->]
    \item Co-maintained by the Yocto Project and OpenEmbedded Project
    \item Set of \textbf{base layer} with recipes and classes
    \item It is the \textbf{core} of all the magic
    \item It supports the ARM, MIPS (32 and 64 bits), PowerPC and
      x86 (32 and 64 bits) architectures + QEMU
    \end{itemize}
    \column{0.57\textwidth}
    \pause
    \center\includegraphics[width=0.15\textwidth]{images/logo-poky.png}
    \begin{itemize}[<+->]
    \item Reference distribution of the Yocto Project
    \item Contains everything you need to start a project:
      \begin{itemize}
      \item OpenEmbedded-core
      \item Bitbake
      \item Additional layers
      \end{itemize}
    \item Also contains some useful tools to ease recipes and layers' creation
    \end{itemize}
  \end{columns}
\end{frame}

\begin{frame}{The Yocto Project / OpenEmbedded Core / Poky}
  \begin{center}
    \includegraphics[width=\textwidth]{dia/yocto-project-overview.pdf}
  \end{center}
\end{frame}

\begin{frame}{Workflow - General}
    \begin{center}
      \includegraphics[width=0.9\textwidth]{dia/workflow-general-user.pdf}
      \pause
      \includegraphics[width=0.9\textwidth]{dia/workflow-general.pdf}
      \pause
      \includegraphics[width=0.9\textwidth]{dia/workflow-general-2.pdf}
    \end{center}
\end{frame}

\begin{frame}{Workflow - Users/Developers actions}
    \begin{center}
    \includegraphics[width=0.9\textwidth]{dia/workflow-users.pdf}
    \end{center}
\end{frame}

\begin{frame}[fragile]{Workflow - 1. Download}
  \begin{textblock*}{5cm}(10.5cm,0.25cm) % {block width} (coords)
    \includegraphics[width=5cm]{dia/workflow-banner-1-ddl.pdf}
  \end{textblock*}
  \pause
  \begin{itemize}[<+->]
  \item Find which \textbf{version} you want to use:
    \begin{overprint}
      \onslide<2>
      \begin{figure}
        \includegraphics[width=0.6\textwidth]{images/yocto-releases.png}
        \captionsetup{font=tiny}
        \caption{\url{https://wiki.yoctoproject.org/wiki/Releases}}
      \end{figure}
      \onslide<3>
      \begin{figure}
        \includegraphics[width=0.6\textwidth]{images/yocto-releases-2.png}
        \captionsetup{font=tiny}
        \caption{\url{https://wiki.yoctoproject.org/wiki/Releases}}
      \end{figure}
      \onslide<4>
      \begin{figure}
        \includegraphics[width=0.6\textwidth]{images/yocto-releases-3.png}
        \captionsetup{font=tiny}
        \caption{\url{https://wiki.yoctoproject.org/wiki/Releases}}
      \end{figure}
      \onslide<5-6>
      \begin{figure}
        \includegraphics[width=0.6\textwidth]{images/yocto-releases.png}
        \captionsetup{font=tiny}
        \caption{\url{https://wiki.yoctoproject.org/wiki/Releases}}
      \end{figure}
    \end{overprint}
    \begin{itemize}
    \item Support level: Development, Stable, Community
    \item A \textbf{codename} corresponds to a Poky and Bitbake versions \\
      \texttt{Pyro = Yocto Project v2.3 $\rightarrow$ Poky v17.0 \& Bitbake v1.34}
    \item How to download:
      \begin{block}{}
        \begin{minted}{console}
          git clone -b pyro git://git.yoctoproject.org/poky.git
        \end{minted}
      \end{block}
    \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}{Workflow - 1. Download}
  \begin{textblock*}{5cm}(10.5cm,0.25cm)
    \includegraphics[width=5cm]{dia/workflow-banner-1-ddl.pdf}
  \end{textblock*}
  \begin{itemize}[<+->]
  \item \textbf{Layers} are sets of recipes, matching a common purpose.\\
    To simplify things, they are just \textbf{folders}
  \item Look at existing layers
    \begin{figure}
      \includegraphics[width=0.7\textwidth]{images/layers.png}
      \captionsetup{font=tiny}
      \caption{\url{http://layers.openembedded.org/layerindex/}}
    \end{figure}
  \item Download all other layers on same branch than Poky: \texttt{Pyro}
    \tick Use existing layers before creating a new one $\Rightarrow$
    saves you time
    \tick DO NOT EDIT POKY/UPSTREAM LAYERS $\Rightarrow$ complicates updates
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{Workflow - 2. Configure the build}
  \begin{textblock*}{5cm}(10.5cm,0.25cm)
    \includegraphics[width=5cm]{dia/workflow-banner-2-config.pdf}
  \end{textblock*}
  \pause
  \begin{itemize}[<+->]
  \item A script with all variables needed by Bitbake must be \textbf{sourced}:
    \begin{block}{}
      \fontsize{8}{8}\selectfont
      \begin{minted}{console}
        source oe-init-build-env
      \end{minted}
    \end{block}
  \item Will move you in a \textbf{build} folder
  \item Now, can run any commands
  \item All the local configurations are in the \textit{conf} folder
    \begin{block}{}
      \fontsize{8}{8}\selectfont
      \begin{minted}{console}
        build/
            |-- conf
                |-- bblayers.conf
                |-- local.conf
      \end{minted}
    \end{block}
  \item Edit your \textit{bblayers.conf} with possible additional layers:
    \begin{block}{}
      \fontsize{8}{8}\selectfont
      \begin{minted}{console}
        BBLAYERS ?= " \
        /home/mylene/yocto/poky/meta \
        /home/mylene/yocto/poky/meta-poky \
        /home/mylene/yocto/poky/meta-yocto-bsp \
        /home/mylene/yocto/meta-freescale \
        /home/mylene/yocto/meta-qt5 \
        "
      \end{minted}
    \end{block}
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{Workflow - 2. Configure the build}
  \begin{textblock*}{5cm}(10.5cm,0.25cm)
    \includegraphics[width=5cm]{dia/workflow-banner-2-config.pdf}
  \end{textblock*}
  \begin{itemize}[<+->]
  \item Edit \textit{local.conf} with your \textbf{MACHINE} and your \textbf{DISTRO}
    \begin{itemize}
    \item \textbf{MACHINE}: Describes your hardware. Can find it under specific layers:
      BSP layers. Look at \textit{conf/machine/} folders \\
      \begin{itemize}
      \item poky: beaglebone, x86, x86-64
      \item meta-ti: beagleboard, pandaboard, ...
      \item meta-fsl-arm: imx23, imx28, imx6, imx7, ...
      \item meta-atmel: at91*, sama5d*, ...
      \end{itemize}
    \item \textbf{DISTRO}: Represents the top-level configuration that will
      apply to every build. It will include tools needed to use your hardware:
      compiler, libC, etc + some specific variables
      Look at \textit{conf/distro/} folders \\
      \begin{itemize}
      \item poky: poky, poky-tiny, ...
      \item meta-angstrom: angstrom
      \end{itemize}
    \end{itemize}
  \item Noticed that local.conf $\Rightarrow$ only for the local workstation.
    \tick Avoid changes directly in \textit{local.conf} (or only for test
    purposes, except for some variables such as \textbf{MACHINE} and \textbf{DISTRO})
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{Workflow - 3. Build an image}
  \begin{textblock*}{5cm}(10.5cm,0.25cm)
    \includegraphics[width=5cm]{dia/workflow-banner-3-build.pdf}
  \end{textblock*}
  \pause
  \begin{itemize}[<+->]
  \item What is an \textbf{IMAGE}? \\
    $\Rightarrow$ Represents your root filesystem: all your applications,
    libraries, configuration files, ... Will find it under \textit{recipes-*/images/}
  \item Common images already exist in Poky: core-image-minimal, core-image-base,
    core-image-x11, ...
  \item Build an existing image:
    \begin{block}{}
      \fontsize{8}{8}\selectfont
      \begin{minted}{console}
        bitbake core-image-minimal
      \end{minted}
    \end{block}
  \end{itemize}
\end{frame}

\begin{frame}{MACHINE/DISTRO/IMAGE: a little reminder}
  \pause
  \begin{columns}
    \column{0.5\textwidth}
    \begin{itemize}
      \onslide<2->{
      \item \textbf{Machine}: It represents your hardware \\
        \textit{conf/machine/}
        }
        \onslide<4->{
        \item \textbf{Distro}: Represents the top-level configuration that will
          apply on every build \\
          \textit{conf/distro/}
        }
        \onslide<6->{
        \item \textbf{Image}: It represents your root filesystem itself: all
          your applications, libraries, configuration's files, etc \\
          \textit{recipes-core/images}
        }
    \end{itemize}
    \column{0.5\textwidth}
    \begin{overlayarea}{\textwidth}{0.5\textheight}
      \only<3-4>{\includegraphics[width=\textwidth]{dia/image-distro-machine-1.pdf}}
      \only<5-6>{\includegraphics[width=\textwidth]{dia/image-distro-machine-2.pdf}}
      \only<7>{\includegraphics[width=\textwidth]{dia/image-distro-machine-3.pdf}}
    \end{overlayarea}
  \end{columns}
\end{frame}

\begin{frame}{Workflow - Developer}
  \begin{center}
    \includegraphics[width=0.8\textwidth]{dia/workflow-dev.pdf}
  \end{center}
\end{frame}

\begin{frame}[fragile]{Workflow - 4. Create a layer}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-4-layer.pdf}
  \end{textblock*}
  \pause
  \begin{itemize}[<+->]
  \item You may have \textbf{custom hardware}, need to update recipes from upstream
    layers, integrate your \textbf{own application}, etc
  \item Already said before: DO NOT EDIT POKY/UPSTREAM LAYERS
  \item To be able to do that, we will create our \textbf{own layer} that will
    host all our modifications/applications
  \item Poky provides a tool to create layers:
    \begin{block}{}
      \fontsize{8}{8}\selectfont
      \begin{minted}{console}
        yocto-layer create <layer_name> -o <dest_dir>
      \end{minted}
    \end{block}
    \tick The layer's name must be \texttt{meta-*} (done automatically using
    \texttt{yocto-layer} tool)
    \tick Avoid uppercase and funny/long names
    \tick If you have different projects with common parts, try to create
    two layers \\ $\Rightarrow$ Can re-use some parts
  \end{itemize}
\end{frame}

\begin{frame}{Workflow - 5. Create a recipe}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-5-recipe.pdf}
  \end{textblock*}
  \pause
  \begin{itemize}[<+->]
  \item A recipe is a file describing \textbf{tasks} for an application to:
    \begin{itemize}
    \item retrieve its sources
    \item configure it
    \item compile it
    \item install it
    \end{itemize}
  \item It handles all the \textbf{dependencies} for you.
  \item Many common \textbf{tasks} are already defined by OpenEmbedded-core
  \item Organized in folders with the same purpose (\textit{recipes-core, recipes-bsp,
      recipes-kernel, recipes-devtool, recipes-support, ...}) and a sub-folder
      with the application's name
  \end{itemize}
\end{frame}

\begin{frame}{Workflow - 5. Create a recipe}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-5-recipe.pdf}
  \end{textblock*}
  \begin{itemize}[<+->]
  \item To create a recipe, you have to create a \textit{.bb file}. It is the
    format that \textit{bitbake} understands
  \item The format of a recipe file name is
    \code{<application-name>_<version>.bb}
  \item A recipe can be divided in three parts:
    \begin{itemize}
    \item The header: what/who. Description of the application
    \item The sources: where. Can be tarballs, remote repository, ...
    \item The tasks: how. How to proceed with the application's sources
    \end{itemize}
  \item Classes are available for tasks commonly used: kernel, CMake, autotools, ...
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{Workflow - 5. Create a recipe}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-5-recipe.pdf}
  \end{textblock*}
  \code{recipes-support/nmon/nmon_13g.bb}
  \begin{block}{}
    \begin{minted}[fontsize=\tiny]{sh}
            SUMMARY = "nmon performance monitor"
            HOMEPAGE = "http://nmon.sf.net"
            SECTION = "console/utils"
            LICENSE = "GPLv3"
            LIC_FILES_CHKSUM = "file://${WORKDIR}/Documentation.txt;md5=dbb13658cf55d687c4f2ff771a696d4a"
            DEPENDS = "ncurses"

            SRC_URI = "${SOURCEFORGE_MIRROR}/nmon/lmon13g.c;name=lmon \
                       ${SOURCEFORGE_MIRROR}/nmon/Documentation.txt;name=doc \
            "
            SRC_URI[lmon.md5sum] = "b1b8e6c0123ad232394991f2d4f40494"
            SRC_URI[lmon.sha256sum] = "456ab2a342b31d1a352d0d940af5962fa65a12ae8757ff73e6e73210832ae8b5"
            SRC_URI[doc.md5sum] = "dbb13658cf55d687c4f2ff771a696d4a"
            SRC_URI[doc.sha256sum] = "1f7f83afe62a7210be5e83cd24157adb854c14599efe0b377a7ecca933869278"

            CFLAGS += "-D JFS -D GETUSER -Wall -D LARGEMEM"
            LDFLAGS += "-ltinfo -lncursesw"

            do_compile() {
               ${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/lmon13g.c -o nmon
            }

            do_install() {
               install -d ${D}${bindir}
               install -m 0755 nmon ${D}${bindir}
            }
     \end{minted}
  \end{block}
\end{frame}

\begin{frame}[fragile]{Workflow - 5. Create a recipe}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-5-recipe.pdf}
  \end{textblock*}
  \code{recipes-support/nmon/nmon_13g.bb}
  \begin{block}{}
    \begin{minted}[fontsize=\tiny]{sh}
          | SUMMARY = "nmon performance monitor"
          | HOMEPAGE = "http://nmon.sf.net"
          | SECTION = "console/utils"
 "Header" | LICENSE = "GPLv3"
          | LIC_FILES_CHKSUM = "file://${WORKDIR}/Documentation.txt;md5=dbb13658cf55d687c4f2ff771a696d4a"
          | DEPENDS = "ncurses"

          | SRC_URI = "${SOURCEFORGE_MIRROR}/nmon/lmon13g.c;name=lmon \
          |            ${SOURCEFORGE_MIRROR}/nmon/Documentation.txt;name=doc \
          | "
          | SRC_URI[lmon.md5sum] = "b1b8e6c0123ad232394991f2d4f40494"
 "Source" | SRC_URI[lmon.sha256sum] = "456ab2a342b31d1a352d0d940af5962fa65a12ae8757ff73e6e73210832ae8b5"
          | SRC_URI[doc.md5sum] = "dbb13658cf55d687c4f2ff771a696d4a"
          | SRC_URI[doc.sha256sum] = "1f7f83afe62a7210be5e83cd24157adb854c14599efe0b377a7ecca933869278"

          | CFLAGS += "-D JFS -D GETUSER -Wall -D LARGEMEM"
          | LDFLAGS += "-ltinfo -lncursesw"
          |
          | do_compile() {
          |    ${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/lmon13g.c -o nmon
 "Tasks"  | }
          |
          | do_install() {
          |    install -d ${D}${bindir}
          |    install -m 0755 nmon ${D}${bindir}
          | }
      \end{minted}
   \end{block}
\end{frame}

\begin{frame}[fragile]{Workflow - 5. Create a recipe}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-5-recipe.pdf}
  \end{textblock*}
  \code{recipes-example/helloworld/helloworld_1.0.bb}
  \begin{block}{}
    \begin{minted}[fontsize=\scriptsize]{sh}
            DESCRIPTION = "Print a friendly, customizable greeting"
            HOMEPAGE = "https://www.gnu.org/software/hello/"
            PRIORITY = "optional"
            SECTION = "examples"
            LICENSE = "GPLv3"

            SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
            SRC_URI[md5sum] = "67607d2616a0faaf5bc94c59dca7c3cb"
            SRC_URI[sha256sum] = "ecbb7a2214196c57ff9340aa71458e1559abd38f6d8d169666846935df191ea7"
            LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"

            inherit autotools
    \end{minted}
  \end{block}
\end{frame}

\begin{frame}[fragile]{Workflow - 5. Create a recipe}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-5-recipe.pdf}
  \end{textblock*}
  \code{recipes-example/helloworld/helloworld_1.0.bb}
  \begin{block}{}
    \begin{minted}[fontsize=\scriptsize]{sh}
          | DESCRIPTION = "Print a friendly, customizable greeting"
          | HOMEPAGE = "https://www.gnu.org/software/hello/"
 "Header" | PRIORITY = "optional"
          | SECTION = "examples"
          | LICENSE = "GPLv3"

          | SRC_URI = "${GNU_MIRROR}/hello/hello-${PV}.tar.gz"
 "Source" | SRC_URI[md5sum] = "67607d2616a0faaf5bc94c59dca7c3cb"
          | SRC_URI[sha256sum] = "ecbb7a2214196c57ff9340aa71458e1559abd38f6d8d169666846935df191ea7"
          | LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"

 "Tasks"  | inherit autotools
    \end{minted}
  \end{block}
\end{frame}


\begin{frame}{Workflow - 5. Create a recipe}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-5-recipe.pdf}
  \end{textblock*}
  \begin{itemize}[<+->]
    \tick Always use \textbf{remote repositories} to host your application sources \\
    $\Rightarrow$ Makes development quicker + keep history
    \tick Do not put \textbf{application sources} in your layer directly! \\
    $\Rightarrow$ Application development $\ne$  Application Integration
    \tick Keep the same \textbf{folder organization}: \textit{recipes-core/recipes-bsp/recipes-devtools/...}\\
    $\Rightarrow$ Find recipes quicker
    \tick Keep the \textbf{headers / sources / tasks} organization in the recipe \\
    $\Rightarrow$ All the recipes have the same content organization
    \tick Use/Create \textbf{include files} when possible \\
    $\Rightarrow$ Can extend other versions easily
    \tick Know how to \textbf{compile} the application \textbf{manually} before
    integrating it in a recipe \\
    $\Rightarrow$ Saves you time
  \end{itemize}
\end{frame}

\begin{frame}{Workflow - 6. Extend a recipe}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-6-bbappend.pdf}
  \end{textblock*}
  \pause
  \begin{itemize}[<+->]
  \item It is a good practice {\bf not} to modify recipes available
    in Poky.
  \item But it is sometimes useful to modify an existing recipe
  \item The BitBake \emph{build engine} allows to modify a recipe by
    \textbf{extending} it
  \item The recipe extensions end in \code{.bbappend}
  \item Appended files must have the \textbf{same root name} as the recipe they
    extend
    \code{example_0.1.bbappend} applies to
    \code{example_0.1.bb}\\
    $\Rightarrow$ \textbf{version specific}
  \item If adding new files, you must prepend the \code{FILESEXTRAPATHS}
    variable with the path to files' directory.
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{Workflow - 6. Extend a recipe}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-6-bbappend.pdf}
  \end{textblock*}
  \code{recipes-support/nmon/nmon_13g.bbappend}
  \begin{block}{}
    \begin{minted}[fontsize=\scriptsize]{sh}
      FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

      SRC_URI += "file://custom-modification-0.patch \
                  file://custom-modification-1.patch \
      "

      do_install_append() {
         # Do something
      }
    \end{minted}
  \end{block}
  \begin{block}{}
    \begin{minted}[fontsize=\scriptsize]{sh}
      .
      |--- conf
      |   |-- layer.conf
      |--- recipes-support
          |--- nmon
              |-- files
              |   |-- custom-modification-0.patch
              |   |-- custom-modification-1.patch
              |-- nmon_13g.bbappend
     \end{minted}
  \end{block}
\end{frame}

\begin{frame}[fragile]{Workflow - 7. Create an image}
   \begin{textblock*}{5cm}(11.5cm,0.25cm)
     \includegraphics[width=4cm]{dia/workflow-banner-7-image.pdf}
   \end{textblock*}
   \pause
   \begin{itemize}[<+->]
   \item An \code{image} is the top level recipe and is used
     alongside the \code{machine} definition
  \item Whereas the \code{machine} describes the hardware used and
    its capabilities, the \code{image} is architecture agnostic and
    defines how the root filesystem is built, with what packages
  \item By default, several images are provided in Poky:
    \begin{itemize}
    \item \code{meta*/recipes*/images/*.bb}
    \end{itemize}
  \item An \code{image} is no more than a recipe
  \item To create an image, simply create a \textit{.bb} in an \textit{images}
    folder
    \begin{block}{}
      \fontsize{8}{8}\selectfont
      \begin{minted}{console}
        mkdir -p recipes-core/images/
        touch recipes-core/images/core-image-fe.bb
      \end{minted}
    \end{block}
  \end{itemize}
\end{frame}

\begin{frame}{Workflow - 7. Create an image}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-7-image.pdf}
  \end{textblock*}
  \pause
  \begin{itemize}[<+->]
    \item Some special configuration variables are used to describe an
      image:
      \begin{description}
        \item[IMAGE\_INSTALL] List of packages to install in the
          generated image
        \item[IMAGE\_FSTYPES] List of formats the OpenEmbedded build
          system will use to create images
      \end{description}
    \tick Create a \textbf{minimal image} to include it in others \\
    $\Rightarrow$ Allows to have a minimal rootfs
    \tick Create different images according to your needs: image-minimal,
    image-dev, image-x11, image-qt5, etc \\
    $\Rightarrow$ Install only what you really need for your board.
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{Workflow - 7. Create an image}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-7-image.pdf}
  \end{textblock*}
  \code{recipes-core/images/core-image-fe.bb}
  \begin{block}{}
    \begin{minted}[fontsize=\small]{sh}
 inherit core-image

 DESCRIPTION = "A small image to boot a device, created for Embedded Recipes"
 LICENSE = "MIT"

 IMAGE_FSTYPES = "tar.bz2 ext4"
 IMAGE_INSTALL = "packagegroup-core-boot \
                  nmon \
                  helloworld \
                  "
   \end{minted}
  \end{block}
\end{frame}

\begin{frame}{Workflow - 8. Create a machine}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-8-machine.pdf}
  \end{textblock*}
  \pause
  \begin{itemize}[<+->]
  \item A machine describes your \textbf{hardware}
  \item Stored under \code{meta-<bsp_name>/conf/machine/*.conf}
  \item The file name corresponds to the value set in the \code{MACHINE}
    variable \\
    \code{meta-ti/conf/machine/beaglebone.conf} \\
    \code{MACHINE = "beaglebone"}
  \item Contains configuration variables related to the architecture,
    to machine's features and to customize the kernel image or the
    filesystems used.
    \begin{description}
    \item [TARGET\_ARCH]: The architecture of the device being built
    \item [PREFERRED\_PROVIDER\_virtual/kernel]: The kernel recipe to use
    \item [SERIAL\_CONSOLE]: Speed and device for the serial console to
      attach. Passed to the kernel as the \code{console} parameter,
      e.g. \code{115200 ttyS0}
    \item [KERNEL\_IMAGETYPE]: The type of kernel image to build, e.g.
      \code{zImage}
    \end{description}
    \tick Describe your machine in a \code{README} file
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{Workflow - 8. Create a machine}
  \begin{textblock*}{5cm}(11.5cm,0.25cm)
    \includegraphics[width=4cm]{dia/workflow-banner-8-machine.pdf}
  \end{textblock*}
      \code{conf/machine/fe-machine.conf}
  \begin{block}{}
    \begin{minted}[fontsize=\small]{sh}
      require conf/machine/include/soc-family.inc
      require conf/machine/include/tune-cortexa5.inc

      TARGET_ARCH = "arm"

      PREFERRED_PROVIDER_virtual/kernel ?= "linux-at91"
      PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot-at91"

      KERNEL_IMAGETYPE = "zImage"
      KERNEL_DEVICETREE = "at91-sama5d3_xplained.dtb"

      SERIAL_CONSOLE ?= "115200 ttyS0"
   \end{minted}
  \end{block}
\end{frame}

\begin{frame}{Conclusion}
  \begin{center}
    \includegraphics[width=0.9\textwidth]{dia/workflow-general.pdf}
  \end{center}
\end{frame}

\begin{frame}{\insertconference}
  \begin{center}
    \huge\textbf{Thank you for listening!}
    \begin{textblock*}{5cm}(0cm,5.5cm) % {block width} (coords)
      \includegraphics[width=2cm]{images/logo-poky.png}
    \end{textblock*}
    \begin{textblock*}{5cm}(5cm,6.5cm) % {block width} (coords)
      \includegraphics[width=3cm]{images/logo-yocto-project.png}
    \end{textblock*}
    \begin{textblock*}{5cm}(10cm,5.5cm) % {block width} (coords)
      \includegraphics[width=2.5cm]{images/logo-oe.png}
    \end{textblock*}
  \end{center}
\end{frame}

\questionslide

\end{document}
