\documentclass[obeyspaces,spaces,hyphens]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{minted}

\mode<presentation>
\usetheme{Bootlin}

\newcommand{\codehack}[1]{{\usebeamercolor[fg]{code} {\tt #1}}}

\title{Using Yocto Project for modules manufacturers}
\authors{Alexandre Belloni}
\institute{Bootlin}

\usepackage{hyperref}

\begin{document}

\begin{frame}{Embedded Linux Conference 2014}
  \begin{columns}[c]
   \column{0.6\textwidth}
     \huge
     Using Yocto Project for module manufacturers\\
     \vspace{2cm}
     \normalsize
     Alexandre Belloni\\
     {\bf Bootlin}\\
     {\em alexandre.belloni@bootlin.com}
     \column{0.4\textwidth}
     \includegraphics[width=\textwidth]{yocto-project-transp.png}
   \end{columns}
   \vfill
   Put your business card in the box to participate in the raffle!
\end{frame}

\begin{frame}{Alexandre Belloni}
  \begin{columns}
    \column{0.7\textwidth}
    \begin{itemize}
      \item Embedded Linux engineer at {\bf Bootlin}
        \begin{itemize}
          \item Embedded Linux {\bf expertise}
          \item {\bf Development}, consulting and training
          \item Strong open-source focus
        \end{itemize}
      \item Open-source contributor
        \begin{itemize}
          \item Contributing the {\bf kernel support for Atmel ARM
            processors}
          \item Contributing the {\bf kernel support for Marvell
            ARM (Berlin) processors}
          \item Maintainer of the Crystalfontz boards in the {\bf
            meta-fsl-arm} layer
        \end{itemize}
    \end{itemize}
    \column{0.3\textwidth}
    \includegraphics[width=\textwidth]{common/logo-square.pdf}
  \end{columns}
\end{frame}

\begin{frame}{Crystalfontz}
  \begin{columns}
    \column{0.7\textwidth}
    \begin{itemize}
      \item SoM manufacturer
        \begin{itemize}
          \item cfa-10036 is an i.MX28 based SoM
          \item 128 or 256 MB RAM
          \item optional OLED screen
          \item SO-DIMM 200 connector
        \end{itemize}
      \item Carrier boards
        \begin{itemize}
          \item Prototyping: cfa-10037, screens available
          \item Internet gadget: cfa-10057/cfa-10058 (commercial
            names: CFA920-TS and CFA921-TS)
        \end{itemize}
      \item Linux and Barebox mainline support
    \end{itemize}
    \column{0.3\textwidth}
    \includegraphics[width=\textwidth]{cfa10036.jpg}
  \end{columns}
  \vfill
  \url{http://www.crystalfontz.com/CFA10036-Linux-SOM.php}
\end{frame}

\begin{frame}{What is the Yocto Project ?}
  \begin{itemize}
    \item Umbrella project, including:
      \begin{itemize}
        \item pseudo
        \item cross-prelink
        \item matchbox
        \item opkg
        \item psplash
        \item ...
      \end{itemize}
    \item Provides \code{Poky}, a build system, based on
      \code{OpenEmbedded-Core}, uses:
      \begin{itemize}
        \item \code{BitBake}, a build tool, task executor and
          scheduler
        \item Metadata, organized in layers:
          \begin{description}
            \item[Configuration (.conf)] global definitions of
              variables
            \item[Classes (.bbclass)] encapsulation and inheritance of
              build logic, packaging, etc
            \item[Recipes (.bb)] set of instruction to build packages
            \item[Recipes extensions (.bbappend)] extension to an
              existing recipe
          \end{description}
      \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}{Why ?}
  Adding Yocto Project support allows to:
  \begin{itemize}
    \item use the initial support given by your silicon vendor
    \item leverage work from the community:
      \begin{itemize}
        \item Thousands of packages available
        \item Benefit from bug fixes
      \end{itemize}
    \item generate a demo image to ship with the board
    \item generate an SDK so that customers are ready to start
      developing once they receive the board.
    \item easily switch between modules or evaluation boards for better
      benchmarking
    \item create a distribution (.ipk, .deb, .rpm)
  \end{itemize}
\end{frame}

\begin{frame}{Our goals}
  \begin{itemize}
    \item get \code{core-image-*} working without any specific
      configuration
    \item inclusion in the official Freescale BSP,
      \code{meta-fsl-arm{-extra}}
      \begin{itemize}
        \item good visibility of the platform
        \item ease of use for the customers, only having to deal
          with one layer
        \item (almost) free maintenance
      \end{itemize}
    \item create a demo image to implement all the available features
  \end{itemize}
\end{frame}

\begin{frame}{What has been done}
  Upstreamed:
  \begin{itemize}
    \item machine configuration for each board
    \item bootloader (\code{Barebox}) support improvements 
    \item new image type
    \item kernel recipes for the Crystalfontz boards
    \item formfactor configuration for the board having a touchscreen
    \item multiple package fixes
  \end{itemize}
  In \code{meta-crystalfontz}:
  \begin{itemize}
    \item machine configuration for all the boards
    \item multiple package tweaks and two demo images
  \end{itemize}
\end{frame}

\begin{frame}{First step}
  Working Buildroot SD card images existed, they were using:
  \begin{itemize}
    \item \code{imxbootlets} to boot...
    \item \code{Barebox} to select and load the correct device tree
      and boot...
    \item the Linux kernel to start...
    \item the Buildroot root filesystem
  \end{itemize}
  So the first step was to simply build \code{core-image-minimal}
  using the \code{imx28evk} machine configuration.
  \begin{itemize}
    \item generate an \code{ext3} root filesystem image and a
      \code{tar.bz2} archive along with the final SD card image
    \item use either of those to replace the root filesystem on an
      existing SD card.
  \end{itemize}
  This allows to quickly test the built root filesystem.
\end{frame}

\begin{frame}[fragile]{Building an image with Yocto}
  \begin{itemize}
    \item Initialize the build environment
      \begin{block}{}
      \begin{minted}{console}
$ source poky/oe-init-build-env build
      \end{minted}
      \end{block}
    \item Configure your \code{local.conf}
      \begin{block}{}
      \begin{minted}{console}
BB_NUMBER_THREADS = "16"
PARALLEL_MAKE = "-j 16"
MACHINE ?= "imx28evk"
      \end{minted}
      \end{block}
    \item build the image
      \begin{block}{}
      \begin{minted}{console}
$ bitbake core-image-minimal
      \end{minted}
      \end{block}
  \end{itemize}
\end{frame}


\begin{frame}{Layer creation}
  To make modifications, it is necessary to create a new layer:
  \begin{itemize}
    \item create a \code{meta-<machine>} directory
    \item inside that directory, create a \code{conf/layer.conf} file
  \end{itemize}
  Alternatively, you could use:
  \begin{itemize}
    \item \code{yocto-layer create} and select a high priority
    \item or \code{yocto-bsp create}
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{\code{conf/layer.conf}}
  \begin{block}{}
  \begin{minted}{c}
# We have a conf and classes directory, add to BBPATH
BBPATH .= ":${LAYERDIR}"

BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \
    ${LAYERDIR}/recipes-*/*/*.bbappend"

BBFILE_COLLECTIONS += "crystalfontz"
BBFILE_PATTERN_crystalfontz := "^${LAYERDIR}/"
BBFILE_PRIORITY_crystalfontz = "10"

LAYERDEPENDS_crystalfontz = "fsl-arm fsl-arm-extra"
  \end{minted}
  \end{block}
\end{frame}

\begin{frame}[fragile]{\code{conf/layer.conf}}
  The Yocto Project documentation states:
  \begin{verbatim}
  At a minimum, the README file must contain a
  list of dependencies, such as the names of any
  other layers on which the BSP depends and the
  name of the BSP maintainer with his or her
  contact information.
  \end{verbatim}
  But it is actually quite better to also specify those dependencies
  in \code{conf/layer.conf} by using \code{LAYERDEPENDS}. Still, you
  can document how to get those dependencies in the \code{README}.
\end{frame}

\begin{frame}[fragile]{Adding the layer to the build}
  \begin{itemize}
    \item The main drawback of having a layer separate from your
      silicon vendor is that your customers will have to add it to
      their configuration to use it.
    \item That configuration is done in
      \code{<builddir>/conf/bblayers.conf}. Add your layer to the
      \code{BBLAYERS} variable:
      \begin{block}{}
        \begin{minted}{c}
BBLAYERS += "${BSPDIR}/sources/meta-crystalfontz "
        \end{minted}
      \end{block}
  \end{itemize}
\end{frame}

\begin{frame}{Machine configuration}
  Create a \code{<machine>.conf} file in \code{conf/machine/}. As we
  want to support multiple similar boards (all based on
  \code{cfa10036}), an include was created in
  \code{conf/machine/include/}.
\end{frame}

\begin{frame}[fragile]{\code{conf/machine/include/cfa10036.inc}}
  \begin{block}{}
  \footnotesize
  \begin{minted}{c}
# Common definitions for cfa-10036 boards
include conf/machine/include/mxs-base.inc

SOC_FAMILY = "mxs:mx28:cfa10036"

PREFERRED_PROVIDER_virtual/kernel ?= "linux-cfa"
IMAGE_BOOTLOADER = "barebox"
BAREBOX_BINARY = "barebox"
IMXBOOTLETS_MACHINE = "cfa10036"
KERNEL_IMAGETYPE = "zImage"
KERNEL_DEVICETREE = "imx28-cfa10036.dtb"

# we need the kernel to be installed in the final image
IMAGE_INSTALL_append = " kernel-image kernel-devicetree"

SDCARD_ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3"
IMAGE_FSTYPES ?= "tar.bz2 ext3 barebox.mxsboot-sdcard sdcard"

SERIAL_CONSOLE = "115200 ttyAMA0"
MACHINE_FEATURES = "usbgadget usbhost vfat"
  \end{minted}
  \normalsize
  \end{block}
\end{frame}

\begin{frame}[fragile]{\code{conf/machine/cfa10036.conf}}
  The machine configuration for the module is simple:
  \begin{block}{}
  \begin{minted}{c}
#@TYPE: Machine
#@NAME: Crystalfontz CFA-10036
#@SOC: i.MX28
#@DESCRIPTION: Machine configuration for CFA-10036
#@MAINTAINER: Alexandre Belloni <alexandre.belloni@bootlin.com>

include conf/machine/include/cfa10036.inc
  \end{minted}
  \end{block}
  It is always a good idea to put a contact as maintainer.
\end{frame}

\begin{frame}[fragile]{\code{conf/machine/cfa10057.conf}}
  For a carrier board, add the corresponding device tree and the
  supported features.
  \begin{block}{}
  \begin{minted}{c}
#@TYPE: Machine
#@NAME: Crystalfontz CFA-10057
#@SOC: i.MX28
#@DESCRIPTION: Machine configuration for CFA-10057, also called CFA-920
#@MAINTAINER: Alexandre Belloni <alexandre.belloni@bootlin.com>

include conf/machine/include/cfa10036.inc

KERNEL_DEVICETREE += "imx28-cfa10057.dtb"

MACHINE_FEATURES += "touchscreen"
  \end{minted}
  \end{block}
\end{frame}

\begin{frame}{Kernel support}
  For the kernel, you have multiple choices:
  \begin{itemize}
    \item patches over silicon vendor kernel tree
      \begin{itemize}
        \item available as an include
        \item using a \code{.bbappend}
      \end{itemize}
    \item custom git tree
    \item mainline git
  \end{itemize}
  You also probably have to provide a configuration file.
\end{frame}

\begin{frame}[fragile]{Patches, include}
  The compilation logic is provided by your silicon vendor as an include
  file:
  \begin{itemize}
    \item create a \code{recipes-kernel/linux/}
    \item write a new recipe \code{linux-<vendor>_<version>.bb}
    \item copy your patches to \code{recipes-kernel/linux/linux-<vendor>-<version>}
    \item Example: for \code{linux-congatec}:
      \footnotesize
      \begin{block}{}
      \begin{minted}{console}
$ ls recipes-kernel/linux/linux-congatec*
recipes-kernel/linux/linux-congatec_3.0.35.bb

recipes-kernel/linux/linux-congatec-3.0.35:
0001-Add-linux-support-for-congatec-evaluation-board-qmx6q.patch
0001-perf-tools-Fix-getrusage-related-build-failure-on-gl.patch
0002-ARM-7668-1-fix-memset-related-crashes-caused-by-rece.patch
0003-ARM-7670-1-fix-the-memset-fix.patch
[...]
defconfig
      \end{minted}
      \end{block}
      \normalsize
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{Patches, include: recipe}
  \scriptsize
  \begin{block}{}
  \begin{minted}{c}
SUMMARY = "Linux Kernel based on Freescale Linux kernel to add support for Congatec boards"
include recipes-kernel/linux/linux-imx.inc

SRCREV = "bdde708ebfde4a8c1d3829578d3f6481a343533a"
LOCALVERSION = "-4.1.0+yocto"
SRCBRANCH = "imx_3.0.35_4.1.0"

SRC_URI += "file://drm-vivante-Add-00-sufix-in-returned-bus-Id.patch \
            file://epdc-Rename-mxcfb_epdc_kernel.h-to-mxc_epdc.h.patch \
            file://0001-perf-tools-Fix-getrusage-related-build-failure-on-gl.patch \
            file://0002-ARM-7668-1-fix-memset-related-crashes-caused-by-rece.patch \
            file://0003-ARM-7670-1-fix-the-memset-fix.patch \
            file://0004-ENGR00271136-Fix-build-break-when-CONFIG_CLK_DEBUG-i.patch \
            file://0005-ENGR00271359-Add-Multi-touch-support.patch \
            file://0006-Add-support-for-DVI-monitors.patch \
            file://0001-Add-linux-support-for-congatec-evaluation-board-qmx6q.patch \
            file://ENGR00278350-gpu-viante-4.6.9p13-kernel-part-integra.patch \
"

COMPATIBLE_MACHINE = "(cgtqmx6)"
  \end{minted}
  \end{block}
  \normalsize
\end{frame}

\begin{frame}[fragile]{Patches, include: recipe}
  \begin{description}
    \item[SRCREV] The revision of the source code used to build the package.
    \item[SRCBRANCH] New in \code{daisy}, when using git it is
      required to specify in which branch the commit resides.
      \code{SRCBRANCH} is used in \code{SRC_URI}, in
      \code{linux-imx.inc}
    \item[SRC\_URI] The list of source files. Here patches are added
      in the original \code{SRC_URI}
    \item[COMPATIBLE\_MACHINE] A regular expression used to match
      against the \code{MACHINEOVERRIDES} variable which in turn
      includes \code{MACHINE}. Used to ensure the recipe won't build
      for other machines.
  \end{description}
\end{frame}

\begin{frame}[fragile]{\code{SRC_URI}: file://}
  \begin{itemize}
    \item When using \code{file://} in \code{SRC-URI}, OpenEmbedded will
      search files relative to the subdirectories listed in
      \code{FILESPATH}
    \item By default, this is:
      \begin{itemize}
        \item \code{${BPN}}, the base recipe name
        \item \code{${BP}}, which is \code{${BPN}-${PV}}, \code{${PV}}
          being the package version
        \item \code{files}
      \end{itemize}
    \item also looks in a subdirectory named \code{${MACHINE}} inside
      those directories
    \item if set, also looks for subdirectories named from
      \code{${MACHINEOVERRIDES}} and \code{${DISTROOVERRIDES}}
    \item Don't modify \code{FILESPATH} directly, use
      \code{FILESEXTRAPATHS}
  \end{itemize}
\end{frame}

\begin{frame}{custom git tree}
  When using a custom git tree, you'll have to write your own recipe.
  But this doesn't have to be difficult:
  \begin{itemize}
    \item inherit the kernel class, it already takes care of
      downloading, unpacking, configuring and compiling your kernel.
    \item if using device trees, include
      \code{recipes-kernel/linux/linux-dtb.inc}
    \item define \code{SRC_URI}
    \item define \code{S}
    \item define \code{COMPATIBLE_MACHINE}
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{\code{recipes-kernel/linux/linux-cfa_3.10.bb}}
  \scriptsize
  \begin{block}{}
  \begin{minted}{c}
DESCRIPTION = "Linux kernel for Crystalfontz boards"
SECTION = "kernel"
LICENSE = "GPLv2"

LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7"

inherit kernel
require recipes-kernel/linux/linux-dtb.inc

SRCBRANCH = "cfa-3.10.25"
SRC_URI = "git://github.com/crystalfontz/cfa_10036_kernel;branch=${SRCBRANCH} \
           file://defconfig"

SRCREV = "61dbe8ef338ce4cc1c10d5a6cdd418c047fb136d"

S = "${WORKDIR}/git"

COMPATIBLE_MACHINE = "cfa10036"
  \end{minted}
  \end{block}
  \normalsize
\end{frame}

\begin{frame}{Bootloader support}
  \begin{itemize}
    \item using \code{imxbootlets} to start \code{Barebox}
    \item the recipes are going in the \code{recipes-bsp} folder
    \item those recipes are extended using \code{.bbappend}
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{\code{imx-bootlets/imx-bootlets_10.12.01.bbappend}}
  \begin{itemize}
    \item extends
      \code{recipes-bsp/imx-bootlets/imx-bootlets_10.12.01.bb} from
      \code{meta-fsl-arm}
  \end{itemize}
  \small
  \begin{block}{}
  \begin{minted}{c}
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI_append_cfa10036 = " file://cfa10036-support.patch"
  \end{minted}
  \end{block}
  \normalsize
  \begin{itemize}
    \item use immediate expansion \code{:=}
    \item conditionally adds the cfa10036 support patch when
      \code{MACHINEOVERRIDES} matches
    \item don't forget the space at the beginning of the string when
      using \code{_append}
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{\code{barebox/barebox_2013.08.0.bbappend}}
  \begin{itemize}
    \item extends
      \code{recipes-bsp/barebox/barebox_2013.08.0.bb} from
      \code{meta-fsl-arm}
  \end{itemize}
  \small
  \begin{block}{}
  \begin{minted}{c}
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"

COMPATIBLE_MACHINE_cfa10036 = "cfa10036"
  \end{minted}
  \end{block}
  \normalsize
  \begin{itemize}
    \item simply adds the subdirectory, it contains the configuration
  \end{itemize}
  \begin{block}{}
  \begin{minted}{console}
$ tree recipes-bsp/barebox/barebox-2013.08.0/
recipes-bsp/barebox/barebox-2013.08.0/
`-- cfa10036
    `-- defconfig
  \end{minted}
  \end{block}
\end{frame}

\begin{frame}{Image types}
  \begin{itemize}
    \item an image type defines how to create the final image
    \item usually, it is not necessary to create a new one, simply
      select the one you want by using \code{IMAGE_FSTYPES} in your
      machine configuration.
    \item using \code{imxbootlets} with \code{barebox} was not
      supported so it has been added.
    \item adding image types is done by using classes, for boards
      based on Freescale SoCs, they are defined in
      \code{classes/image_types_fsl.bbclass} in \code{meta-fsl-arm}
  \end{itemize}
\end{frame}

\begin{frame}{Image recipes}
  \begin{itemize}
    \item an image recipe is used to define the content of the final
      image
    \item it is the entry point of the build and defines all the
      necessary packages through dependencies
    \item image recipes are usually in \code{recipes-*/images/}
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{\code{images/demo-image-cfa-mini.bb}}
  \footnotesize
  \begin{block}{}
  \begin{minted}{c}
DESCRIPTION = "Image for Crystalfontz boards"
LICENSE = "MIT"

IMAGE_INSTALL = "packagegroup-core-boot \
    ${ROOTFS_PKGMANAGE_BOOTSTRAP} \
    ${CORE_IMAGE_EXTRA_INSTALL}"

IMAGE_INSTALL += "init-ifupdown busybox-udhcpd iw"

IMAGE_INSTALL += "evtest tslib tslib-conf tslib-tests \
    tslib-calibrate"

IMAGE_LINGUAS = " "

inherit core-image
  \end{minted}
  \end{block}
  \normalsize
\end{frame}

\begin{frame}{Image recipes}
  \begin{itemize}
    \item use \code{IMAGE_INSTALL} to specify which packages you need
      on your target
    \item you can use packagegroups, they are useful when needing
      features with complex dependencies
    \item inherit the base image class \code{core-image}
    \item you can also include already existing image recipes
  \end{itemize}
\end{frame}

\begin{frame}[fragile]{\code{images/demo-image-cfa.bb} (1)}
  \scriptsize
  \begin{block}{}
  \begin{minted}{c}
include recipes-sato/images/core-image-sato.bb

IMAGE_FEATURES += "debug-tweaks"
WEB = "web-webkit"

IMAGE_INSTALL += " linux-firmware init-ifupdown busybox-udhcpd"

# we don't need the full tools-testapps
IMAGE_INSTALL += " evtest tslib tslib-conf tslib-tests tslib-calibrate xev"
IMAGE_INSTALL += " iw connman-client"

EXTRA_IMAGE_FEATURES += " \
    nfs-server \
    qt4-pkgs \
"

# more debugging and profiling
EXTRA_IMAGE_FEATURES += " \
    tools-debug \
    tools-profile \
"

  \end{minted}
  \end{block}
  \normalsize
\end{frame}

\begin{frame}[fragile]{\code{images/demo-image-cfa.bb} (2)}
  \scriptsize
  \begin{block}{}
  \begin{minted}{c}
IMAGE_INSTALL += " \
    cpufrequtils \
    nano \
    packagegroup-qt-in-use-demos \
    qt4-demos \
    qt4-examples \
    cfa-config-extra \
    "

export IMAGE_BASENAME = "demo-image-cfa"
  \end{minted}
  \end{block}
  \normalsize
\end{frame}

\begin{frame}{Image recipes}
  \begin{description}
    \item[IMAGE\_FEATURES] The primary list of features to include in an image.
    \item[EXTRA\_IMAGE\_FEATURES] List of additional features to
      include in an image, typically to be put in your
      \code{local.conf} file.
  \end{description}
  Available features: dbg-pkgs, dev-pkgs, doc-pkgs, nfs-server,
  read-only-rootfs, splash, ssh-server-dropbear, ssh-server-openssh,
  staticdev-pkgs, tools-debug, tools-profile, tools-sdk,
  tools-testapps, x11, x11-base, x11-sato
\end{frame}

\begin{frame}[fragile]{Image tweaks}
  There is a mechanism to describe what functionalities are available
  on the target, the formfactor configuration file.
  \begin{itemize}
    \item extend it with a .bbappend: \code{recipes-bsp/formfactor/formfactor_0.0.bbappend}
  \begin{block}{}
  \begin{minted}{c}
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
  \end{minted}
  \end{block}
    \item it install a file named \code{machconfig}
  \end{itemize}
  \begin{block}{}
  \begin{minted}{console}
$ tree recipes-bsp/formfactor/
recipes-bsp/formfactor/
|-- formfactor
|   |-- cfa10057
|   |   `-- machconfig
|   `-- cfa10058
|       `-- machconfig
`-- formfactor_0.0.bbappend
  \end{minted}
  \end{block}
\end{frame}

\begin{frame}[fragile]{\code{cfa10058/machconfig}}
  \begin{block}{}
  \begin{minted}{c}
# Display options
HAVE_TOUCHSCREEN=1
  \end{minted}
  \end{block}
  Other available variables: \code{HAVE_KEYBOARD},
  \code{HAVE_KEYBOARD_PORTRAIT}, \code{HAVE_KEYBOARD_LANDSCAPE},
  \code{DISPLAY_CAN_ROTATE}, \code{DISPLAY_ORIENTATION},
  \code{DISPLAY_WIDTH_PIXELS}, \code{DISPLAY_HEIGHT_PIXELS},
  \code{DISPLAY_BPP}, \code{DISPLAY_WIDTH_MM},
  \code{DISPLAY_HEIGHT_MM}, \code{DISPLAY_SUBPIXEL_ORDER}.
\end{frame}

\begin{frame}[fragile]{Adding extra configuration}
  You can create a recipe to simply install a few configuration files
  in your final filesystem. This is what \code{cfa-config-extra} is
  doing:
  \code{recipes/cfa-config-extra/cfa-config-extra.bb}
  \tiny
  \begin{block}{}
  \begin{minted}{c}
DESCRIPTION = "Extra files for demo-image-cfa"
LICENSE = "GPLv2"
PR = "r1"
S="${WORKDIR}"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c746876a5e2eaefef09efb9d7c1c463d"

SRC_URI += "file://qtbrowser.desktop \
            file://webkit.png \
            file://qtmediaplayer.desktop \
            file://qtmediaplayer.png \
            file://qtdemo.desktop \
            file://qtdemo.png \
            file://LICENSE"

inherit allarch

do_install () {
    install -d ${D}/${datadir}/pixmaps
    install -d ${D}/${datadir}/applications
    install -m 0644 ${WORKDIR}/webkit.png ${D}/${datadir}/pixmaps
    install -m 0644 ${WORKDIR}/qtbrowser.desktop ${D}/${datadir}/applications
    install -m 0644 ${WORKDIR}/qtmediaplayer.png ${D}/${datadir}/pixmaps
    install -m 0644 ${WORKDIR}/qtmediaplayer.desktop ${D}/${datadir}/applications
    install -m 0644 ${WORKDIR}/qtdemo.png ${D}/${datadir}/pixmaps
    install -m 0644 ${WORKDIR}/qtdemo.desktop ${D}/${datadir}/applications
}
  \end{minted}
  \end{block}
  \normalsize
\end{frame}

\begin{frame}[fragile]{Useful package tweaks}
  \code{recipes-connectivity/connman}, to be extended to install and
  \code{connman.defaults} file, especially to prevent \code{connman}
  from configuring some interfaces.
  \code{recipes-connectivity/connman/connman_1.17.bbappend}
  \scriptsize
  \begin{block}{}
  \begin{minted}{bash}
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += " file://connman.defaults"

do_install_append() {
    if ${@base_contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
        install -d ${D}${sysconfdir}/default
        install -m 0755 ${WORKDIR}/connman.defaults \
            ${D}${sysconfdir}/default/connman
    fi
}
  \end{minted}
  \end{block}
  \normalsize
  \code{recipes-connectivity/connman/connman/connman.defaults}
  \begin{block}{}
  \begin{minted}{c}
EXCLUDED_INTERFACES="usb0"
  \end{minted}
  \end{block}
\end{frame}

\begin{frame}[fragile]{Useful package tweaks}
  \code{recipes-core/busybox}, to be extended to install various
  configuration files for the \code{busybox applets}
  \code{recipes-core/busybox/busybox_1.21.1.bbappend}:
  \footnotesize
  \begin{block}{}
  \begin{minted}{c}
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"

SRC_URI_append_cfa10036 = " \
   file://udhcpd.conf \
"

do_install_append_cfa10036 () {
    install -m 0755 ${WORKDIR}/udhcpd.conf ${D}${sysconfdir}/
}
  \end{minted}
  \end{block}
  \normalsize
  This recipe is better than the previous one as it restrict changes
  to a particular machine.
\end{frame}

\begin{frame}[fragile]{Useful package tweaks}
  \code{recipes-core/psplash}, can be extended to change the splash
  screen, needs more to change the color of the progress bar:
  \code{recipes-core/psplash/psplash_git.bbappend}:
  \tiny
  \begin{block}{}
  \begin{minted}{c}
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
DEPENDS += "gdk-pixbuf-native"
PRINC = "8"
SRC_URI += "file://psplash-colors.h \
         file://psplash-bar-img.png"

# NB: this is only for the main logo image; if you add multiple images here,
# poky will build multiple psplash packages with 'outsuffix' in name for
# each of these ...
SPLASH_IMAGES = "file://psplash-poky-img.png;outsuffix=default"

# The core psplash recipe is only designed to deal with modifications to the
# 'logo' image; we need to change the bar image too, since we are changing
# colors
do_configure_append () {
        cd ${S}
        cp ../psplash-colors.h ./
        # strip the -img suffix from the bar png -- we could just store the
        # file under that suffix-less name, but that would make it confusing
        # for anyone updating the assets
        cp ../psplash-bar-img.png ./psplash-bar.png
        ./make-image-header.sh ./psplash-bar.png BAR
}
  \end{minted}
  \end{block}
  \normalsize
\end{frame}

\begin{frame}[fragile]{Lessons learned}
  \begin{itemize}
    \item due to the large amount of modifications in \code{oe-core}
      and \code{Poky}, your build will get broken!
    \item Don't use the following construct in \code{pkg_postinst}:
      \begin{block}{}
      \begin{minted}{c}
pkg_postinst_wpa-supplicant () {
        # If we're offline, we don't need to do this.
        if [ "x$D" != "x" ]; then
                exit 0
        fi

        killall -q -HUP dbus-daemon || true
}
      \end{minted}
      \end{block}
      It can't be extended using .bbappend
  \end{itemize}
\end{frame}

\begin{frame}{Lessons learned}
  \begin{itemize}
    \item it may be better to create two layers from the start, one
      with what will be upstreamed, the other one with customization.
    \item submit early
    \item you won't get notified when your patches hit upstream
    \item you may have to fix things in \code{Poky}, especially
      regarding initialization and X11
    \item using \code{repo} to manage the layers is really helpful,
      example: \url{https://github.com/Freescale/fsl-community-bsp-platform}
  \end{itemize}
\end{frame}

\begin{frame}{Documentation}
  \begin{itemize}
    \item \url{https://www.yoctoproject.org/documentation}
    \item in particular the variable glossary:
      \url{http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html\#ref-variables-glossary}
    \item and the BSP developer's guide:
      \url{http://www.yoctoproject.org/docs/current/bsp-guide/bsp-guide.html}
    \item Freescale BSP:
      \url{http://freescale.github.io}
  \end{itemize}
\end{frame}

\begin{frame}
  \begin{center}
    \LARGE
    Questions?\\
    \vspace{2.5cm}
    \small
    Alexandre Belloni\\
    \code{alexandre.belloni@bootlin.com}\\
    \vspace{0.5cm}
    Slides under CC-BY-SA 3.0\\
    \scriptsize
    \url{http://bootlin.com/pub/conferences/2014/elc/belloni-yocto-for-manufacturers/}
  \end{center}
\end{frame}

\begin{frame}{Give away}
  \includegraphics[width=\textwidth]{Give_Away1.jpg}
\end{frame}

\begin{frame}{Give away}
  \includegraphics[width=\textwidth]{Give_Away2.jpg}
\end{frame}

\begin{frame}{Give away}
  \includegraphics[width=\textwidth]{Give_Away3.jpg}
\end{frame}

\begin{frame}{Give away}
  \includegraphics[width=\textwidth]{Give_Away4.jpg}
\end{frame}

\begin{frame}{Give away}
  \includegraphics[width=\textwidth]{Give_Away5.jpg}
\end{frame}

\begin{frame}{Give away}
  \includegraphics[width=\textwidth]{Give_Away6.jpg}
\end{frame}

\end{document}
